Common: Switch configuration timeouts from ms to floating-point seconds

This commit is contained in:
Mike Salvatore 2022-06-17 09:14:22 -04:00
parent bd7ea7fdb1
commit 7039ccf708
2 changed files with 11 additions and 12 deletions

View File

@ -67,11 +67,11 @@ class ScanTargetConfigurationSchema(Schema):
@dataclass(frozen=True)
class ICMPScanConfiguration:
timeout_ms: int
timeout: float
class ICMPScanConfigurationSchema(Schema):
timeout_ms = fields.Int()
timeout = fields.Float()
@post_load
def _make_icmp_scan_configuration(self, data, **kwargs):
@ -80,12 +80,12 @@ class ICMPScanConfigurationSchema(Schema):
@dataclass(frozen=True)
class TCPScanConfiguration:
timeout_ms: int
timeout: float
ports: List[int]
class TCPScanConfigurationSchema(Schema):
timeout_ms = fields.Int()
timeout = fields.Float()
ports = fields.List(fields.Int())
@post_load

View File

@ -72,8 +72,8 @@ def test_scan_target_configuration():
assert config.subnets == SUBNETS
TIMEOUT_MS = 2525
ICMP_CONFIGURATION = {"timeout_ms": TIMEOUT_MS}
TIMEOUT = 2.525
ICMP_CONFIGURATION = {"timeout": TIMEOUT}
def test_icmp_scan_configuration_schema():
@ -81,13 +81,12 @@ def test_icmp_scan_configuration_schema():
config = schema.load(ICMP_CONFIGURATION)
assert config.timeout_ms == TIMEOUT_MS
assert config.timeout == TIMEOUT
TIMEOUT_MS = 2525
PORTS = [8080, 443]
TCP_SCAN_CONFIGURATION = {"timeout_ms": TIMEOUT_MS, "ports": PORTS}
TCP_SCAN_CONFIGURATION = {"timeout": TIMEOUT, "ports": PORTS}
def test_tcp_scan_configuration_schema():
@ -95,7 +94,7 @@ def test_tcp_scan_configuration_schema():
config = schema.load(TCP_SCAN_CONFIGURATION)
assert config.timeout_ms == TIMEOUT_MS
assert config.timeout == TIMEOUT
assert config.ports == PORTS
@ -114,8 +113,8 @@ def test_network_scan_configuration():
config = schema.load(NETWORK_SCAN_CONFIGURATION)
assert config.tcp.ports == TCP_SCAN_CONFIGURATION["ports"]
assert config.tcp.timeout_ms == TCP_SCAN_CONFIGURATION["timeout_ms"]
assert config.icmp.timeout_ms == ICMP_CONFIGURATION["timeout_ms"]
assert config.tcp.timeout == TCP_SCAN_CONFIGURATION["timeout"]
assert config.icmp.timeout == ICMP_CONFIGURATION["timeout"]
assert config.fingerprinters[0].name == FINGERPRINTERS[0]["name"]
assert config.fingerprinters[0].options == FINGERPRINTERS[0]["options"]
assert config.targets.blocked_ips == BLOCKED_IPS