csle_common.dao.container_config package
Submodules
csle_common.dao.container_config.container_env_config module
csle_common.dao.container_config.containers_config module
- class csle_common.dao.emulation_config.containers_config.ContainersConfig(containers: List[NodeContainerConfig], agent_ip: str, router_ip: str, networks: List[ContainerNetwork], ids_enabled: bool, vulnerable_nodes=None, agent_reachable_nodes=None)[source]
Bases:
JSONSerializable
A DTO representing the configuration of the containers that make up an emulation environment
- copy() ContainersConfig [source]
- Returns
a copy of the DTO
- create_execution_config(ip_first_octet: int, physical_servers: List[str]) ContainersConfig [source]
Creates a new config for an execution
- Parameters
ip_first_octet – the first octet of the IP of the new execution
physical_servers – the physical servers where the execution will be deployed
- Returns
the new config
- static from_dict(d: Dict[str, Any]) ContainersConfig [source]
Converts a dict representation to an instance
- Parameters
d – the dict to convert
- Returns
the created instance
- static from_json_file(json_file_path: str) ContainersConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
- get_agent_container() Optional[NodeContainerConfig] [source]
- Returns
get container of the attacker agent
- get_container_from_full_name(name: str) Optional[NodeContainerConfig] [source]
Utility function for getting the container
- Parameters
name – the full name of the container
- Returns
the container with the given ip or None
- get_container_from_ip(ip: str) Optional[NodeContainerConfig] [source]
Utility function for getting the container
- Parameters
ip – the ip of the container
- Returns
the container with the given ip or None
- get_reachable_ips(container: NodeContainerConfig) List[str] [source]
Get list of IP addresses reachable from a given container
- Parameters
container – the container to get reachable IPs from
- Returns
csle_common.dao.container_config.created_env_config module
csle_common.dao.container_config.flags_config module
- class csle_common.dao.emulation_config.flags_config.FlagsConfig(node_flag_configs: List[NodeFlagsConfig])[source]
Bases:
JSONSerializable
A DTO representing the set of flags in an emulation environment
- copy() FlagsConfig [source]
- Returns
a copy of the DTO
- create_execution_config(ip_first_octet: int) FlagsConfig [source]
Creates a new config for an execution
- Parameters
ip_first_octet – the first octet of the IP of the new execution
- Returns
the new config
- static from_dict(d: Dict[str, Any]) FlagsConfig [source]
Converts a dict representation to a an instance
- Parameters
d – the dict to convert
- Returns
the created instance
- static from_json_file(json_file_path: str) FlagsConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_common.dao.container_config.node_container_config module
- class csle_common.dao.emulation_config.node_container_config.NodeContainerConfig(name: str, ips_and_networks: List[Tuple[str, ContainerNetwork]], version: str, level: str, restart_policy: str, suffix: str, os: str, execution_ip_first_octet: int = -1, docker_gw_bridge_ip: str = '', physical_host_ip: str = '')[source]
Bases:
JSONSerializable
A DTO object representing an individual container in an emulation environment
- copy() NodeContainerConfig [source]
- Returns
a copy of the DTO
- create_execution_config(ip_first_octet: int, physical_servers: List[str]) NodeContainerConfig [source]
Creates a new config for an execution
- Parameters
ip_first_octet – the first octet of the IP of the new execution
physical_servers – the list of physical servers of the execution
- Returns
the new config
- static from_dict(d: Dict[str, Any]) NodeContainerConfig [source]
Converts a dict representation to an instance :param d: the dict to convert :return: the created instance
- static from_json_file(json_file_path: str) NodeContainerConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
- reachable(reachable_ips: List[str]) bool [source]
Check if container is reachable given a list of reachable ips
- Parameters
reachable_ips – the list of reachable ips
- Returns
True if the container is reachable, false otherwise
- static schema() NodeContainerConfig [source]
- Returns
get the schema of the DTO
csle_common.dao.container_config.node_firewall_config module
- class csle_common.dao.emulation_config.node_firewall_config.NodeFirewallConfig(ips_gw_default_policy_networks: List[DefaultNetworkFirewallConfig], hostname: str, output_accept: Set[str], input_accept: Set[str], forward_accept: Set[str], output_drop: Set[str], input_drop: Set[str], forward_drop: Set[str], routes: Set[Tuple[str, str]], docker_gw_bridge_ip: str = '', physical_host_ip: str = '')[source]
Bases:
JSONSerializable
A DTO object representing a firewall configuration of a container in an emulation environment
- copy() NodeFirewallConfig [source]
- Returns
a copy of the DTO
- create_execution_config(ip_first_octet: int) NodeFirewallConfig [source]
Creates a new config for an execution
- Parameters
ip_first_octet – the first octet of the IP of the new execution
- Returns
the new config
- static from_dict(d: Dict[str, Any]) NodeFirewallConfig [source]
Converts a dict representation into an instance
- Parameters
d – the dict to convert
- Returns
the created instance
- static from_json_file(json_file_path: str) NodeFirewallConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
- static schema() NodeFirewallConfig [source]
- Returns
get the schema of the DTO
csle_common.dao.container_config.node_flags_config module
- class csle_common.dao.emulation_config.node_flags_config.NodeFlagsConfig(ip: str, flags: List[Flag], docker_gw_bridge_ip: str = '', physical_host_ip: str = '')[source]
Bases:
JSONSerializable
A DTO object representing the set of flags at a specific container in an emulation environment
- copy() NodeFlagsConfig [source]
- Returns
a copy of the DTO
- create_execution_config(ip_first_octet: int) NodeFlagsConfig [source]
Creates a new config for an execution
- Parameters
ip_first_octet – the first octet of the IP of the new execution
- Returns
the new config
- static from_dict(d: Dict[str, Any]) NodeFlagsConfig [source]
Converts a dict representation of the object to an instance
- Parameters
d – the dict to convert
- Returns
the created instance
- static from_json_file(json_file_path: str) NodeFlagsConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_common.dao.container_config.node_network_config module
Network configuration of a container in the emulation
- class csle_common.dao.emulation_config.node_network_config.NodeNetworkConfig(interface: str = 'eth0', limit_packets_queue: int = 30000, packet_delay_ms: float = 0.1, packet_delay_jitter_ms: float = 0.025, packet_delay_correlation_percentage: float = 25, packet_delay_distribution: PacketDelayDistributionType = PacketDelayDistributionType.PARETO, packet_loss_type: PacketLossType = PacketLossType.GEMODEL, packet_loss_rate_random_percentage: float = 2, packet_loss_random_correlation_percentage: float = 25, loss_state_markov_chain_p13: float = 0.1, loss_state_markov_chain_p31: float = 0.1, loss_state_markov_chain_p32: float = 0.1, loss_state_markov_chain_p23: float = 0.1, loss_state_markov_chain_p14: float = 0.1, loss_gemodel_p: float = 0.0001, loss_gemodel_r: float = 0.999, loss_gemodel_h: float = 0.0001, loss_gemodel_k: float = 0.9999, packet_corrupt_percentage: float = 1e-05, packet_corrupt_correlation_percentage: float = 25, packet_duplicate_percentage: float = 1e-05, packet_duplicate_correlation_percentage: float = 25, packet_reorder_percentage: float = 0.0025, packet_reorder_correlation_percentage: float = 25, packet_reorder_gap: int = 5, rate_limit_mbit: float = 100, packet_overhead_bytes: int = 0, cell_overhead_bytes: int = 0)[source]
Bases:
JSONSerializable
A DTO object representing the network configuration of a specific container in an emulation environment
- copy() NodeNetworkConfig [source]
- Returns
a copy of the DTO
- static from_dict(d: Dict[str, Any]) NodeNetworkConfig [source]
Converts a dict representation to an instance
- Parameters
d – the dict to convert
- Returns
the converted instance
- static from_json_file(json_file_path: str) NodeNetworkConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
- static schema() NodeNetworkConfig [source]
- Returns
get the schema of the DTO
csle_common.dao.container_config.node_resources_config module
- class csle_common.dao.emulation_config.node_resources_config.NodeResourcesConfig(container_name: str, num_cpus: int, available_memory_gb: int, ips_and_network_configs: List[Tuple[str, NodeNetworkConfig]], docker_gw_bridge_ip: str = '', physical_host_ip: str = '')[source]
Bases:
JSONSerializable
A DTO object representing the resources of a specific container in an emulation environment
- copy() NodeResourcesConfig [source]
- Returns
a copy of the DTO
- create_execution_config(ip_first_octet: int) NodeResourcesConfig [source]
Creates a new config for an execution
- Parameters
ip_first_octet – the first octet of the IP of the new execution
- Returns
the new config
- static from_dict(d: Dict[str, Any]) NodeResourcesConfig [source]
Converts a dict representation into an instance
- Parameters
d – the dict to convert
- Returns
the created instance
- static from_json_file(json_file_path: str) NodeResourcesConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
- static schema() NodeResourcesConfig [source]
- Returns
get the schema of the DTO
csle_common.dao.container_config.node_traffic_config module
- class csle_common.dao.emulation_config.node_traffic_config.NodeTrafficConfig(ip: str, commands: List[str], traffic_manager_log_file: str, traffic_manager_log_dir: str, traffic_manager_max_workers: int, traffic_manager_port: int = 50043, docker_gw_bridge_ip: str = '', physical_host_ip: str = '')[source]
Bases:
JSONSerializable
A DTO object representing the traffic configuration of an individual container in an emulation
- copy() NodeTrafficConfig [source]
- Returns
a copy of the DTO
- create_execution_config(ip_first_octet: int) NodeTrafficConfig [source]
Creates a new config for an execution
- Parameters
ip_first_octet – the first octet of the IP of the new execution
- Returns
the new config
- static from_dict(d: Dict[str, Any]) NodeTrafficConfig [source]
Converts a dict representation into an instance
- Parameters
d – the dict to convert
- Returns
the created instance
- static from_json_file(json_file_path: str) NodeTrafficConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_common.dao.container_config.node_users_config module
- class csle_common.dao.emulation_config.node_users_config.NodeUsersConfig(ip: str, users: List[User], docker_gw_bridge_ip: str = '', physical_host_ip: str = '')[source]
Bases:
JSONSerializable
A DTO object representing the users of a container in an emulation environment
- copy() NodeUsersConfig [source]
- Returns
a copy of the DTO
- create_execution_config(ip_first_octet: int) NodeUsersConfig [source]
Creates a new config for an execution
- Parameters
ip_first_octet – the first octet of the IP of the new execution
- Returns
the new config
- static from_dict(d: Dict[str, Any]) NodeUsersConfig [source]
Converts a dict representation to an instance
- Parameters
d – the dict to convert
- Returns
the created instance
- static from_json_file(json_file_path: str) NodeUsersConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_common.dao.container_config.node_vulnerability_config module
- class csle_common.dao.emulation_config.node_vulnerability_config.NodeVulnerabilityConfig(ip: str, vuln_type: VulnType, name: str, port: Optional[int], protocol: TransportProtocol, credentials: Optional[List[Credential]] = None, cvss: float = 2.0, cve: Optional[str] = None, service: Optional[str] = None, root: bool = False, docker_gw_bridge_ip: str = '', physical_host_ip: str = '')[source]
Bases:
JSONSerializable
A DTO object representing a vulnerability of a container in the emulation environment
- copy() NodeVulnerabilityConfig [source]
- Returns
a copy of the DTO
- create_execution_config(ip_first_octet: int) NodeVulnerabilityConfig [source]
Creates a new config for an execution
- Parameters
ip_first_octet – the first octet of the IP of the new execution
- Returns
the new config
- static from_dict(d: Dict[str, Any]) NodeVulnerabilityConfig [source]
Convert a dict representation to a DTO representation
- Returns
a dto representation of the object
- static from_json_file(json_file_path: str) NodeVulnerabilityConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_common.dao.container_config.packet_delay_distribution_type module
Type of delay distributions on a container’s network interface
- class csle_common.dao.emulation_config.packet_delay_distribution_type.PacketDelayDistributionType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
Enum representing the different types of delay distributions to emulate on a container
- NORMAL = 1
- PARETO = 2
- PARETONORMAL = 3
- UNIFORM = 0
csle_common.dao.container_config.packet_loss_type module
Type of packet losses on a container’s network interface
csle_common.dao.container_config.priv_esc_vulnerability_config module
csle_common.dao.container_config.pw_vulnerability_config module
csle_common.dao.container_config.rce_vulnerability_config module
csle_common.dao.container_config.resources_config module
- class csle_common.dao.emulation_config.resources_config.ResourcesConfig(node_resources_configurations: List[NodeResourcesConfig])[source]
Bases:
JSONSerializable
A DTO representing the resources assigned to the containers in an emulation environment
- copy() ResourcesConfig [source]
- Returns
a copy of the DTO
- create_execution_config(ip_first_octet: int) ResourcesConfig [source]
Creates a new config for an execution
- Parameters
ip_first_octet – the first octet of the IP of the new execution
- Returns
the new config
- static from_dict(d: Dict[str, Any]) ResourcesConfig [source]
Converts a dict representation into an instance
- Parameters
d – the dict to convert
- Returns
the created instance
- static from_json_file(json_file_path: str) ResourcesConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_common.dao.container_config.sql_injection_vulnerability_config module
csle_common.dao.container_config.topology module
csle_common.dao.container_config.traffic_config module
- class csle_common.dao.emulation_config.traffic_config.TrafficConfig(node_traffic_configs: List[NodeTrafficConfig], client_population_config: ClientPopulationConfig)[source]
Bases:
JSONSerializable
A DTO object representing the traffic configuration of an emulation environment
- copy() TrafficConfig [source]
- Returns
a copy of the DTO
- create_execution_config(ip_first_octet: int) TrafficConfig [source]
Creates a new config for an execution
- Parameters
ip_first_octet – the first octet of the IP of the new execution
- Returns
the new config
- static from_dict(d: Dict[str, Any]) TrafficConfig [source]
Converts a dict representation of the object into a an instance
- Parameters
d – the dict to convert
- Returns
the created instance
- static from_json_file(json_file_path: str) TrafficConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
- get_node_traffic_config_by_ip(ip: str) Optional[NodeTrafficConfig] [source]
Gets a node traffic config with a specific IP
- Parameters
ip – the ip
- Returns
the node traffic config or None
csle_common.dao.container_config.users_config module
- class csle_common.dao.emulation_config.users_config.UsersConfig(users_configs: List[NodeUsersConfig])[source]
Bases:
JSONSerializable
A DTO object representing the users configuration of an emulation environment
- copy() UsersConfig [source]
- Returns
a copy of the DTO
- create_execution_config(ip_first_octet: int) UsersConfig [source]
Creates a new config for an execution
- Parameters
ip_first_octet – the first octet of the IP of the new execution
- Returns
the new config
- static from_dict(d: Dict[str, Any]) UsersConfig [source]
Converts a dict representation to an instance
- Parameters
d – the dict to convert
- Returns
the created instance
- static from_json_file(json_file_path: str) UsersConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_common.dao.container_config.vulnerabilities_config module
- class csle_common.dao.emulation_config.vulnerabilities_config.VulnerabilitiesConfig(node_vulnerability_configs: List[NodeVulnerabilityConfig])[source]
Bases:
JSONSerializable
A DTO class representing the vulnerabilities configuration of an emulation environment
- copy() VulnerabilitiesConfig [source]
- Returns
a copy of the DTO
- create_execution_config(ip_first_octet: int) VulnerabilitiesConfig [source]
Creates a new config for an execution
- Parameters
ip_first_octet – the first octet of the IP of the new execution
- Returns
the new config
- static from_dict(d: Dict[str, Any]) VulnerabilitiesConfig [source]
Converts a dict representation of the object to a DTO representation :return: a DTO representation of the object
- static from_json_file(json_file_path: str) VulnerabilitiesConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
- get_vulnerabilities(ips: List[str]) List[NodeVulnerabilityConfig] [source]
Gets a list of vulnerabilities for a list of ip addresses
- Parameters
ips – the list of ip addresse
- Returns
the list of vulnerabilities corresponding to the list of ip addresses
csle_common.dao.container_config.vulnerability_type module
Type of vulnerabilities in an emulation
- class csle_common.dao.emulation_config.vulnerability_type.VulnType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
Enum representing the different vulnerability types for generated containers
- PRIVILEGE_ESCALATION = 3
- RCE = 1
- SQL_INJECTION = 2
- WEAK_PW = 0