Island: Modify IStolenCredentialsRepository

* Rename to ICredentialsRepository
* Add {get/remove/save}_{stolen/configured}_credentials
This commit is contained in:
Ilija Lazoroski 2022-07-04 17:49:32 +02:00
parent 353605d672
commit 6695e5b4ac
3 changed files with 91 additions and 16 deletions

View File

@ -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

View File

@ -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

View File

@ -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