From 6695e5b4acc7e44bfd3cb2544aa2c7334cba9f58 Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Mon, 4 Jul 2022 17:49:32 +0200 Subject: [PATCH] Island: Modify IStolenCredentialsRepository * Rename to ICredentialsRepository * Add {get/remove/save}_{stolen/configured}_credentials --- .../cc/repository/i_credentials_repository.py | 81 +++++++++++++++++++ .../i_stolen_credentials_repository.py | 13 --- vulture_allowlist.py | 13 ++- 3 files changed, 91 insertions(+), 16 deletions(-) create mode 100644 monkey/monkey_island/cc/repository/i_credentials_repository.py delete mode 100644 monkey/monkey_island/cc/repository/i_stolen_credentials_repository.py diff --git a/monkey/monkey_island/cc/repository/i_credentials_repository.py b/monkey/monkey_island/cc/repository/i_credentials_repository.py new file mode 100644 index 000000000..75dd6f6e1 --- /dev/null +++ b/monkey/monkey_island/cc/repository/i_credentials_repository.py @@ -0,0 +1,81 @@ +from abc import ABC +from typing import Sequence + +from monkey_island.cc.services.telemetry.processing.credentials import Credentials + + +class ICredentialsRepository(ABC): + def get_configured_credentials(self) -> Sequence[Credentials]: + """ + Retrieve all credentials that were configured. + + :raises RetrievalError: If an error is encountered while attempting to retrieve configured + credentials. + :return: Sequence of configured credentials + """ + pass + + def save_configured_credentials(self, configured_credentials: Credentials): + """ + Save credentials which are configured. + + :param configured_credentials: Credentials that are going to be stored. + :raises StorageError: If an error is encountered while attempting to store configured + credentials. + """ + pass + + def remove_configured_credentials(self): + """ + Remove all configured credentials. + + :raises RemovalError: If an error is encountered while attempting to remove configured + credentials. + """ + pass + + def get_stolen_credentials(self) -> Sequence[Credentials]: + """ + Retrieve credentials that are stolen + + :raises RetrievalError: If an error is encountered while attempting to retrieve stolen + credentials. + :return: Sequence of all stolen credentials + """ + pass + + def save_stolen_credentials(self, stolen_credentials: Credentials): + """ + Save credentials which are stolen. + + :param stolen_credentials: Credentials that are going to be stored. + :raises StorageError: If an error is encountered while attempting to store stolen + credentials. + """ + pass + + def remove_stolen_credentials(self): + """ + Remove all credentials from the repository. + + :raises RemovalError: If an error is encountered while attempting to remove the credentials. + """ + pass + + def get_all_credentials(self) -> Sequence[Credentials]: + """ + Retrieve stolen and configured credentials. + + :raises RetrievalError: If an error is encountered while attempting to retrieve the + credentials + :return: Sequence of stolen and configured credentials + """ + pass + + def remove_all_credentials(self): + """ + Remove all the credentials in the repository. + + :raises RemovalError: If an error is encountered while attempting to remove the credentials. + """ + pass diff --git a/monkey/monkey_island/cc/repository/i_stolen_credentials_repository.py b/monkey/monkey_island/cc/repository/i_stolen_credentials_repository.py deleted file mode 100644 index 00d8a4620..000000000 --- a/monkey/monkey_island/cc/repository/i_stolen_credentials_repository.py +++ /dev/null @@ -1,13 +0,0 @@ -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/vulture_allowlist.py b/vulture_allowlist.py index 22ddb97d5..383072f14 100644 --- a/vulture_allowlist.py +++ b/vulture_allowlist.py @@ -17,7 +17,7 @@ from monkey_island.cc.repository.i_network_map_repository import INetworkMapRepo from monkey_island.cc.repository.i_report_repository import IReportRepository from monkey_island.cc.repository.i_simulation_repository import ISimulationRepository from monkey_island.cc.repository.i_telemetry_repository import ITelemetryRepository -from monkey_island.cc.repository.IStolenCredentials import IStolenCredentialsRepository +from monkey_island.cc.repository.ICredentials import ICredentialsRepository from monkey_island.cc.repository.zero_trust.IEventRepository import IEventRepository from monkey_island.cc.repository.zero_trust.IFindingRepository import IFindingRepository @@ -225,12 +225,19 @@ INetworkMapRepository.save_netmap IReportRepository ISimulationRepository.save_simulation ISimulationRepository.get_simulation -IStolenCredentialsRepository.get_stolen_credentials -IStolenCredentialsRepository.save_stolen_credentials +ICredentialsRepository.get_stolen_credentials +ICredentialsRepository.get_configured_credentials +ICredentialsRepository.get_all_credentials +ICredentialsRepository.remove_stolen_credentials +ICredentialsRepository.remove_configured_credentials +ICredentialsRepository.remove_all_credentials +ICredentialsRepository.save_stolen_credentials +ICredentialsRepository.save_configured_credentials ITelemetryRepository.get_telemetries IEventRepository.get_events IFindingRepository.get_findings key_list simulation stolen_credentials +configured_credentials netmap