From 20fff43fa986f25846f5e459c93bf76fbd60f50e Mon Sep 17 00:00:00 2001 From: Shreya Date: Thu, 20 Feb 2020 12:24:58 +0530 Subject: [PATCH] Remove `None` values from list of networks to scan Fixes #540 --- monkey/common/network/network_range.py | 2 +- monkey/infection_monkey/network/network_scanner.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/monkey/common/network/network_range.py b/monkey/common/network/network_range.py index 6a1201e07..15e04f893 100644 --- a/monkey/common/network/network_range.py +++ b/monkey/common/network/network_range.py @@ -44,9 +44,9 @@ class NetworkRange(object, metaclass=ABCMeta): @staticmethod def get_range_obj(address_str): - address_str = address_str.strip() if not address_str: # Empty string return None + address_str = address_str.strip() if NetworkRange.check_if_range(address_str): return IpRange(ip_range=address_str) if -1 != address_str.find('/'): diff --git a/monkey/infection_monkey/network/network_scanner.py b/monkey/infection_monkey/network/network_scanner.py index faa5e9a5f..ec42e1e54 100644 --- a/monkey/infection_monkey/network/network_scanner.py +++ b/monkey/infection_monkey/network/network_scanner.py @@ -34,6 +34,7 @@ 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()