diff --git a/monkey/infection_monkey/credential_collectors/mimikatz_collector/mimikatz_credential_collector.py b/monkey/infection_monkey/credential_collectors/mimikatz_collector/mimikatz_credential_collector.py index e1f94c4dd..1cbef911e 100644 --- a/monkey/infection_monkey/credential_collectors/mimikatz_collector/mimikatz_credential_collector.py +++ b/monkey/infection_monkey/credential_collectors/mimikatz_collector/mimikatz_credential_collector.py @@ -1,4 +1,4 @@ -from typing import Iterable +from typing import Sequence from infection_monkey.credential_collectors import LMHash, NTHash, Password, Username from infection_monkey.i_puppet.credential_collection import Credentials, ICredentialCollector @@ -8,12 +8,12 @@ from .windows_credentials import WindowsCredentials class MimikatzCredentialCollector(ICredentialCollector): - def collect_credentials(self, options=None) -> Iterable[Credentials]: + def collect_credentials(self, options=None) -> Sequence[Credentials]: creds = pypykatz_handler.get_windows_creds() return MimikatzCredentialCollector._to_credentials(creds) @staticmethod - def _to_credentials(win_creds: Iterable[WindowsCredentials]) -> [Credentials]: + def _to_credentials(win_creds: Sequence[WindowsCredentials]) -> [Credentials]: all_creds = [] for win_cred in win_creds: identities = [] diff --git a/monkey/infection_monkey/credential_collectors/ssh_collector/ssh_credential_collector.py b/monkey/infection_monkey/credential_collectors/ssh_collector/ssh_credential_collector.py index ce64221fb..69afd68f6 100644 --- a/monkey/infection_monkey/credential_collectors/ssh_collector/ssh_credential_collector.py +++ b/monkey/infection_monkey/credential_collectors/ssh_collector/ssh_credential_collector.py @@ -1,5 +1,5 @@ import logging -from typing import Dict, Iterable, List +from typing import Dict, Iterable, Sequence from infection_monkey.credential_collectors import SSHKeypair, Username from infection_monkey.credential_collectors.ssh_collector import ssh_handler @@ -17,7 +17,7 @@ class SSHCredentialCollector(ICredentialCollector): def __init__(self, telemetry_messenger: ITelemetryMessenger): self._telemetry_messenger = telemetry_messenger - def collect_credentials(self, _options=None) -> List[Credentials]: + def collect_credentials(self, _options=None) -> Sequence[Credentials]: logger.info("Started scanning for SSH credentials") ssh_info = ssh_handler.get_ssh_info(self._telemetry_messenger) logger.info("Finished scanning for SSH credentials") @@ -25,7 +25,7 @@ class SSHCredentialCollector(ICredentialCollector): return SSHCredentialCollector._to_credentials(ssh_info) @staticmethod - def _to_credentials(ssh_info: Iterable[Dict]) -> List[Credentials]: + def _to_credentials(ssh_info: Iterable[Dict]) -> Sequence[Credentials]: ssh_credentials = [] for info in ssh_info: diff --git a/monkey/infection_monkey/i_puppet/credential_collection/i_credential_collector.py b/monkey/infection_monkey/i_puppet/credential_collection/i_credential_collector.py index 847cd929d..0cbd2578b 100644 --- a/monkey/infection_monkey/i_puppet/credential_collection/i_credential_collector.py +++ b/monkey/infection_monkey/i_puppet/credential_collection/i_credential_collector.py @@ -1,10 +1,10 @@ from abc import ABC, abstractmethod -from typing import Iterable, Mapping, Optional +from typing import Mapping, Optional, Sequence from .credentials import Credentials class ICredentialCollector(ABC): @abstractmethod - def collect_credentials(self, options: Optional[Mapping]) -> Iterable[Credentials]: + def collect_credentials(self, options: Optional[Mapping]) -> Sequence[Credentials]: pass diff --git a/monkey/infection_monkey/puppet/puppet.py b/monkey/infection_monkey/puppet/puppet.py index 5150c9b6f..bea4695b3 100644 --- a/monkey/infection_monkey/puppet/puppet.py +++ b/monkey/infection_monkey/puppet/puppet.py @@ -32,7 +32,7 @@ class Puppet(IPuppet): credential_collector = self._plugin_registry.get_plugin( name, PluginType.CREDENTIAL_COLLECTOR ) - return list(credential_collector.collect_credentials(options)) + return credential_collector.collect_credentials(options) def run_pba(self, name: str, options: Dict) -> PostBreachData: return self._mock_puppet.run_pba(name, options) diff --git a/monkey/tests/unit_tests/infection_monkey/credential_collectors/test_mimikatz_collector.py b/monkey/tests/unit_tests/infection_monkey/credential_collectors/test_mimikatz_collector.py index b33d4e097..20eca62c7 100644 --- a/monkey/tests/unit_tests/infection_monkey/credential_collectors/test_mimikatz_collector.py +++ b/monkey/tests/unit_tests/infection_monkey/credential_collectors/test_mimikatz_collector.py @@ -1,4 +1,4 @@ -from typing import List +from typing import Sequence import pytest @@ -23,8 +23,8 @@ def patch_pypykatz(win_creds: [WindowsCredentials], monkeypatch): ) -def collect_credentials() -> List[Credentials]: - return list(MimikatzCredentialCollector().collect_credentials()) +def collect_credentials() -> Sequence[Credentials]: + return MimikatzCredentialCollector().collect_credentials() @pytest.mark.parametrize(