diff --git a/monkey/infection_monkey/network_scanning/tcp_scanner.py b/monkey/infection_monkey/network_scanning/tcp_scanner.py index e19b2e0eb..9b6d581e2 100644 --- a/monkey/infection_monkey/network_scanning/tcp_scanner.py +++ b/monkey/infection_monkey/network_scanning/tcp_scanner.py @@ -46,9 +46,7 @@ def _scan_tcp_ports( def _generate_tcp_scan_event( host: str, port_scan_data: Dict[int, PortScanData], event_timestamp: float ): - port_statuses = {} - for port, data in port_scan_data.items(): - port_statuses[port] = data.status + port_statuses = {port: psd.status for port, psd in port_scan_data.items()} return TCPScanEvent( source=get_agent_id(), diff --git a/monkey/tests/unit_tests/infection_monkey/network_scanning/test_tcp_scanner.py b/monkey/tests/unit_tests/infection_monkey/network_scanning/test_tcp_scanner.py index f3c897f11..2fd67590d 100644 --- a/monkey/tests/unit_tests/infection_monkey/network_scanning/test_tcp_scanner.py +++ b/monkey/tests/unit_tests/infection_monkey/network_scanning/test_tcp_scanner.py @@ -35,9 +35,7 @@ def patch_check_tcp_ports(monkeypatch, open_ports_data): def _get_tcp_scan_event(port_scan_data: PortScanData): - port_statuses = {} - for port, data in port_scan_data.items(): - port_statuses[port] = data.status + port_statuses = {port: psd.status for port, psd in port_scan_data.items()} return TCPScanEvent( source=get_agent_id(),