diff --git a/poortego/dispatcher.py b/poortego/dispatcher.py index e550236..eb74fe6 100644 --- a/poortego/dispatcher.py +++ b/poortego/dispatcher.py @@ -33,6 +33,7 @@ class Dispatcher(Cmd): # def __init__(self): Cmd.__init__(self) + self.namespace = 'poortego' self.prompt = 'poortego> ' self.do_poortego_reinitialize('') @@ -56,7 +57,7 @@ def do_poortego_login(self, arg): self.stdout.write("\n Password: ") password_string = (self.stdin.readline()).replace('\n','') attempted_user = User(username_string, password_string) - if (attempted_user.is_authenticated): + if (attempted_user.authenticate()): self.my_session.user = attempted_user # @@ -161,6 +162,7 @@ def do_import(self, arg, opts=None): fn = arg # TODO elif opts.stix: + # TODO fn = arg (stix_package, stix_package_binding_obj) = STIXPackage.from_xml(fn) stix_dict = stix_package.to_dict() # parse to dictionary @@ -201,7 +203,7 @@ def do_poortego_purge(self, arg): """Command to delete EVERYTHING from GraphDB""" self.stdout.write("This will delete EVERYTHING from the GraphDB!!! Are you sure you want to do this [Y/N]: ") response = (self.stdin.readline()).replace('\n','') - if (response == 'Y'): + if response == 'Y' or response == 'y': self.my_graph.PURGE() self.stdout.write("Database purged.\n") self.do_poortego_reinitialize('') diff --git a/poortego/poortego_passwd.txt b/poortego/poortego_passwd.txt deleted file mode 100644 index 26d0a3a..0000000 --- a/poortego/poortego_passwd.txt +++ /dev/null @@ -1,13 +0,0 @@ -# poortego_passwd.txt -# -# Default file for stupid/basic user authentication -# Format: username:password MD5:group -# - -# Example users: -# username: guest, password: guest, groups: guest -# username: analyst, password: analyst, groups: analyst, guest -# username: admin, password: admin, groups: admin, analyst, guest -guest:084e0343a0486ff05530df6c705c8bb4:guest -analyst:05d5c5dfb743a5bd8fd7494fdc9bdb00:analyst,guest -admin:21232f297a57a5a743894a0e4a801fc3:admin,analyst,guest diff --git a/poortego/session.py b/poortego/session.py index 447033a..bc38375 100644 --- a/poortego/session.py +++ b/poortego/session.py @@ -7,29 +7,32 @@ import time +from .user import User + class Session: """Used for tracking Poortego session state""" def __init__(self): - self.username = "" # TODO + self.user = User('guest','guest') + self.user.authenticate() self.home_node_id = -1 self.current_node_id = -1 now_string = time.strftime("%Y-%m-%d %H:%M:%S") self.default_node_meta = { - "created_by":self.username, + "created_by":self.user.username, "created_at":now_string, "creation_method":"Poortego shell", - "last_accessed_by":self.username, + "last_accessed_by":self.user.username, "last_accessed_at":now_string, - "last_modified_by":self.username, + "last_modified_by":self.user.username, "last_modified_at":now_string } self.default_link_meta = { - "created_by":self.username, + "created_by":self.user.username, "created_at":now_string, "creation_method":"Poortego shell", - "last_accessed_by":self.username, + "last_accessed_by":self.user.username, "last_accessed_at":now_string, - "last_modified_by":self.username, + "last_modified_by":self.user.username, "last_modified_at":now_string } @@ -45,6 +48,6 @@ def update_link_meta(self): def display(self): print "Session Info:" print "-------------" - print " Username: " + str(self.username) + print " Username: " + str(self.user.username) print " Home Node Id: " + str(self.home_node_id) print " Current Node Id: " + str(self.current_node_id) diff --git a/poortego/user.py b/poortego/user.py index b555f32..b2eb50b 100644 --- a/poortego/user.py +++ b/poortego/user.py @@ -10,6 +10,7 @@ class User: """Used for tracking Poortego user""" def __init__(self, username, password): + self.password_file = 'poortego_passwd.txt' self.username = username self.password = password self.authenticated = False @@ -18,7 +19,7 @@ def __init__(self, username, password): def authenticate(self): """Stupid/basic authentication against a file - update before using in production""" # TODO - improve authentication - with open('poortego_passwd.txt', 'r') as users_file: + with open(self.password_file, 'r') as users_file: userreader = csv.reader(users_file, delimiter=':') for row in userreader: if len(row) == 3: @@ -47,4 +48,5 @@ def authenticate(self): #user = User('guest', 'guest') #user = User('analyst','analyst') user = User('admin', 'admin') + user.password_file = "../" + user.password_file user.authenticate()