Agent: Fix identity logic in AggregatingCredentialsStore

This commit is contained in:
Mike Salvatore 2022-07-18 09:07:11 -04:00
parent 9edfe6979b
commit 7c920cced3
2 changed files with 10 additions and 3 deletions

View File

@ -26,9 +26,11 @@ class AggregatingCredentialsStore(ICredentialsStore):
def add_credentials(self, credentials_to_add: Iterable[Credentials]):
for credentials in credentials_to_add:
self._stored_credentials.setdefault("exploit_user_list", set()).add(
credentials.identity.username
)
identity = credentials.identity
if identity and identity.credential_type is CredentialComponentType.USERNAME:
self._stored_credentials.setdefault("exploit_user_list", set()).add(
identity.username
)
secret = credentials.secret

View File

@ -38,6 +38,10 @@ TEST_CREDENTIALS = [
identity=Username("user3"),
secret=SSHKeypair(public_key="some_public_key_1", private_key="some_private_key_1"),
),
Credentials(
identity=None,
secret=Password("super_secret"),
),
]
SSH_KEYS_CREDENTIALS = [
@ -93,6 +97,7 @@ def test_add_credentials_to_store(aggregating_credentials_store):
"abcdefg",
"password",
"root",
"super_secret",
]
)