Agent: Add a timeout parameter to scan_tcp_port()

This commit is contained in:
Mike Salvatore 2021-11-23 07:16:06 -05:00
parent 6e6c3f6133
commit a4a9de6a8d
2 changed files with 4 additions and 3 deletions

View File

@ -42,11 +42,12 @@ class IPuppet(metaclass=abc.ABCMeta):
"""
@abc.abstractmethod
def scan_tcp_port(self, host: str, port: int) -> PortScanData:
def scan_tcp_port(self, host: str, port: int, timeout: int) -> PortScanData:
"""
Scans a TCP port on a remote host
:param str host: The domain name or IP address of a host
:param int port: A TCP port number to scan
:param int timeout: The maximum amount of time (in seconds) to wait for a response
:return: The data collected by scanning the provided host:port combination
:rtype: PortScanData
"""

View File

@ -161,8 +161,8 @@ class MockPuppet(IPuppet):
return (False, None)
def scan_tcp_port(self, host: str, port: int) -> PortScanData:
logger.debug(f"run_scan_tcp_port({host}, {port})")
def scan_tcp_port(self, host: str, port: int, timeout: int = 3) -> PortScanData:
logger.debug(f"run_scan_tcp_port({host}, {port}, {timeout})")
dot_1_results = {
22: PortScanData(22, PortStatus.CLOSED, None, None),
445: PortScanData(445, PortStatus.OPEN, "SMB BANNER", "tcp-445"),