From 21c9ea9d440d59f2a1635ea70e1e1623c25f6208 Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Fri, 12 Aug 2022 10:11:37 +0200 Subject: [PATCH 1/2] Agent: Initialize IEventQueue --- monkey/infection_monkey/monkey.py | 6 ++++++ vulture_allowlist.py | 1 + 2 files changed, 7 insertions(+) diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index 1640c1fa1..3feaebf9f 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -6,7 +6,10 @@ import sys from pathlib import Path, WindowsPath from typing import List +from pubsub.core import Publisher + import infection_monkey.tunnel as tunnel +from common.event_queue import PyPubSubEventQueue from common.network.network_utils import address_to_ip_port from common.utils.argparse_types import positive_int from common.utils.attack_utils import ScanStatus, UsageEnum @@ -103,6 +106,7 @@ class InfectionMonkey: self._current_depth = self._opts.depth self._master = None self._inbound_tunnel_opened = False + self._event_queue = None @staticmethod def _get_arguments(args): @@ -194,6 +198,8 @@ class InfectionMonkey: def _build_master(self): local_network_interfaces = InfectionMonkey._get_local_network_interfaces() + self._event_queue = PyPubSubEventQueue(Publisher()) + # TODO control_channel and control_client have same responsibilities, merge them control_channel = ControlChannel( self._control_client.server_address, GUID, self._control_client.proxies diff --git a/vulture_allowlist.py b/vulture_allowlist.py index 29359dfe9..7bd2185f2 100644 --- a/vulture_allowlist.py +++ b/vulture_allowlist.py @@ -213,6 +213,7 @@ _make_simulation # unused method (monkey/monkey_island/cc/models/simulation.py: # TODO DELETE AFTER EVENT QUEUE IMPLEMENTATION AbstractEvent tags +_event_queue # TODO DELETE AFTER RESOURCE REFACTORING From 23b96c2a36a940ed6fcaccc71e521f7fe09ac0cc Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Fri, 12 Aug 2022 10:13:36 -0400 Subject: [PATCH 2/2] Agent: Convert _event_queue from member to local variable --- monkey/infection_monkey/monkey.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index 3feaebf9f..665f97222 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -106,7 +106,6 @@ class InfectionMonkey: self._current_depth = self._opts.depth self._master = None self._inbound_tunnel_opened = False - self._event_queue = None @staticmethod def _get_arguments(args): @@ -198,7 +197,7 @@ class InfectionMonkey: def _build_master(self): local_network_interfaces = InfectionMonkey._get_local_network_interfaces() - self._event_queue = PyPubSubEventQueue(Publisher()) + _event_queue = PyPubSubEventQueue(Publisher()) # TODO control_channel and control_client have same responsibilities, merge them control_channel = ControlChannel(