From f6e5462ad31f2d77623bdb6ef8ef0984555f9d17 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Fri, 30 Sep 2022 12:06:09 -0400 Subject: [PATCH] Island: Use sum() to count open ports --- .../cc/agent_event_handlers/scan_event_handler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monkey/monkey_island/cc/agent_event_handlers/scan_event_handler.py b/monkey/monkey_island/cc/agent_event_handlers/scan_event_handler.py index 6e3582832..673074591 100644 --- a/monkey/monkey_island/cc/agent_event_handlers/scan_event_handler.py +++ b/monkey/monkey_island/cc/agent_event_handlers/scan_event_handler.py @@ -49,9 +49,9 @@ class ScanEventHandler: logger.exception("Unable to process ping scan data") def handle_tcp_scan_event(self, event: TCPScanEvent): - open_ports = [port for port, status in event.ports.items() if status == PortStatus.OPEN] + num_open_ports = sum((1 for status in event.ports.values() if status == PortStatus.OPEN)) - if not open_ports: + if num_open_ports <= 0: return try: