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.
This commit is contained in:
Shreya 2020-02-21 14:51:58 +05:30
parent 16b2b87adc
commit 6ff2bbf92e
3 changed files with 2 additions and 2 deletions

View File

@ -27,6 +27,8 @@ class Configuration(object):
if self._depth_from_commandline and key == "depth": if self._depth_from_commandline and key == "depth":
continue continue
if hasattr(self, key): if hasattr(self, key):
if type(value) == list:
value = list(filter(None, value))
setattr(self, key, value) setattr(self, key, value)
else: else:
unknown_items.append(key) unknown_items.append(key)

View File

@ -34,7 +34,6 @@ class NetworkScanner(object):
LOG.info("Found local IP addresses of the machine: %r", self._ip_addresses) LOG.info("Found local IP addresses of the machine: %r", self._ip_addresses)
# for fixed range, only scan once. # for fixed range, only scan once.
self._ranges = [NetworkRange.get_range_obj(address_str=x) for x in WormConfiguration.subnet_scan_list] 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: if WormConfiguration.local_network_scan:
self._ranges += get_interfaces_ranges() self._ranges += get_interfaces_ranges()
self._ranges += self._get_inaccessible_subnets_ips() self._ranges += self._get_inaccessible_subnets_ips()

View File

@ -31,7 +31,6 @@ class TcpScanner(HostScanner, HostFinger):
# maybe hide under really bad detection systems # maybe hide under really bad detection systems
target_ports = self._config.tcp_target_ports[:] target_ports = self._config.tcp_target_ports[:]
target_ports = list(filter(None, target_ports)) # remove None values
shuffle(target_ports) shuffle(target_ports)
ports, banners = check_tcp_ports(host.ip_addr, target_ports, self._config.tcp_scan_timeout / 1000.0, ports, banners = check_tcp_ports(host.ip_addr, target_ports, self._config.tcp_scan_timeout / 1000.0,