Merge pull request #2124 from guardicore/2004-icmp-scan-configuration-validation

ICMPScanConfiguration docstring
This commit is contained in:
VakarisZ 2022-07-27 14:25:39 +03:00 committed by GitHub
commit ffd1773e92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

View File

@ -85,7 +85,7 @@ class ScanTargetConfigurationSchema(Schema):
class ICMPScanConfigurationSchema(Schema):
timeout = fields.Float()
timeout = fields.Float(validate=validate.Range(min=0))
@post_load
def _make_icmp_scan_configuration(self, data, **kwargs):

View File

@ -41,6 +41,13 @@ class ScanTargetConfiguration:
@dataclass(frozen=True)
class ICMPScanConfiguration:
"""
A configuration for ICMP scanning
Attributes:
:param timeout: Maximum time in seconds to wait for a response from the target
"""
timeout: float

View File

@ -126,6 +126,16 @@ def test_icmp_scan_configuration_schema():
assert config.timeout == TIMEOUT
def test_icmp_scan_configuration_schema__negative_timeout():
schema = ICMPScanConfigurationSchema()
negative_timeout_configuration = ICMP_CONFIGURATION.copy()
negative_timeout_configuration["timeout"] = -1
with pytest.raises(ValidationError):
schema.load(negative_timeout_configuration)
def test_tcp_scan_configuration_schema():
schema = TCPScanConfigurationSchema()