forked from p15670423/monkey
Island: Register mongo client in DI container
This commit is contained in:
parent
0bddef7078
commit
b7786e2d0a
|
@ -66,6 +66,9 @@ def _register_conventions(container: DIContainer, data_dir: Path):
|
||||||
"default_ransomware_agent_configuration",
|
"default_ransomware_agent_configuration",
|
||||||
DEFAULT_RANSOMWARE_AGENT_CONFIGURATION,
|
DEFAULT_RANSOMWARE_AGENT_CONFIGURATION,
|
||||||
)
|
)
|
||||||
|
container.register_convention(
|
||||||
|
MongoClient, "mongo", MongoClient(MONGO_URL, serverSelectionTimeoutMS=100)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _register_repositories(container: DIContainer, data_dir: Path):
|
def _register_repositories(container: DIContainer, data_dir: Path):
|
||||||
|
@ -78,7 +81,9 @@ def _register_repositories(container: DIContainer, data_dir: Path):
|
||||||
IAgentConfigurationRepository, container.resolve(FileAgentConfigurationRepository)
|
IAgentConfigurationRepository, container.resolve(FileAgentConfigurationRepository)
|
||||||
)
|
)
|
||||||
container.register_instance(ISimulationRepository, container.resolve(FileSimulationRepository))
|
container.register_instance(ISimulationRepository, container.resolve(FileSimulationRepository))
|
||||||
container.register_instance(ICredentialsRepository, _build_mongo_credentials_repository())
|
container.register_instance(
|
||||||
|
ICredentialsRepository, container.resolve(MongoCredentialsRepository)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _decorate_file_repository(file_repository: IFileRepository) -> IFileRepository:
|
def _decorate_file_repository(file_repository: IFileRepository) -> IFileRepository:
|
||||||
|
@ -96,13 +101,6 @@ def _build_agent_binary_repository():
|
||||||
return agent_binary_repository
|
return agent_binary_repository
|
||||||
|
|
||||||
|
|
||||||
def _build_mongo_credentials_repository():
|
|
||||||
mongo = MongoClient(MONGO_URL, serverSelectionTimeoutMS=100)
|
|
||||||
|
|
||||||
mongo_credentials_repository = MongoCredentialsRepository(mongo)
|
|
||||||
return mongo_credentials_repository
|
|
||||||
|
|
||||||
|
|
||||||
def _log_agent_binary_hashes(agent_binary_repository: IAgentBinaryRepository):
|
def _log_agent_binary_hashes(agent_binary_repository: IAgentBinaryRepository):
|
||||||
"""
|
"""
|
||||||
Logs all the hashes of the agent executables for debbuging ease
|
Logs all the hashes of the agent executables for debbuging ease
|
||||||
|
|
Loading…
Reference in New Issue