Agent: Use filter() to improve loop in _process_tcp_scan_results()

This commit is contained in:
Mike Salvatore 2022-01-23 19:30:52 -05:00
parent ea0ab309d2
commit fa59f45d31
1 changed files with 7 additions and 8 deletions

View File

@ -107,9 +107,8 @@ class Propagator:
victim_host.os["type"] = ping_scan_data.os
@staticmethod
def _process_tcp_scan_results(victim_host: VictimHost, port_scan_data: PortScanData) -> bool:
for psd in port_scan_data.values():
if psd.status == PortStatus.OPEN:
def _process_tcp_scan_results(victim_host: VictimHost, port_scan_data: PortScanData):
for psd in filter(lambda psd: psd.status == PortStatus.OPEN, port_scan_data.values()):
victim_host.services[psd.service] = {}
victim_host.services[psd.service]["display_name"] = "unknown(TCP)"
victim_host.services[psd.service]["port"] = psd.port