diff --git a/monkey/monkey_island/cc/agent_event_handlers/save_event_to_event_repository.py b/monkey/monkey_island/cc/agent_event_handlers/save_event_to_event_repository.py index 4d69b6283..5558ae83b 100644 --- a/monkey/monkey_island/cc/agent_event_handlers/save_event_to_event_repository.py +++ b/monkey/monkey_island/cc/agent_event_handlers/save_event_to_event_repository.py @@ -1,13 +1,13 @@ import logging from common.events import AbstractAgentEvent -from monkey_island.cc.repository import IEventRepository, StorageError +from monkey_island.cc.repository import IAgentEventRepository, StorageError logger = logging.getLogger(__name__) class save_event_to_event_repository: - def __init__(self, event_repository: IEventRepository): + def __init__(self, event_repository: IAgentEventRepository): self._event_repository = event_repository def __call__(self, event: AbstractAgentEvent): diff --git a/monkey/monkey_island/cc/repository/__init__.py b/monkey/monkey_island/cc/repository/__init__.py index 63e9ac214..1ac6d99e6 100644 --- a/monkey/monkey_island/cc/repository/__init__.py +++ b/monkey/monkey_island/cc/repository/__init__.py @@ -10,7 +10,7 @@ from .i_user_repository import IUserRepository from .i_machine_repository import IMachineRepository from .i_agent_repository import IAgentRepository from .i_node_repository import INodeRepository -from .i_event_repository import IEventRepository +from .i_event_repository import IAgentEventRepository from .local_storage_file_repository import LocalStorageFileRepository diff --git a/monkey/monkey_island/cc/repository/i_event_repository.py b/monkey/monkey_island/cc/repository/i_event_repository.py index 94bc895dc..b119e8191 100644 --- a/monkey/monkey_island/cc/repository/i_event_repository.py +++ b/monkey/monkey_island/cc/repository/i_event_repository.py @@ -7,7 +7,7 @@ from common.types import AgentID T = TypeVar("T", bound=AbstractAgentEvent) -class IEventRepository(ABC): +class IAgentEventRepository(ABC): """A repository used to store and retrieve event objects""" @abstractmethod diff --git a/monkey/monkey_island/cc/repository/mongo_event_repository.py b/monkey/monkey_island/cc/repository/mongo_event_repository.py index 5e8b4f21e..14525ac33 100644 --- a/monkey/monkey_island/cc/repository/mongo_event_repository.py +++ b/monkey/monkey_island/cc/repository/mongo_event_repository.py @@ -5,13 +5,13 @@ from pymongo import MongoClient from common.agent_event_serializers import EVENT_TYPE_FIELD, AgentEventSerializerRegistry from common.events import AbstractAgentEvent from common.types import AgentID -from monkey_island.cc.repository import IEventRepository +from monkey_island.cc.repository import IAgentEventRepository from . import RemovalError, RetrievalError, StorageError from .consts import MONGO_OBJECT_ID_KEY -class MongoEventRepository(IEventRepository): +class MongoEventRepository(IAgentEventRepository): """A repository for storing and retrieving events in MongoDB""" def __init__( diff --git a/monkey/monkey_island/cc/repository/stubbed_event_repository.py b/monkey/monkey_island/cc/repository/stubbed_event_repository.py index d5260b6af..c507cf92c 100644 --- a/monkey/monkey_island/cc/repository/stubbed_event_repository.py +++ b/monkey/monkey_island/cc/repository/stubbed_event_repository.py @@ -3,13 +3,13 @@ from typing import Sequence, Type, TypeVar from common.events import AbstractAgentEvent from common.types import AgentID -from . import IEventRepository +from . import IAgentEventRepository T = TypeVar("T", bound=AbstractAgentEvent) # TODO: Remove this class after #2180 is complete -class StubbedEventRepository(IEventRepository): +class StubbedEventRepository(IAgentEventRepository): def save_event(self, event: AbstractAgentEvent): return diff --git a/monkey/monkey_island/cc/repository/zero_trust/IEventRepository.py b/monkey/monkey_island/cc/repository/zero_trust/IEventRepository.py index 3f4af68c5..28e0c6ff8 100644 --- a/monkey/monkey_island/cc/repository/zero_trust/IEventRepository.py +++ b/monkey/monkey_island/cc/repository/zero_trust/IEventRepository.py @@ -4,7 +4,7 @@ from typing import Optional, Sequence from monkey_island.cc.models.zero_trust.event import Event -class IEventRepository(ABC): +class IAgentEventRepository(ABC): def get_events(self, finding_id: Optional[str] = None) -> Sequence[Event]: pass diff --git a/monkey/monkey_island/cc/services/initialize.py b/monkey/monkey_island/cc/services/initialize.py index bba100c83..df4f92d6b 100644 --- a/monkey/monkey_island/cc/services/initialize.py +++ b/monkey/monkey_island/cc/services/initialize.py @@ -23,8 +23,8 @@ from monkey_island.cc.repository import ( FileSimulationRepository, IAgentBinaryRepository, IAgentConfigurationRepository, + IAgentEventRepository, ICredentialsRepository, - IEventRepository, IFileRepository, ISimulationRepository, IUserRepository, @@ -102,7 +102,7 @@ def _register_repositories(container: DIContainer, data_dir: Path): container.register_instance(IUserRepository, container.resolve(JSONFileUserRepository)) # TODO: Replace with MongoEventRepository - container.register_instance(IEventRepository, StubbedEventRepository()) + container.register_instance(IAgentEventRepository, StubbedEventRepository()) def _decorate_file_repository(file_repository: IFileRepository) -> IFileRepository: diff --git a/monkey/monkey_island/cc/setup/agent_event_handlers.py b/monkey/monkey_island/cc/setup/agent_event_handlers.py index d3df0ce4f..989363c43 100644 --- a/monkey/monkey_island/cc/setup/agent_event_handlers.py +++ b/monkey/monkey_island/cc/setup/agent_event_handlers.py @@ -5,7 +5,7 @@ from monkey_island.cc.agent_event_handlers import ( save_event_to_event_repository, save_stolen_credentials_to_repository, ) -from monkey_island.cc.repository import ICredentialsRepository, IEventRepository +from monkey_island.cc.repository import IAgentEventRepository, ICredentialsRepository def setup_agent_event_handlers(container: DIContainer): @@ -15,7 +15,7 @@ def setup_agent_event_handlers(container: DIContainer): def _subscribe_and_store_to_event_repository(container: DIContainer): agent_event_queue = container.resolve(IAgentEventQueue) - save_event_subscriber = save_event_to_event_repository(container.resolve(IEventRepository)) + save_event_subscriber = save_event_to_event_repository(container.resolve(IAgentEventRepository)) agent_event_queue.subscribe_all_events(save_event_subscriber) save_stolen_credentials_subscriber = save_stolen_credentials_to_repository(