From c76cc72821ab180edd1f1ba5b6e52db4a224d388 Mon Sep 17 00:00:00 2001 From: Daniel Goldberg Date: Mon, 23 Sep 2019 17:45:17 +0300 Subject: [PATCH] Fixed horrible bug where we would return more victims than we needed to --- monkey/infection_monkey/network/network_scanner.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/monkey/infection_monkey/network/network_scanner.py b/monkey/infection_monkey/network/network_scanner.py index be424692c..eb7c29572 100644 --- a/monkey/infection_monkey/network/network_scanner.py +++ b/monkey/infection_monkey/network/network_scanner.py @@ -112,7 +112,7 @@ class NetworkScanner(object): # check before running scans if stop_callback and stop_callback(): LOG.debug("Got stop signal") - break + return results = pool.map(self.scan_machine, victim_chunk) resulting_victims = [x for x in results if x] # filter out dead addresses @@ -123,8 +123,7 @@ class NetworkScanner(object): if victims_count >= max_find: LOG.debug("Found max needed victims (%d), stopping scan", max_find) - - break + return if WormConfiguration.tcp_scan_interval: # time.sleep uses seconds, while config is in milliseconds time.sleep(WormConfiguration.tcp_scan_interval / float(1000))