From d6e0b03a64c736583c0208d8277708661cecb420 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Fri, 12 Aug 2022 12:02:23 -0400 Subject: [PATCH] Island: Move island log file registration to setup_server.py --- monkey/monkey_island/cc/server_setup.py | 2 ++ monkey/monkey_island/cc/services/initialize.py | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/monkey/monkey_island/cc/server_setup.py b/monkey/monkey_island/cc/server_setup.py index f8b1261f3..e98c4f652 100644 --- a/monkey/monkey_island/cc/server_setup.py +++ b/monkey/monkey_island/cc/server_setup.py @@ -13,6 +13,7 @@ from gevent.pywsgi import WSGIServer from monkey_island.cc import Version from monkey_island.cc.deployment import Deployment from monkey_island.cc.server_utils.consts import ISLAND_PORT +from monkey_island.cc.server_utils.island_logger import get_log_file_path from monkey_island.cc.setup.config_setup import get_server_config # Add the monkey_island directory to the path, to make sure imports that don't start with @@ -120,6 +121,7 @@ def _initialize_di_container( container.register_convention(Sequence[str], "ip_addresses", ip_addresses) container.register_instance(Version, version) container.register_convention(Path, "data_dir", data_dir) + container.register_convention(Path, "island_log_file_path", get_log_file_path(data_dir)) initialize_services(container, data_dir) diff --git a/monkey/monkey_island/cc/services/initialize.py b/monkey/monkey_island/cc/services/initialize.py index 2a824e752..3ceb489c2 100644 --- a/monkey/monkey_island/cc/services/initialize.py +++ b/monkey/monkey_island/cc/services/initialize.py @@ -34,7 +34,6 @@ from monkey_island.cc.repository import ( ) from monkey_island.cc.server_utils.consts import MONKEY_ISLAND_ABS_PATH from monkey_island.cc.server_utils.encryption import ILockableEncryptor, RepositoryEncryptor -from monkey_island.cc.server_utils.island_logger import get_log_file_path from monkey_island.cc.services import AWSService, IslandModeService, RepositoryService from monkey_island.cc.services.attack.technique_reports.T1003 import T1003, T1003GetReportData from monkey_island.cc.services.run_local_monkey import LocalMonkeyRunService @@ -56,7 +55,7 @@ REPOSITORY_KEY_FILE_NAME = "repository_key.bin" def initialize_services(container: DIContainer, data_dir: Path): - _register_conventions(container, data_dir) + _register_conventions(container) container.register_instance(AWSInstance, AWSInstance()) container.register_instance(MongoClient, MongoClient(MONGO_URL, serverSelectionTimeoutMS=100)) @@ -79,7 +78,7 @@ def initialize_services(container: DIContainer, data_dir: Path): ) -def _register_conventions(container: DIContainer, data_dir: Path): +def _register_conventions(container: DIContainer): container.register_convention( AgentConfiguration, "default_agent_configuration", DEFAULT_AGENT_CONFIGURATION ) @@ -88,7 +87,6 @@ def _register_conventions(container: DIContainer, data_dir: Path): "default_ransomware_agent_configuration", DEFAULT_RANSOMWARE_AGENT_CONFIGURATION, ) - container.register_convention(Path, "island_log_file_path", get_log_file_path(data_dir)) def _register_repositories(container: DIContainer, data_dir: Path):