forked from p15670423/monkey
Common: Add ScanTargetConfigurationSchema
This commit is contained in:
parent
7e9c481992
commit
3c879f444d
|
@ -13,4 +13,6 @@ from .agent_configuration import (
|
||||||
ICMPScanConfigurationSchema,
|
ICMPScanConfigurationSchema,
|
||||||
TCPScanConfiguration,
|
TCPScanConfiguration,
|
||||||
TCPScanConfigurationSchema,
|
TCPScanConfigurationSchema,
|
||||||
|
ScanTargetConfiguration,
|
||||||
|
ScanTargetConfigurationSchema,
|
||||||
)
|
)
|
||||||
|
|
|
@ -96,6 +96,17 @@ class ScanTargetConfiguration:
|
||||||
subnets: List[str]
|
subnets: List[str]
|
||||||
|
|
||||||
|
|
||||||
|
class ScanTargetConfigurationSchema(Schema):
|
||||||
|
blocked_ips = fields.List(fields.Str())
|
||||||
|
inaccessible_subnets = fields.List(fields.Str())
|
||||||
|
local_network_scan = fields.Bool()
|
||||||
|
subnets = fields.List(fields.Str())
|
||||||
|
|
||||||
|
@post_load
|
||||||
|
def _make_scan_target_configuration(self, data, **kwargs):
|
||||||
|
return ScanTargetConfiguration(**data)
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class ICMPScanConfiguration:
|
class ICMPScanConfiguration:
|
||||||
timeout_ms: int
|
timeout_ms: int
|
||||||
|
|
|
@ -7,6 +7,7 @@ from common.configuration import (
|
||||||
ExploiterConfigurationSchema,
|
ExploiterConfigurationSchema,
|
||||||
ICMPScanConfigurationSchema,
|
ICMPScanConfigurationSchema,
|
||||||
PluginConfigurationSchema,
|
PluginConfigurationSchema,
|
||||||
|
ScanTargetConfigurationSchema,
|
||||||
TCPScanConfigurationSchema,
|
TCPScanConfigurationSchema,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -99,6 +100,27 @@ def test_exploitation_configuration():
|
||||||
assert config_dict == exploitation_config
|
assert config_dict == exploitation_config
|
||||||
|
|
||||||
|
|
||||||
|
def test_scan_target_configuration():
|
||||||
|
blocked_ips = ["10.0.0.1", "192.168.1.1"]
|
||||||
|
inaccessible_subnets = ["172.0.0.0/24", "172.2.2.0/24", "192.168.56.0/24"]
|
||||||
|
local_network_scan = True
|
||||||
|
subnets = ["10.0.0.2", "10.0.0.2/16"]
|
||||||
|
scan_target_config = {
|
||||||
|
"blocked_ips": blocked_ips,
|
||||||
|
"inaccessible_subnets": inaccessible_subnets,
|
||||||
|
"local_network_scan": local_network_scan,
|
||||||
|
"subnets": subnets,
|
||||||
|
}
|
||||||
|
schema = ScanTargetConfigurationSchema()
|
||||||
|
|
||||||
|
config = schema.load(scan_target_config)
|
||||||
|
|
||||||
|
assert config.blocked_ips == blocked_ips
|
||||||
|
assert config.inaccessible_subnets == inaccessible_subnets
|
||||||
|
assert config.local_network_scan == local_network_scan
|
||||||
|
assert config.subnets == subnets
|
||||||
|
|
||||||
|
|
||||||
def test_icmp_scan_configuration_schema():
|
def test_icmp_scan_configuration_schema():
|
||||||
timeout_ms = 2525
|
timeout_ms = 2525
|
||||||
schema = ICMPScanConfigurationSchema()
|
schema = ICMPScanConfigurationSchema()
|
||||||
|
|
|
@ -190,6 +190,7 @@ _make_plugin_configuration # unused method (monkey/common/configuration/agent_c
|
||||||
_make_custom_pba_configuration # unused method (monkey/common/configuration/agent_configuration.py:24)
|
_make_custom_pba_configuration # unused method (monkey/common/configuration/agent_configuration.py:24)
|
||||||
_make_exploiter_configuration # unused method (monkey/common/configuration/agent_configuration.py:69)
|
_make_exploiter_configuration # unused method (monkey/common/configuration/agent_configuration.py:69)
|
||||||
_make_exploitation_options_configuration # unused method (monkey/common/configuration/agent_configuration.py:86)
|
_make_exploitation_options_configuration # unused method (monkey/common/configuration/agent_configuration.py:86)
|
||||||
|
_make_scan_target_configuration # unused method (monkey/common/configuration/agent_configuration.py:105)
|
||||||
_make_icmp_scan_configuration # unused method (monkey/common/configuration/agent_configuration.py:107)
|
_make_icmp_scan_configuration # unused method (monkey/common/configuration/agent_configuration.py:107)
|
||||||
_make_tcp_scan_configuration # unused method (monkey/common/configuration/agent_configuration.py:122)
|
_make_tcp_scan_configuration # unused method (monkey/common/configuration/agent_configuration.py:122)
|
||||||
LINUX # unused variable (monkey/common/operating_systems.py:5)
|
LINUX # unused variable (monkey/common/operating_systems.py:5)
|
||||||
|
|
Loading…
Reference in New Issue