Common: Add TCPScanConfigurationSchema

This commit is contained in:
Mike Salvatore 2022-06-17 08:14:35 -04:00
parent 2e561181ea
commit 0b810f5d56
4 changed files with 24 additions and 0 deletions

View File

@ -9,4 +9,6 @@ from .agent_configuration import (
ExploiterConfigurationSchema,
ExploitationConfiguration,
ExploitationConfigurationSchema,
TCPScanConfiguration,
TCPScanConfigurationSchema,
)

View File

@ -105,3 +105,12 @@ class ICMPScanConfiguration:
class TCPScanConfiguration:
timeout_ms: int
ports: List[int]
class TCPScanConfigurationSchema(Schema):
timeout_ms = fields.Int()
ports = fields.List(fields.Int())
@post_load
def make_tcp_scan_configuration(self, data, **kwargs):
return TCPScanConfiguration(**data)

View File

@ -6,6 +6,7 @@ from common.configuration import (
ExploitationOptionsConfigurationSchema,
ExploiterConfigurationSchema,
PluginConfigurationSchema,
TCPScanConfigurationSchema,
)
@ -95,3 +96,14 @@ def test_exploitation_configuration():
assert isinstance(config, ExploitationConfiguration)
assert config_dict == exploitation_config
def test_tcp_scan_configuration_schema():
timeout_ms = 2525
ports = [8080, 443]
schema = TCPScanConfigurationSchema()
config = schema.load({"timeout_ms": timeout_ms, "ports": ports})
assert config.timeout_ms == timeout_ms
assert config.ports == ports

View File

@ -190,6 +190,7 @@ make_plugin_configuration # unused method (monkey/common/configuration/agent_co
make_custom_pba_configuration # unused method (monkey/common/configuration/agent_configuration.py:34)
make_exploitation_options_configuration # unused method (monkey/common/configuration/agent_configuration.py:58)
make_exploiter_configuration # unused method (monkey/common/configuration/agent_configuration.py:62)
make_tcp_scan_configuration # unused method (monkey/common/configuration/agent_configuration.py:114)
LINUX # unused variable (monkey/common/operating_systems.py:5)
WINDOWS # unused variable (monkey/common/operating_systems.py:6)