forked from p15670423/monkey
Island: Rename IEventRepository -> IAgentEventRepository
This commit is contained in:
parent
f0d5545f28
commit
0dccbd32b6
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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__(
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue