From f5711e2fab35e8cf9be74ce5068d0a7f2ab6b09d Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 14 Sep 2022 13:35:49 -0400 Subject: [PATCH] Island: Add StubbedEventRepository A placeholder until MongoEventRepository is implemented --- .../monkey_island/cc/repository/__init__.py | 1 + .../cc/repository/stubbed_event_repository.py | 29 +++++++++++++++++++ vulture_allowlist.py | 7 ++++- 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 monkey/monkey_island/cc/repository/stubbed_event_repository.py diff --git a/monkey/monkey_island/cc/repository/__init__.py b/monkey/monkey_island/cc/repository/__init__.py index e2ce11dd4..a414b5eb0 100644 --- a/monkey/monkey_island/cc/repository/__init__.py +++ b/monkey/monkey_island/cc/repository/__init__.py @@ -26,3 +26,4 @@ from .mongo_credentials_repository import MongoCredentialsRepository from .mongo_machine_repository import MongoMachineRepository from .mongo_agent_repository import MongoAgentRepository from .mongo_node_repository import MongoNodeRepository +from .stubbed_event_repository import StubbedEventRepository diff --git a/monkey/monkey_island/cc/repository/stubbed_event_repository.py b/monkey/monkey_island/cc/repository/stubbed_event_repository.py new file mode 100644 index 000000000..d5260b6af --- /dev/null +++ b/monkey/monkey_island/cc/repository/stubbed_event_repository.py @@ -0,0 +1,29 @@ +from typing import Sequence, Type, TypeVar + +from common.events import AbstractAgentEvent +from common.types import AgentID + +from . import IEventRepository + +T = TypeVar("T", bound=AbstractAgentEvent) + + +# TODO: Remove this class after #2180 is complete +class StubbedEventRepository(IEventRepository): + def save_event(self, event: AbstractAgentEvent): + return + + def get_events(self) -> Sequence[AbstractAgentEvent]: + return [] + + def get_events_by_type(self, event_type: Type[T]) -> Sequence[T]: + return [] + + def get_events_by_tag(self, tag: str) -> Sequence[AbstractAgentEvent]: + return [] + + def get_events_by_source(self, source: AgentID) -> Sequence[AbstractAgentEvent]: + return [] + + def reset(self): + return diff --git a/vulture_allowlist.py b/vulture_allowlist.py index d942d34b2..8c57586b8 100644 --- a/vulture_allowlist.py +++ b/vulture_allowlist.py @@ -12,7 +12,11 @@ from infection_monkey.exploit.log4shell_utils.ldap_server import LDAPServerFacto from monkey_island.cc.event_queue import IslandEventTopic, PyPubSubIslandEventQueue from monkey_island.cc.models import Report from monkey_island.cc.models.networkmap import Arc, NetworkMap -from monkey_island.cc.repository import MongoAgentRepository, MongoMachineRepository +from monkey_island.cc.repository import ( + MongoAgentRepository, + MongoMachineRepository, + StubbedEventRepository, +) from monkey_island.cc.repository.attack.IMitigationsRepository import IMitigationsRepository from monkey_island.cc.repository.i_agent_repository import IAgentRepository from monkey_island.cc.repository.i_attack_repository import IAttackRepository @@ -279,6 +283,7 @@ IEventRepository.get_events IFindingRepository.get_findings MongoAgentRepository MongoMachineRepository +StubbedEventRepository key_list simulation netmap