Island: Add save_stolen_credentials_to_repository

This commit is contained in:
Mike Salvatore 2022-09-14 13:49:23 -04:00
parent d5979fae16
commit 4db251dd7d
2 changed files with 24 additions and 0 deletions

View File

@ -1 +1,2 @@
from .save_event_to_event_repository import save_event_to_event_repository from .save_event_to_event_repository import save_event_to_event_repository
from .save_stolen_credentials_to_repository import save_stolen_credentials_to_repository

View File

@ -0,0 +1,23 @@
import logging
from common.events import CredentialsStolenEvent
from monkey_island.cc.repository import ICredentialsRepository, StorageError
logger = logging.getLogger(__name__)
class save_stolen_credentials_to_repository:
"""
Accepts CredentialsStolenEvent and pushes the stolen credentials into ICredentialsRepository
"""
def __init__(self, credentials_repository: ICredentialsRepository):
self._credentials_repository = credentials_repository
def __call__(self, credentials_stolen_event: CredentialsStolenEvent):
try:
self._credentials_repository.save_stolen_credentials(
credentials_stolen_event.stolen_credentials
)
except StorageError as err:
logger.error(f"Error occurred while storing stolen credentials: {err}")