Agent: Simplify credentials object in aggregating credentials store
This commit is contained in:
parent
f421f42604
commit
0f2fc0902f
|
@ -26,14 +26,12 @@ 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:
|
||||||
usernames = {
|
self._stored_credentials.setdefault("exploit_user_list", set()).add(
|
||||||
identity.username
|
credentials.identity.username
|
||||||
for identity in credentials.identities
|
)
|
||||||
if identity.credential_type is CredentialComponentType.USERNAME
|
|
||||||
}
|
secret = credentials.secret
|
||||||
self._stored_credentials.setdefault("exploit_user_list", set()).update(usernames)
|
|
||||||
|
|
||||||
for secret in credentials.secrets:
|
|
||||||
if secret.credential_type is CredentialComponentType.PASSWORD:
|
if secret.credential_type is CredentialComponentType.PASSWORD:
|
||||||
self._stored_credentials.setdefault("exploit_password_list", set()).add(
|
self._stored_credentials.setdefault("exploit_password_list", set()).add(
|
||||||
secret.password
|
secret.password
|
||||||
|
|
|
@ -30,21 +30,20 @@ EMPTY_CHANNEL_CREDENTIALS = {
|
||||||
|
|
||||||
TEST_CREDENTIALS = [
|
TEST_CREDENTIALS = [
|
||||||
Credentials(
|
Credentials(
|
||||||
[Username("user1"), Username("user3")],
|
identity=Username("user1"),
|
||||||
[
|
secret=Password("root"),
|
||||||
Password("abcdefg"),
|
),
|
||||||
Password("root"),
|
Credentials(identity=Username("user1"), secret=Password("abcdefg")),
|
||||||
SSHKeypair(public_key="some_public_key_1", private_key="some_private_key_1"),
|
Credentials(
|
||||||
],
|
identity=Username("user3"),
|
||||||
)
|
secret=SSHKeypair(public_key="some_public_key_1", private_key="some_private_key_1"),
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
SSH_KEYS_CREDENTIALS = [
|
SSH_KEYS_CREDENTIALS = [
|
||||||
Credentials(
|
Credentials(
|
||||||
[Username("root")],
|
Username("root"),
|
||||||
[
|
|
||||||
SSHKeypair(public_key="some_public_key", private_key="some_private_key"),
|
SSHKeypair(public_key="some_public_key", private_key="some_private_key"),
|
||||||
],
|
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue