Agent: Improve documentation of credential repository

This commit is contained in:
vakarisz 2022-08-08 16:09:59 +03:00
parent 4f6500ad83
commit 022daf762b
2 changed files with 18 additions and 1 deletions

View File

@ -33,10 +33,18 @@ class AggregatingPropagationCredentialsRepository(IPropagationCredentialsReposit
self._add_secret(credentials.secret) self._add_secret(credentials.secret)
def _add_identity(self, identity: ICredentialComponent): def _add_identity(self, identity: ICredentialComponent):
"""
Stores identity component to the repository
:param identity: Identity credential component
"""
if identity.credential_type is CredentialComponentType.USERNAME: if identity.credential_type is CredentialComponentType.USERNAME:
self._stored_credentials.setdefault("exploit_user_list", set()).add(identity.username) self._stored_credentials.setdefault("exploit_user_list", set()).add(identity.username)
def _add_secret(self, secret: ICredentialComponent): def _add_secret(self, secret: ICredentialComponent):
"""
Stores secret component to the repository
:param secret: Secret credential component
"""
if secret.credential_type is CredentialComponentType.PASSWORD: if secret.credential_type is CredentialComponentType.PASSWORD:
self._stored_credentials.setdefault("exploit_password_list", set()).add(secret.password) self._stored_credentials.setdefault("exploit_password_list", set()).add(secret.password)
elif secret.credential_type is CredentialComponentType.LM_HASH: elif secret.credential_type is CredentialComponentType.LM_HASH:
@ -61,9 +69,18 @@ class AggregatingPropagationCredentialsRepository(IPropagationCredentialsReposit
@request_cache(CREDENTIALS_POLL_PERIOD_SEC) @request_cache(CREDENTIALS_POLL_PERIOD_SEC)
def _get_credentials_from_control_channel(self) -> Sequence[Credentials]: 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() return self._control_channel.get_credentials_for_propagation()
def _set_attribute(self, attribute_to_be_set: str, credentials_values: Iterable[Any]): 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: if not credentials_values:
return return

View File

@ -10,7 +10,7 @@ class IPropagationCredentialsRepository(metaclass=abc.ABCMeta):
def add_credentials(self, credentials_to_add: Iterable[Credentials]): def add_credentials(self, credentials_to_add: Iterable[Credentials]):
""" """
Adds credentials to the CredentialStore Adds credentials to the CredentialStore
:param Iterable[Credentials] credentials: The credentials that will be added :param Iterable[Credentials] credentials_to_add: The credentials that will be added
""" """
@abc.abstractmethod @abc.abstractmethod