From 223474d983ac7d3fc834f9463a48027d014a4937 Mon Sep 17 00:00:00 2001 From: vakarisz Date: Mon, 8 Aug 2022 17:20:27 +0300 Subject: [PATCH] Island: Document IPropagationRepository and child classes --- ...ting_propagation_credentials_repository.py | 22 +++++-------------- .../i_propagation_credentials_repository.py | 4 ++++ 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/monkey/infection_monkey/credential_repository/aggregating_propagation_credentials_repository.py b/monkey/infection_monkey/credential_repository/aggregating_propagation_credentials_repository.py index f347b901c..3050e5f85 100644 --- a/monkey/infection_monkey/credential_repository/aggregating_propagation_credentials_repository.py +++ b/monkey/infection_monkey/credential_repository/aggregating_propagation_credentials_repository.py @@ -14,6 +14,11 @@ CREDENTIALS_POLL_PERIOD_SEC = 10 class AggregatingPropagationCredentialsRepository(IPropagationCredentialsRepository): + """ + Repository that stores credentials on the island and saves/gets credentials by using + command and control channel + """ + def __init__(self, control_channel: IControlChannel): self._stored_credentials = { "exploit_user_list": set(), @@ -33,18 +38,10 @@ class AggregatingPropagationCredentialsRepository(IPropagationCredentialsReposit self._add_secret(credentials.secret) def _add_identity(self, identity: ICredentialComponent): - """ - Stores identity component to the repository - :param identity: Identity credential component - """ if identity.credential_type is CredentialComponentType.USERNAME: self._stored_credentials.setdefault("exploit_user_list", set()).add(identity.username) def _add_secret(self, secret: ICredentialComponent): - """ - Stores secret component to the repository - :param secret: Secret credential component - """ if secret.credential_type is CredentialComponentType.PASSWORD: self._stored_credentials.setdefault("exploit_password_list", set()).add(secret.password) elif secret.credential_type is CredentialComponentType.LM_HASH: @@ -69,18 +66,9 @@ class AggregatingPropagationCredentialsRepository(IPropagationCredentialsReposit @request_cache(CREDENTIALS_POLL_PERIOD_SEC) def _get_credentials_from_control_channel(self) -> Sequence[Credentials]: - """ - Fetches credentials from control channel - :return: Credentials that can be used for propagation - """ return self._control_channel.get_credentials_for_propagation() def _set_attribute(self, attribute_to_be_set: str, credentials_values: Iterable[Any]): - """ - Sets a value for a credential type - :param attribute_to_be_set: Key of self._stored_credentials (credential container key) - :param credentials_values: Value we want to set the container to - """ if not credentials_values: return diff --git a/monkey/infection_monkey/credential_repository/i_propagation_credentials_repository.py b/monkey/infection_monkey/credential_repository/i_propagation_credentials_repository.py index 7e5d20dab..eb5fb1cba 100644 --- a/monkey/infection_monkey/credential_repository/i_propagation_credentials_repository.py +++ b/monkey/infection_monkey/credential_repository/i_propagation_credentials_repository.py @@ -6,6 +6,10 @@ from infection_monkey.custom_types import PropagationCredentials class IPropagationCredentialsRepository(metaclass=abc.ABCMeta): + """ + Repository that stores and provides credentials for the Agent to use in propagation + """ + @abc.abstractmethod def add_credentials(self, credentials_to_add: Iterable[Credentials]): """