Island: Register Island log file path as convention in DI container and inject into IslandLog

This commit is contained in:
Shreya Malviya 2022-08-01 13:28:19 +05:30
parent 24aea69220
commit b89ffbae24
2 changed files with 6 additions and 0 deletions

View File

@ -1,4 +1,5 @@
import logging import logging
from pathlib import Path
from monkey_island.cc.resources.AbstractResource import AbstractResource from monkey_island.cc.resources.AbstractResource import AbstractResource
from monkey_island.cc.resources.request_authentication import jwt_required from monkey_island.cc.resources.request_authentication import jwt_required
@ -10,6 +11,9 @@ logger = logging.getLogger(__name__)
class IslandLog(AbstractResource): class IslandLog(AbstractResource):
urls = ["/api/island/log"] urls = ["/api/island/log"]
def __init__(self, island_log_file_path: Path):
self._island_log_file_path = island_log_file_path
@jwt_required @jwt_required
def get(self): def get(self):
try: try:

View File

@ -32,6 +32,7 @@ from monkey_island.cc.repository import (
) )
from monkey_island.cc.server_utils.consts import MONKEY_ISLAND_ABS_PATH 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.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 import AWSService, IslandModeService, RepositoryService
from monkey_island.cc.services.attack.technique_reports.T1003 import T1003, T1003GetReportData from monkey_island.cc.services.attack.technique_reports.T1003 import T1003, T1003GetReportData
from monkey_island.cc.services.run_local_monkey import LocalMonkeyRunService from monkey_island.cc.services.run_local_monkey import LocalMonkeyRunService
@ -87,6 +88,7 @@ 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(Path, "island_log_file_path", get_log_file_path())
def _register_repositories(container: DIContainer, data_dir: Path): def _register_repositories(container: DIContainer, data_dir: Path):