From abec851ed0b9c945f5924077d63d809afcc3c7db Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Fri, 10 Dec 2021 11:45:20 -0500 Subject: [PATCH] Agent: Make minor code cleanliness changes --- monkey/infection_monkey/master/ip_scanner.py | 7 ++++--- .../infection_monkey/master/test_network_scanner.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/monkey/infection_monkey/master/ip_scanner.py b/monkey/infection_monkey/master/ip_scanner.py index 8073abad3..3e469ee9c 100644 --- a/monkey/infection_monkey/master/ip_scanner.py +++ b/monkey/infection_monkey/master/ip_scanner.py @@ -49,13 +49,14 @@ class IPScanner: results_callback(ip, ping_scan_data, port_scan_data) + logger.debug( + f"Detected the stop signal, scanning thread {threading.get_ident()} exiting" + ) + except queue.Empty: logger.debug( f"ips_to_scan queue is empty, scanning thread {threading.get_ident()} exiting" ) - return - - logger.debug(f"Detected the stop signal, scanning thread {threading.get_ident()} exiting") def _scan_tcp_ports(self, ip: str, options: Dict, stop: Event): port_scan_data = {} diff --git a/monkey/tests/unit_tests/infection_monkey/master/test_network_scanner.py b/monkey/tests/unit_tests/infection_monkey/master/test_network_scanner.py index 078a47593..1ace7f67f 100644 --- a/monkey/tests/unit_tests/infection_monkey/master/test_network_scanner.py +++ b/monkey/tests/unit_tests/infection_monkey/master/test_network_scanner.py @@ -145,7 +145,7 @@ def test_scan_lots_of_ips(callback, scan_config, stop): def test_stop_after_callback(scan_config, stop): - def _callback(_, __, ___): + def _callback(*_): # Block all threads here until 2 threads reach this barrier, then set stop # and test that niether thread continues to scan. _callback.barrier.wait() @@ -164,7 +164,7 @@ def test_stop_after_callback(scan_config, stop): def test_interrupt_port_scanning(callback, scan_config, stop): - def stopable_scan_tcp_port(port, _, __): + def stopable_scan_tcp_port(port, *_): # Block all threads here until 2 threads reach this barrier, then set stop # and test that niether thread scans any more ports stopable_scan_tcp_port.barrier.wait()