Merge pull request #2060 from guardicore/1965-modify-i-stolen-credentials-repository

Modify IStolenCredentialsRepository
This commit is contained in:
Mike Salvatore 2022-07-05 11:07:47 -04:00 committed by GitHub
commit 1efea21269
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 95 additions and 17 deletions

View File

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

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_report_repository import IReportRepository
from monkey_island.cc.repository.i_simulation_repository import ISimulationRepository 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.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.IEventRepository import IEventRepository
from monkey_island.cc.repository.zero_trust.IFindingRepository import IFindingRepository from monkey_island.cc.repository.zero_trust.IFindingRepository import IFindingRepository
@ -225,12 +225,17 @@ INetworkMapRepository.save_netmap
IReportRepository IReportRepository
ISimulationRepository.save_simulation ISimulationRepository.save_simulation
ISimulationRepository.get_simulation ISimulationRepository.get_simulation
IStolenCredentialsRepository.get_stolen_credentials ICredentialsRepository.get_stolen_credentials
IStolenCredentialsRepository.save_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 ITelemetryRepository.get_telemetries
IEventRepository.get_events IEventRepository.get_events
IFindingRepository.get_findings IFindingRepository.get_findings
key_list key_list
simulation simulation
stolen_credentials
netmap netmap