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]): def add_credentials(self, credentials_to_add: Iterable[Credentials]):
for credentials in credentials_to_add: for credentials in credentials_to_add:
self._stored_credentials.setdefault("exploit_user_list", set()).add( identity = credentials.identity
credentials.identity.username if identity and identity.credential_type is CredentialComponentType.USERNAME:
) self._stored_credentials.setdefault("exploit_user_list", set()).add(
identity.username
)
secret = credentials.secret secret = credentials.secret

View File

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