Agent: Improve performance of _remove_ips_from_scan_targets()

This commit is contained in:
Mike Salvatore 2021-12-16 08:29:45 -05:00
parent ec9aaf6b38
commit 7c786b0883
1 changed files with 2 additions and 7 deletions

View File

@ -99,13 +99,8 @@ def _remove_blocklisted_ips(
def _remove_ips_from_scan_targets( def _remove_ips_from_scan_targets(
scan_targets: List[NetworkAddress], ips_to_remove: List[str] scan_targets: List[NetworkAddress], ips_to_remove: List[str]
) -> List[NetworkAddress]: ) -> List[NetworkAddress]:
for ip in ips_to_remove: ips_to_remove_set = set(ips_to_remove)
try: return [address for address in scan_targets if address.ip not in ips_to_remove_set]
scan_targets = [address for address in scan_targets if address.ip != ip]
except KeyError:
# We don't need to remove the ip if it's already missing from the scan_targets
pass
return scan_targets
def _get_segmentation_check_targets( def _get_segmentation_check_targets(