From 5e7a252a6b3f44528bf5d9f54b0234be98921cdf Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 13 Oct 2021 11:57:23 -0400 Subject: [PATCH] Island: Rename KEY_FILE_DIRECTORY -> DATA_DIR Neither the AuthenticationService, nor the function that initializes it needs to know what the data_dir is for. AuthenticationService only needs to know that datastore_encryptor needs it, but not why. --- monkey/monkey_island/cc/services/authentication.py | 10 +++++----- monkey/monkey_island/cc/services/initialize.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/monkey/monkey_island/cc/services/authentication.py b/monkey/monkey_island/cc/services/authentication.py index 79749d546..064c27728 100644 --- a/monkey/monkey_island/cc/services/authentication.py +++ b/monkey/monkey_island/cc/services/authentication.py @@ -10,14 +10,14 @@ from monkey_island.cc.setup.mongo.database_initializer import reset_database class AuthenticationService: - KEY_FILE_DIRECTORY = None + DATA_DIR = None # TODO: A number of these services should be instance objects instead of # static/singleton hybrids. At the moment, this requires invasive refactoring that's # not a priority. @classmethod - def initialize(cls, key_file_directory): - cls.KEY_FILE_DIRECTORY = key_file_directory + def initialize(cls, data_dir: str): + cls.DATA_DIR = data_dir @staticmethod def needs_registration() -> bool: @@ -41,12 +41,12 @@ class AuthenticationService: @classmethod def _unlock_datastore_encryptor(cls, username: str, password: str): secret = _get_secret_from_credentials(username, password) - unlock_datastore_encryptor(cls.KEY_FILE_DIRECTORY, secret) + unlock_datastore_encryptor(cls.DATA_DIR, secret) @classmethod def _reset_datastore_encryptor(cls, username: str, password: str): secret = _get_secret_from_credentials(username, password) - reset_datastore_encryptor(cls.KEY_FILE_DIRECTORY, secret) + reset_datastore_encryptor(cls.DATA_DIR, secret) def _hash_password(plaintext_password): diff --git a/monkey/monkey_island/cc/services/initialize.py b/monkey/monkey_island/cc/services/initialize.py index b6e37bbc7..caa599e00 100644 --- a/monkey/monkey_island/cc/services/initialize.py +++ b/monkey/monkey_island/cc/services/initialize.py @@ -6,4 +6,4 @@ from monkey_island.cc.services.run_local_monkey import LocalMonkeyRunService def initialize_services(data_dir): PostBreachFilesService.initialize(data_dir) LocalMonkeyRunService.initialize(data_dir) - AuthenticationService.initialize(key_file_directory=data_dir) + AuthenticationService.initialize(data_dir)