From 6ff2bbf92e8ddfbd004cdc6d46730a18d6da5b7b Mon Sep 17 00:00:00 2001 From: Shreya Date: Fri, 21 Feb 2020 14:51:58 +0530 Subject: [PATCH] Discard all 'None' values in Monkey configuration lists Instead of checking individually for problems arising due to 'None' values and fixing them, all 'None' values in all lists in the configuration are discarded. --- monkey/infection_monkey/config.py | 2 ++ monkey/infection_monkey/network/network_scanner.py | 1 - monkey/infection_monkey/network/tcp_scanner.py | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/monkey/infection_monkey/config.py b/monkey/infection_monkey/config.py index 5c5b5a392..0612bf01e 100644 --- a/monkey/infection_monkey/config.py +++ b/monkey/infection_monkey/config.py @@ -27,6 +27,8 @@ class Configuration(object): if self._depth_from_commandline and key == "depth": continue if hasattr(self, key): + if type(value) == list: + value = list(filter(None, value)) setattr(self, key, value) else: unknown_items.append(key) diff --git a/monkey/infection_monkey/network/network_scanner.py b/monkey/infection_monkey/network/network_scanner.py index ec42e1e54..faa5e9a5f 100644 --- a/monkey/infection_monkey/network/network_scanner.py +++ b/monkey/infection_monkey/network/network_scanner.py @@ -34,7 +34,6 @@ class NetworkScanner(object): LOG.info("Found local IP addresses of the machine: %r", self._ip_addresses) # for fixed range, only scan once. self._ranges = [NetworkRange.get_range_obj(address_str=x) for x in WormConfiguration.subnet_scan_list] - self._ranges = list(filter(None, self._ranges)) if WormConfiguration.local_network_scan: self._ranges += get_interfaces_ranges() self._ranges += self._get_inaccessible_subnets_ips() diff --git a/monkey/infection_monkey/network/tcp_scanner.py b/monkey/infection_monkey/network/tcp_scanner.py index 5605d5654..69a659bf8 100644 --- a/monkey/infection_monkey/network/tcp_scanner.py +++ b/monkey/infection_monkey/network/tcp_scanner.py @@ -31,7 +31,6 @@ class TcpScanner(HostScanner, HostFinger): # maybe hide under really bad detection systems target_ports = self._config.tcp_target_ports[:] - target_ports = list(filter(None, target_ports)) # remove None values shuffle(target_ports) ports, banners = check_tcp_ports(host.ip_addr, target_ports, self._config.tcp_scan_timeout / 1000.0,