From c807f97d1810a7733884f978851fe20ca358718e Mon Sep 17 00:00:00 2001 From: vakarisz Date: Wed, 28 Sep 2022 12:17:31 +0300 Subject: [PATCH] Island: Rename handle_scan_data to handle_ping_scan_event --- .../cc/agent_event_handlers/__init__.py | 2 +- ...le_scan_data.py => handle_ping_scan_event.py} | 2 +- .../cc/setup/agent_event_handlers.py | 4 ++-- .../test_handle_scan_data.py | 16 ++++++++-------- 4 files changed, 12 insertions(+), 12 deletions(-) rename monkey/monkey_island/cc/agent_event_handlers/{handle_scan_data.py => handle_ping_scan_event.py} (98%) diff --git a/monkey/monkey_island/cc/agent_event_handlers/__init__.py b/monkey/monkey_island/cc/agent_event_handlers/__init__.py index ed47c29af..1c7e4714c 100644 --- a/monkey/monkey_island/cc/agent_event_handlers/__init__.py +++ b/monkey/monkey_island/cc/agent_event_handlers/__init__.py @@ -1,3 +1,3 @@ -from .handle_scan_data import handle_scan_data +from .handle_ping_scan_event import handle_ping_scan_event from .save_event_to_event_repository import save_event_to_event_repository from .save_stolen_credentials_to_repository import save_stolen_credentials_to_repository diff --git a/monkey/monkey_island/cc/agent_event_handlers/handle_scan_data.py b/monkey/monkey_island/cc/agent_event_handlers/handle_ping_scan_event.py similarity index 98% rename from monkey/monkey_island/cc/agent_event_handlers/handle_scan_data.py rename to monkey/monkey_island/cc/agent_event_handlers/handle_ping_scan_event.py index b3a44085b..d7d46a2f3 100644 --- a/monkey/monkey_island/cc/agent_event_handlers/handle_scan_data.py +++ b/monkey/monkey_island/cc/agent_event_handlers/handle_ping_scan_event.py @@ -15,7 +15,7 @@ from monkey_island.cc.repository import ( logger = getLogger(__name__) -class handle_scan_data: +class handle_ping_scan_event: def __init__( self, agent_repository: IAgentRepository, diff --git a/monkey/monkey_island/cc/setup/agent_event_handlers.py b/monkey/monkey_island/cc/setup/agent_event_handlers.py index 4d61a5610..44861d766 100644 --- a/monkey/monkey_island/cc/setup/agent_event_handlers.py +++ b/monkey/monkey_island/cc/setup/agent_event_handlers.py @@ -2,7 +2,7 @@ from common import DIContainer from common.agent_events import CredentialsStolenEvent, PingScanEvent from common.event_queue import IAgentEventQueue from monkey_island.cc.agent_event_handlers import ( - handle_scan_data, + handle_ping_scan_event, save_event_to_event_repository, save_stolen_credentials_to_repository, ) @@ -39,6 +39,6 @@ def _subscribe_ping_scan_event(container: DIContainer): machine_repository = container.resolve(IMachineRepository) # type: ignore node_repository = container.resolve(INodeRepository) # type: ignore - handler = handle_scan_data(agent_repository, machine_repository, node_repository) + handler = handle_ping_scan_event(agent_repository, machine_repository, node_repository) agent_event_queue.subscribe_type(PingScanEvent, handler) diff --git a/monkey/tests/unit_tests/monkey_island/cc/agent_event_handlers/test_handle_scan_data.py b/monkey/tests/unit_tests/monkey_island/cc/agent_event_handlers/test_handle_scan_data.py index 60b65f8a2..5b4040f57 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/agent_event_handlers/test_handle_scan_data.py +++ b/monkey/tests/unit_tests/monkey_island/cc/agent_event_handlers/test_handle_scan_data.py @@ -8,7 +8,7 @@ import pytest from common import OperatingSystem from common.agent_events import PingScanEvent from common.types import PingScanData, SocketAddress -from monkey_island.cc.agent_event_handlers import handle_scan_data +from monkey_island.cc.agent_event_handlers import handle_ping_scan_event from monkey_island.cc.models import Agent, CommunicationType, Machine from monkey_island.cc.repository import ( IAgentRepository, @@ -65,8 +65,8 @@ def node_repository() -> INodeRepository: @pytest.fixture -def handler(agent_repository, machine_repository, node_repository) -> handle_scan_data: - return handle_scan_data(agent_repository, machine_repository, node_repository) +def handler(agent_repository, machine_repository, node_repository) -> handle_ping_scan_event: + return handle_ping_scan_event(agent_repository, machine_repository, node_repository) machines = {MACHINE_ID: MACHINE, STORED_MACHINE.id: STORED_MACHINE} @@ -77,7 +77,7 @@ def machine_from_id(id: int): def test_handle_scan_data__upserts_machine( - handler: handle_scan_data, + handler: handle_ping_scan_event, machine_repository: IMachineRepository, ): machine_repository.get_machine_by_id = MagicMock(side_effect=machine_from_id) @@ -90,7 +90,7 @@ def test_handle_scan_data__upserts_machine( def test_handle_scan_data__upserts_node( - handler: handle_scan_data, + handler: handle_ping_scan_event, machine_repository: IMachineRepository, node_repository: INodeRepository, ): @@ -103,7 +103,7 @@ def test_handle_scan_data__upserts_node( def test_handle_scan_data__node_not_upserted_if_no_matching_agent( - handler: handle_scan_data, + handler: handle_ping_scan_event, agent_repository: IAgentRepository, machine_repository: IMachineRepository, node_repository: INodeRepository, @@ -117,7 +117,7 @@ def test_handle_scan_data__node_not_upserted_if_no_matching_agent( def test_handle_scan_data__node_not_upserted_if_no_matching_machine( - handler: handle_scan_data, + handler: handle_ping_scan_event, machine_repository: IMachineRepository, node_repository: INodeRepository, ): @@ -129,7 +129,7 @@ def test_handle_scan_data__node_not_upserted_if_no_matching_machine( def test_handle_scan_data__upserts_machine_if_not_existed( - handler: handle_scan_data, machine_repository: IMachineRepository + handler: handle_ping_scan_event, machine_repository: IMachineRepository ): machine_repository.get_machine_by_id = MagicMock(side_effect=machine_from_id) handler(EVENT)