Agent: Rename should_propagate -> maximum_depth_reached

This commit is contained in:
Mike Salvatore 2022-06-23 16:36:01 -04:00
parent ad0f6946bd
commit 05f640d487
4 changed files with 12 additions and 12 deletions

View File

@ -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")

View File

@ -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

View File

@ -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

View File

@ -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