Common: Fix configuration typehints to tuples

Configuration types need to be tuples, because that's what we expect on the object. They can stay as lists in the marshmallow schemas, because marshmallow schemas expect to take lists.
This commit is contained in:
vakarisz 2022-07-26 17:20:10 +03:00
parent 1252ad3b87
commit 0ab90aeaf5
2 changed files with 15 additions and 15 deletions

View File

@ -1,11 +1,12 @@
from __future__ import annotations
from dataclasses import dataclass
from typing import Any, List, Mapping
from typing import Any, Mapping, Tuple
from marshmallow import Schema, fields, post_load
from marshmallow import Schema, fields
from marshmallow.exceptions import MarshmallowError
from ..utils.code_utils import freeze_lists_in_dict
from .agent_sub_configuration_schemas import (
CustomPBAConfigurationSchema,
PluginConfigurationSchema,
@ -16,7 +17,6 @@ from .agent_sub_configurations import (
PluginConfiguration,
PropagationConfiguration,
)
from ..utils.code_utils import freeze_lists_in_dict
class InvalidConfigurationError(Exception):
@ -34,9 +34,9 @@ class InvalidConfigurationError(Exception):
class AgentConfiguration:
keep_tunnel_open_time: float
custom_pbas: CustomPBAConfiguration
post_breach_actions: List[PluginConfiguration]
credential_collectors: List[PluginConfiguration]
payloads: List[PluginConfiguration]
post_breach_actions: Tuple[PluginConfiguration]
credential_collectors: Tuple[PluginConfiguration]
payloads: Tuple[PluginConfiguration]
propagation: PropagationConfiguration
def __post_init__(self):

View File

@ -1,5 +1,5 @@
from dataclasses import dataclass
from typing import Dict, List
from typing import Dict, Tuple
@dataclass(frozen=True)
@ -18,10 +18,10 @@ class PluginConfiguration:
@dataclass(frozen=True)
class ScanTargetConfiguration:
blocked_ips: List[str]
inaccessible_subnets: List[str]
blocked_ips: Tuple[str]
inaccessible_subnets: Tuple[str]
local_network_scan: bool
subnets: List[str]
subnets: Tuple[str]
@dataclass(frozen=True)
@ -32,27 +32,27 @@ class ICMPScanConfiguration:
@dataclass(frozen=True)
class TCPScanConfiguration:
timeout: float
ports: List[int]
ports: Tuple[int]
@dataclass(frozen=True)
class NetworkScanConfiguration:
tcp: TCPScanConfiguration
icmp: ICMPScanConfiguration
fingerprinters: List[PluginConfiguration]
fingerprinters: Tuple[PluginConfiguration]
targets: ScanTargetConfiguration
@dataclass(frozen=True)
class ExploitationOptionsConfiguration:
http_ports: List[int]
http_ports: Tuple[int]
@dataclass(frozen=True)
class ExploitationConfiguration:
options: ExploitationOptionsConfiguration
brute_force: List[PluginConfiguration]
vulnerability: List[PluginConfiguration]
brute_force: Tuple[PluginConfiguration]
vulnerability: Tuple[PluginConfiguration]
@dataclass(frozen=True)