From 89f5ff89d29172b2b431126440188cd83c05254c Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Thu, 14 Jul 2022 17:23:12 +0200 Subject: [PATCH] Island: Remove extract_ssh_keys from stolen_credentials reporting --- .../services/reporting/stolen_credentials.py | 4 --- .../reporting/test_stolen_credentials.py | 27 +------------------ 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/monkey/monkey_island/cc/services/reporting/stolen_credentials.py b/monkey/monkey_island/cc/services/reporting/stolen_credentials.py index 2a817ac75..ebcc2190a 100644 --- a/monkey/monkey_island/cc/services/reporting/stolen_credentials.py +++ b/monkey/monkey_island/cc/services/reporting/stolen_credentials.py @@ -15,10 +15,6 @@ def get_stolen_creds() -> Sequence[Mapping]: return stolen_creds -def extract_ssh_keys(credentials: Sequence[Mapping]) -> Sequence[Mapping]: - return [c for c in credentials if c["_type"] == CredentialComponentType.SSH_KEYPAIR.name] - - def _fetch_from_db() -> Sequence[StolenCredentials]: return list(StolenCredentials.objects()) diff --git a/monkey/tests/unit_tests/monkey_island/cc/services/reporting/test_stolen_credentials.py b/monkey/tests/unit_tests/monkey_island/cc/services/reporting/test_stolen_credentials.py index d7c2386c9..201dda576 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/services/reporting/test_stolen_credentials.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/reporting/test_stolen_credentials.py @@ -2,10 +2,7 @@ import pytest from common.credentials import CredentialComponentType from monkey_island.cc.models import Monkey, StolenCredentials -from monkey_island.cc.services.reporting.stolen_credentials import ( - extract_ssh_keys, - get_stolen_creds, -) +from monkey_island.cc.services.reporting.stolen_credentials import get_stolen_creds monkey_hostname = "fake_hostname" fake_monkey_guid = "abc" @@ -73,25 +70,3 @@ def test_get_credentials(fake_monkey): assert result2 in credentials assert result3 in credentials assert result4 in credentials - - -@pytest.mark.usefixtures("uses_database") -def test_extract_ssh_keys(fake_monkey): - StolenCredentials( - identities=fake_credentials["identities"], - secrets=fake_credentials["secrets"], - monkey=fake_monkey, - ).save() - - credentials = get_stolen_creds() - keys = extract_ssh_keys(credentials) - - assert len(keys) == 1 - - result = { - "origin": monkey_hostname, - "_type": CredentialComponentType.SSH_KEYPAIR.name, - "type": "Clear SSH private key", - "username": fake_username, - } - assert result in keys