diff --git a/monkey/monkey_island/cc/services/initialize.py b/monkey/monkey_island/cc/services/initialize.py index 28a88558c..dad5b92c7 100644 --- a/monkey/monkey_island/cc/services/initialize.py +++ b/monkey/monkey_island/cc/services/initialize.py @@ -12,6 +12,9 @@ from common.utils.file_utils import get_binary_io_sha256_hash from monkey_island.cc.repository import ( AgentBinaryRepository, FileAgentConfigurationRepository, + FileRepositoryCachingDecorator, + FileRepositoryLockingDecorator, + FileRepositoryLoggingDecorator, FileSimulationRepository, IAgentBinaryRepository, IAgentConfigurationRepository, @@ -62,7 +65,8 @@ def _register_conventions(container: DIContainer, data_dir: Path): def _register_repositories(container: DIContainer, data_dir: Path): container.register_instance( - IFileRepository, LocalStorageFileRepository(data_dir / "runtime_data") + IFileRepository, + _decorate_file_repository(LocalStorageFileRepository(data_dir / "runtime_data")), ) container.register_instance(IAgentBinaryRepository, _build_agent_binary_repository()) container.register_instance( @@ -71,6 +75,12 @@ def _register_repositories(container: DIContainer, data_dir: Path): container.register_instance(ISimulationRepository, container.resolve(FileSimulationRepository)) +def _decorate_file_repository(file_repository: IFileRepository) -> IFileRepository: + return FileRepositoryLockingDecorator( + FileRepositoryCachingDecorator(FileRepositoryLoggingDecorator(file_repository)) + ) + + def _build_agent_binary_repository(): file_repository = LocalStorageFileRepository(AGENT_BINARIES_PATH) agent_binary_repository = AgentBinaryRepository(file_repository)