From 05f640d48777f4fbab3f9a59b105c68154e3a318 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 23 Jun 2022 16:36:01 -0400 Subject: [PATCH] Agent: Rename should_propagate -> maximum_depth_reached --- monkey/infection_monkey/master/automated_master.py | 4 ++-- monkey/infection_monkey/monkey.py | 4 ++-- monkey/infection_monkey/utils/propagation.py | 2 +- .../infection_monkey/utils/test_propagation.py | 14 +++++++------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/monkey/infection_monkey/master/automated_master.py b/monkey/infection_monkey/master/automated_master.py index ced26e58d..de55ef904 100644 --- a/monkey/infection_monkey/master/automated_master.py +++ b/monkey/infection_monkey/master/automated_master.py @@ -14,7 +14,7 @@ from infection_monkey.network import NetworkInterface from infection_monkey.telemetry.credentials_telem import CredentialsTelem from infection_monkey.telemetry.messengers.i_telemetry_messenger import ITelemetryMessenger from infection_monkey.telemetry.post_breach_telem import PostBreachTelem -from infection_monkey.utils.propagation import should_propagate +from infection_monkey.utils.propagation import maximum_depth_reached from infection_monkey.utils.threading import create_daemon_thread, interruptible_iter from . import Exploiter, IPScanner, Propagator @@ -174,7 +174,7 @@ class AutomatedMaster(IMaster): current_depth = self._current_depth if self._current_depth is not None else 0 logger.info(f"Current depth is {current_depth}") - if should_propagate(config.propagation.maximum_depth, self._current_depth): + if maximum_depth_reached(config.propagation.maximum_depth, self._current_depth): self._propagator.propagate(config.propagation, current_depth, self._stop) else: logger.info("Skipping propagation: maximum depth reached") diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index 23a5a3ace..749803c7b 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -78,7 +78,7 @@ from infection_monkey.utils.monkey_dir import ( remove_monkey_dir, ) from infection_monkey.utils.monkey_log_path import get_agent_log_path -from infection_monkey.utils.propagation import should_propagate +from infection_monkey.utils.propagation import maximum_depth_reached from infection_monkey.utils.signal_handler import register_signal_handlers, reset_signal_handlers logger = logging.getLogger(__name__) @@ -175,7 +175,7 @@ class InfectionMonkey: self._monkey_inbound_tunnel = self._control_client.create_control_tunnel( config.keep_tunnel_open_time ) - if self._monkey_inbound_tunnel and should_propagate( + if self._monkey_inbound_tunnel and maximum_depth_reached( config.propagation.maximum_depth, self._current_depth ): self._inbound_tunnel_opened = True diff --git a/monkey/infection_monkey/utils/propagation.py b/monkey/infection_monkey/utils/propagation.py index 5036b5745..2da2e7bee 100644 --- a/monkey/infection_monkey/utils/propagation.py +++ b/monkey/infection_monkey/utils/propagation.py @@ -1,2 +1,2 @@ -def should_propagate(maximum_depth: int, current_depth: int) -> bool: +def maximum_depth_reached(maximum_depth: int, current_depth: int) -> bool: return maximum_depth > current_depth diff --git a/monkey/tests/unit_tests/infection_monkey/utils/test_propagation.py b/monkey/tests/unit_tests/infection_monkey/utils/test_propagation.py index a4531f92d..19b2c18b5 100644 --- a/monkey/tests/unit_tests/infection_monkey/utils/test_propagation.py +++ b/monkey/tests/unit_tests/infection_monkey/utils/test_propagation.py @@ -1,22 +1,22 @@ -from infection_monkey.utils.propagation import should_propagate +from infection_monkey.utils.propagation import maximum_depth_reached -def test_should_propagate_current_less_than_max(): +def test_maximum_depth_reached__current_less_than_max(): maximum_depth = 2 current_depth = 1 - assert should_propagate(maximum_depth, current_depth) is True + assert maximum_depth_reached(maximum_depth, current_depth) is True -def test_should_propagate_current_greater_than_max(): +def test_maximum_depth_reached__current_greater_than_max(): maximum_depth = 2 current_depth = 3 - assert should_propagate(maximum_depth, current_depth) is False + assert maximum_depth_reached(maximum_depth, current_depth) is False -def test_should_propagate_current_equal_to_max(): +def test_maximum_depth_reached__current_equal_to_max(): maximum_depth = 2 current_depth = maximum_depth - assert should_propagate(maximum_depth, current_depth) is False + assert maximum_depth_reached(maximum_depth, current_depth) is False