From 4bbd9981972210b11ff17d00682a71897cdb7c47 Mon Sep 17 00:00:00 2001 From: vakarisz Date: Wed, 18 May 2022 17:29:38 +0300 Subject: [PATCH] Island: Add remaining repository interfaces --- monkey/monkey_island/cc/dal/ILogRepository.py | 14 ++++++++++++++ monkey/monkey_island/cc/dal/IStolenCredentials.py | 13 +++++++++++++ .../monkey_island/cc/dal/ITelemStoreRepository.py | 9 +++++++-- monkey/monkey_island/cc/dal/__init__.py | 0 .../cc/dal/attack/IMitigationsRepository.py | 12 ++++++++++++ .../cc/dal/zero_trust/IEventRepository.py | 11 +++++++++++ .../cc/dal/zero_trust/IFindingRepository.py | 13 +++++++++++++ monkey/monkey_island/cc/dal/zero_trust/__init__.py | 0 8 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 monkey/monkey_island/cc/dal/ILogRepository.py create mode 100644 monkey/monkey_island/cc/dal/IStolenCredentials.py create mode 100644 monkey/monkey_island/cc/dal/__init__.py create mode 100644 monkey/monkey_island/cc/dal/attack/IMitigationsRepository.py create mode 100644 monkey/monkey_island/cc/dal/zero_trust/IEventRepository.py create mode 100644 monkey/monkey_island/cc/dal/zero_trust/IFindingRepository.py create mode 100644 monkey/monkey_island/cc/dal/zero_trust/__init__.py diff --git a/monkey/monkey_island/cc/dal/ILogRepository.py b/monkey/monkey_island/cc/dal/ILogRepository.py new file mode 100644 index 000000000..3da83d167 --- /dev/null +++ b/monkey/monkey_island/cc/dal/ILogRepository.py @@ -0,0 +1,14 @@ +from abc import ABC +from typing import Optional, Sequence + + +class ILogRepository(ABC): + # Define log object + def get_logs(self, agent_id: Optional[str] = None) -> Sequence[Log]: + pass + + def save_log(self, log: Log): + pass + + def delete_log(self, agent_id: str): + pass diff --git a/monkey/monkey_island/cc/dal/IStolenCredentials.py b/monkey/monkey_island/cc/dal/IStolenCredentials.py new file mode 100644 index 000000000..00d8a4620 --- /dev/null +++ b/monkey/monkey_island/cc/dal/IStolenCredentials.py @@ -0,0 +1,13 @@ +from abc import ABC +from typing import Sequence + +from monkey_island.cc.models import StolenCredentials + + +# Consider removing this interface and just using the telemetry type +class IStolenCredentialsRepository(ABC): + def get_stolen_credentials(self) -> Sequence[StolenCredentials]: + pass + + def save_stolen_credentials(self, stolen_credentials: StolenCredentials): + pass diff --git a/monkey/monkey_island/cc/dal/ITelemStoreRepository.py b/monkey/monkey_island/cc/dal/ITelemStoreRepository.py index bf5648b78..0b791e474 100644 --- a/monkey/monkey_island/cc/dal/ITelemStoreRepository.py +++ b/monkey/monkey_island/cc/dal/ITelemStoreRepository.py @@ -1,7 +1,12 @@ from abc import ABC +from typing import Sequence + +from monkey_island.cc.models.exported_telem import ExportedTelem class ITelemStoreRepository(ABC): - def get_telemetries(self): - # Used to get ExportedTelem for the Telemtry Store + def get_telemetries(self) -> Sequence[ExportedTelem]: + pass + + def save_telemetry(self, telemetry: ExportedTelem): pass diff --git a/monkey/monkey_island/cc/dal/__init__.py b/monkey/monkey_island/cc/dal/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/monkey/monkey_island/cc/dal/attack/IMitigationsRepository.py b/monkey/monkey_island/cc/dal/attack/IMitigationsRepository.py new file mode 100644 index 000000000..2a480b77a --- /dev/null +++ b/monkey/monkey_island/cc/dal/attack/IMitigationsRepository.py @@ -0,0 +1,12 @@ +from abc import ABC +from typing import Optional + +from monkey_island.cc.models.attack.attack_mitigations import AttackMitigations + + +class IMitigationsRepository(ABC): + def get_mitigations(self, technique_id: Optional[str] = None) -> AttackMitigations: + pass + + def save_mitigations(self, mitigations: AttackMitigations): + pass diff --git a/monkey/monkey_island/cc/dal/zero_trust/IEventRepository.py b/monkey/monkey_island/cc/dal/zero_trust/IEventRepository.py new file mode 100644 index 000000000..3f4af68c5 --- /dev/null +++ b/monkey/monkey_island/cc/dal/zero_trust/IEventRepository.py @@ -0,0 +1,11 @@ +from abc import ABC +from typing import Optional, Sequence + +from monkey_island.cc.models.zero_trust.event import Event + + +class IEventRepository(ABC): + def get_events(self, finding_id: Optional[str] = None) -> Sequence[Event]: + pass + + # Events are saved in IFindingRepository, because finding had many events diff --git a/monkey/monkey_island/cc/dal/zero_trust/IFindingRepository.py b/monkey/monkey_island/cc/dal/zero_trust/IFindingRepository.py new file mode 100644 index 000000000..c66ee0e73 --- /dev/null +++ b/monkey/monkey_island/cc/dal/zero_trust/IFindingRepository.py @@ -0,0 +1,13 @@ +from abc import ABC +from typing import Optional + +# Zero trust finding +from monkey_island.cc.models.zero_trust.finding import Finding + + +class IFindingRepository(ABC): + def get_findings(self, test: Optional[str] = None) -> Finding: + pass + + def save_finding(self, finding: Finding): + pass diff --git a/monkey/monkey_island/cc/dal/zero_trust/__init__.py b/monkey/monkey_island/cc/dal/zero_trust/__init__.py new file mode 100644 index 000000000..e69de29bb