forked from p34709852/monkey
Agent: Use distinct fields for SSH Keypair
This commit is contained in:
parent
5f8e3e3d8e
commit
897bc11d7b
|
@ -6,4 +6,5 @@ from infection_monkey.i_puppet import CredentialType, ICredentialComponent
|
|||
@dataclass(frozen=True)
|
||||
class SSHKeypair(ICredentialComponent):
|
||||
credential_type: CredentialType = field(default=CredentialType.SSH_KEYPAIR, init=False)
|
||||
content: dict
|
||||
private_key: str
|
||||
public_key: str
|
||||
|
|
|
@ -41,7 +41,11 @@ class SSHCredentialCollector(ICredentialCollector):
|
|||
ssh_keypair[key] = info[key]
|
||||
|
||||
if len(ssh_keypair):
|
||||
secrets.append(SSHKeypair(ssh_keypair))
|
||||
secrets.append(
|
||||
SSHKeypair(
|
||||
ssh_keypair.get("private_key", ""), ssh_keypair.get("public_key", "")
|
||||
)
|
||||
)
|
||||
|
||||
if identities != [] or secrets != []:
|
||||
ssh_credentials.append(Credentials(identities, secrets))
|
||||
|
|
|
@ -52,10 +52,8 @@ def test_ssh_info_result_parsing(monkeypatch, patch_telemetry_messenger):
|
|||
username2 = Username("mcus")
|
||||
username3 = Username("guest")
|
||||
|
||||
ssh_keypair1 = SSHKeypair(
|
||||
{"public_key": "SomePublicKeyUbuntu", "private_key": "ExtremelyGoodPrivateKey"}
|
||||
)
|
||||
ssh_keypair2 = SSHKeypair({"public_key": "AnotherPublicKey"})
|
||||
ssh_keypair1 = SSHKeypair("ExtremelyGoodPrivateKey", "SomePublicKeyUbuntu")
|
||||
ssh_keypair2 = SSHKeypair("", "AnotherPublicKey")
|
||||
|
||||
expected = [
|
||||
Credentials(identities=[username], secrets=[ssh_keypair1]),
|
||||
|
|
Loading…
Reference in New Issue