diff --git a/monkey/monkey_island/cc/services/initialize.py b/monkey/monkey_island/cc/services/initialize.py index 114a1b8c9..2ff9963a8 100644 --- a/monkey/monkey_island/cc/services/initialize.py +++ b/monkey/monkey_island/cc/services/initialize.py @@ -14,6 +14,7 @@ from common.aws import AWSInstance from common.common_consts.telem_categories import TelemCategoryEnum from common.utils.file_utils import get_binary_io_sha256_hash from common.version import get_version +from monkey_island.cc.deployment import Deployment from monkey_island.cc.repository import ( AgentBinaryRepository, FileAgentConfigurationRepository, @@ -35,7 +36,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.deployment import Deployment 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 @@ -46,6 +46,7 @@ from monkey_island.cc.services.telemetry.processing.processing import ( TELEMETRY_CATEGORY_TO_PROCESSING_FUNC, ) from monkey_island.cc.setup.mongo.mongo_setup import MONGO_URL +from monkey_island.cc.version import Version from . import AuthenticationService from .reporting.report import ReportService @@ -66,7 +67,7 @@ def initialize_services(data_dir: Path) -> DIContainer: container.register_instance( ILockableEncryptor, RepositoryEncryptor(data_dir / REPOSITORY_KEY_FILE_NAME) ) - + container.register_instance(Version, container.resolve(Version)) _register_repositories(container, data_dir) _register_services(container) @@ -93,7 +94,9 @@ def _register_conventions(container: DIContainer, data_dir: Path): DEFAULT_RANSOMWARE_AGENT_CONFIGURATION, ) container.register_convention(Path, "island_log_file_path", get_log_file_path(data_dir)) - container.register_convention(Deployment, "deployment", _get_depyloyment_from_file(DEPLOYMENT_FILE_PATH)) + container.register_convention( + Deployment, "deployment", _get_depyloyment_from_file(DEPLOYMENT_FILE_PATH) + ) container.register_convention(str, "version_number", get_version()) @@ -151,6 +154,7 @@ def _log_agent_binary_hashes(agent_binary_repository: IAgentBinaryRepository): for os, binary_sha256_hash in agent_hashes.items(): logger.info(f"{os} agent: SHA-256 hash: {binary_sha256_hash}") + def _get_depyloyment_from_file(file_path: Path) -> Deployment: try: with open(file_path, "r") as deployment_info_file: