Island: Add save_stolen_credentials_to_repository
This commit is contained in:
parent
d5979fae16
commit
4db251dd7d
|
@ -1 +1,2 @@
|
|||
from .save_event_to_event_repository import save_event_to_event_repository
|
||||
from .save_stolen_credentials_to_repository import save_stolen_credentials_to_repository
|
||||
|
|
|
@ -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}")
|
Loading…
Reference in New Issue