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..74ab94628 --- /dev/null +++ b/monkey/monkey_island/cc/repository/i_credentials_repository.py @@ -0,0 +1,86 @@ +from abc import ABC +from typing import Sequence + +from monkey_island.cc.services.telemetry.processing.credentials import Credentials + + +class ICredentialsRepository(ABC): + """ + Store credentials that can be used to propagate around the network. + + This repository stores credentials that were either "configured" or "stolen". "Configured" + credentials are provided to the simulation as input. "Stolen" credentials are collected during + a simulation. + """ + + def get_configured_credentials(self) -> Sequence[Credentials]: + """ + Retrieve credentials that were configured. + + :raises RetrievalError: If an error is encountered while attempting to retrieve the + credentials + :return: Sequence of configured credentials + """ + pass + + def get_stolen_credentials(self) -> Sequence[Credentials]: + """ + Retrieve credentials that were stolen during a simulation. + + :raises RetrievalError: If an error is encountered while attempting to retrieve the + credentials + :return: Sequence of stolen credentials + """ + pass + + def get_all_credentials(self) -> Sequence[Credentials]: + """ + Retrieve all credentials in the repository. + + :raises RetrievalError: If an error is encountered while attempting to retrieve the + credentials + :return: Sequence of stolen and configured credentials + """ + pass + + def save_configured_credentials(self, credentials: Credentials): + """ + Save credentials that were configured. + + :param credentials: Configured Credentials to store in the repository + :raises StorageError: If an error is encountered while attempting to store the credentials + """ + pass + + def save_stolen_credentials(self, credentials: Credentials): + """ + Save credentials that were stolen during a simulation. + + :param credentials: Stolen Credentials to store in the repository + :raises StorageError: If an error is encountered while attempting to store the credentials + """ + pass + + def remove_configured_credentials(self): + """ + Remove credentials that were configured from the repository. + + :raises RemovalError: If an error is encountered while attempting to remove the credentials + """ + pass + + def remove_stolen_credentials(self): + """ + Remove stolen credentials from the repository. + + :raises RemovalError: If an error is encountered while attempting to remove the credentials + """ + pass + + def remove_all_credentials(self): + """ + Remove all 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..a3393325e 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,17 @@ 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 netmap