From a3ca21481ec7602e7ecd1786f60410e5881204dc Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Fri, 30 Sep 2022 11:27:07 +0530 Subject: [PATCH] Agent: Add missing/fix existing type hints in TCP scanner --- monkey/infection_monkey/network_scanning/tcp_scanner.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/monkey/infection_monkey/network_scanning/tcp_scanner.py b/monkey/infection_monkey/network_scanning/tcp_scanner.py index af1efb182..efff5ceaf 100644 --- a/monkey/infection_monkey/network_scanning/tcp_scanner.py +++ b/monkey/infection_monkey/network_scanning/tcp_scanner.py @@ -27,7 +27,9 @@ def scan_tcp_ports( return EMPTY_PORT_SCAN -def _scan_tcp_ports(host: str, ports_to_scan: Collection[int], timeout: float): +def _scan_tcp_ports( + host: str, ports_to_scan: Collection[int], timeout: float +) -> Dict[int, PortScanData]: open_ports = _check_tcp_ports(host, ports_to_scan, timeout) return _build_port_scan_data(ports_to_scan, open_ports) @@ -35,7 +37,7 @@ def _scan_tcp_ports(host: str, ports_to_scan: Collection[int], timeout: float): def _build_port_scan_data( ports_to_scan: Iterable[int], open_ports: Mapping[int, str] -) -> Mapping[int, PortScanData]: +) -> Dict[int, PortScanData]: port_scan_data = {} for port in ports_to_scan: if port in open_ports: @@ -55,7 +57,7 @@ def _get_closed_port_data(port: int) -> PortScanData: def _check_tcp_ports( ip: str, ports_to_scan: Collection[int], timeout: float = DEFAULT_TIMEOUT -) -> Mapping[int, str]: +) -> Dict[int, str]: """ Checks whether any of the given ports are open on a target IP. :param ip: IP of host to attack