#1355 - Renamed the NodeType custom type in custom_typing.py as it clased with the NodeType enum in enums.py
This commit is contained in:
@@ -4,5 +4,5 @@ from primaite.nodes.active_node import ActiveNode
|
|||||||
from primaite.nodes.passive_node import PassiveNode
|
from primaite.nodes.passive_node import PassiveNode
|
||||||
from primaite.nodes.service_node import ServiceNode
|
from primaite.nodes.service_node import ServiceNode
|
||||||
|
|
||||||
NodeType: Type = Union[ActiveNode, PassiveNode, ServiceNode]
|
NodeUnion: Type = Union[ActiveNode, PassiveNode, ServiceNode]
|
||||||
"""A Union of ActiveNode, PassiveNode, and ServiceNode."""
|
"""A Union of ActiveNode, PassiveNode, and ServiceNode."""
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ from gym import Env, spaces
|
|||||||
from matplotlib import pyplot as plt
|
from matplotlib import pyplot as plt
|
||||||
|
|
||||||
from primaite.acl.access_control_list import AccessControlList
|
from primaite.acl.access_control_list import AccessControlList
|
||||||
from primaite.common.custom_typing import NodeType
|
from primaite.common.custom_typing import NodeUnion
|
||||||
from primaite.common.enums import (
|
from primaite.common.enums import (
|
||||||
ActionType,
|
ActionType,
|
||||||
FileSystemState,
|
FileSystemState,
|
||||||
@@ -80,10 +80,10 @@ class Primaite(Env):
|
|||||||
self.agent_identifier = self.config_values.agent_identifier
|
self.agent_identifier = self.config_values.agent_identifier
|
||||||
|
|
||||||
# Create a dictionary to hold all the nodes
|
# Create a dictionary to hold all the nodes
|
||||||
self.nodes: Dict[str, NodeType] = {}
|
self.nodes: Dict[str, NodeUnion] = {}
|
||||||
|
|
||||||
# Create a dictionary to hold a reference set of nodes
|
# Create a dictionary to hold a reference set of nodes
|
||||||
self.nodes_reference: Dict[str, NodeType] = {}
|
self.nodes_reference: Dict[str, NodeUnion] = {}
|
||||||
|
|
||||||
# Create a dictionary to hold all the links
|
# Create a dictionary to hold all the links
|
||||||
self.links: Dict[str, Link] = {}
|
self.links: Dict[str, Link] = {}
|
||||||
@@ -1128,7 +1128,7 @@ class Primaite(Env):
|
|||||||
node_class = item["node_class"]
|
node_class = item["node_class"]
|
||||||
node_hardware_state: HardwareState = HardwareState[item["hardware_state"]]
|
node_hardware_state: HardwareState = HardwareState[item["hardware_state"]]
|
||||||
|
|
||||||
node: NodeType = self.nodes[node_id]
|
node: NodeUnion = self.nodes[node_id]
|
||||||
node_ref = self.nodes_reference[node_id]
|
node_ref = self.nodes_reference[node_id]
|
||||||
|
|
||||||
# Reset the hardware state (common for all node types)
|
# Reset the hardware state (common for all node types)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from typing import Dict, Union
|
|||||||
from networkx import MultiGraph, shortest_path
|
from networkx import MultiGraph, shortest_path
|
||||||
|
|
||||||
from primaite.acl.access_control_list import AccessControlList
|
from primaite.acl.access_control_list import AccessControlList
|
||||||
from primaite.common.custom_typing import NodeType
|
from primaite.common.custom_typing import NodeUnion
|
||||||
from primaite.common.enums import HardwareState, NodePOLType, NodeType, SoftwareState
|
from primaite.common.enums import HardwareState, NodePOLType, NodeType, SoftwareState
|
||||||
from primaite.links.link import Link
|
from primaite.links.link import Link
|
||||||
from primaite.nodes.active_node import ActiveNode
|
from primaite.nodes.active_node import ActiveNode
|
||||||
@@ -19,7 +19,7 @@ _VERBOSE = False
|
|||||||
|
|
||||||
def apply_iers(
|
def apply_iers(
|
||||||
network: MultiGraph,
|
network: MultiGraph,
|
||||||
nodes: Dict[str, NodeType],
|
nodes: Dict[str, NodeUnion],
|
||||||
links: Dict[str, Link],
|
links: Dict[str, Link],
|
||||||
iers: Dict[str, IER],
|
iers: Dict[str, IER],
|
||||||
acl: AccessControlList,
|
acl: AccessControlList,
|
||||||
@@ -230,7 +230,7 @@ def apply_iers(
|
|||||||
|
|
||||||
|
|
||||||
def apply_node_pol(
|
def apply_node_pol(
|
||||||
nodes: Dict[str, NodeType],
|
nodes: Dict[str, NodeUnion],
|
||||||
node_pol: Dict[any, Union[NodeStateInstructionGreen, NodeStateInstructionRed]],
|
node_pol: Dict[any, Union[NodeStateInstructionGreen, NodeStateInstructionRed]],
|
||||||
step: int,
|
step: int,
|
||||||
):
|
):
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from typing import Dict
|
|||||||
from networkx import MultiGraph, shortest_path
|
from networkx import MultiGraph, shortest_path
|
||||||
|
|
||||||
from primaite.acl.access_control_list import AccessControlList
|
from primaite.acl.access_control_list import AccessControlList
|
||||||
from primaite.common.custom_typing import NodeType
|
from primaite.common.custom_typing import NodeUnion
|
||||||
from primaite.common.enums import (
|
from primaite.common.enums import (
|
||||||
HardwareState,
|
HardwareState,
|
||||||
NodePOLInitiator,
|
NodePOLInitiator,
|
||||||
@@ -24,7 +24,7 @@ _VERBOSE = False
|
|||||||
|
|
||||||
def apply_red_agent_iers(
|
def apply_red_agent_iers(
|
||||||
network: MultiGraph,
|
network: MultiGraph,
|
||||||
nodes: Dict[str, NodeType],
|
nodes: Dict[str, NodeUnion],
|
||||||
links: Dict[str, Link],
|
links: Dict[str, Link],
|
||||||
iers: Dict[str, IER],
|
iers: Dict[str, IER],
|
||||||
acl: AccessControlList,
|
acl: AccessControlList,
|
||||||
@@ -221,7 +221,7 @@ def apply_red_agent_iers(
|
|||||||
|
|
||||||
|
|
||||||
def apply_red_agent_node_pol(
|
def apply_red_agent_node_pol(
|
||||||
nodes: NodeType,
|
nodes: Dict[str, NodeUnion],
|
||||||
iers: Dict[str, IER],
|
iers: Dict[str, IER],
|
||||||
node_pol: Dict[str, NodeStateInstructionRed],
|
node_pol: Dict[str, NodeStateInstructionRed],
|
||||||
step: int,
|
step: int,
|
||||||
@@ -256,7 +256,7 @@ def apply_red_agent_node_pol(
|
|||||||
|
|
||||||
if step >= start_step and step <= stop_step:
|
if step >= start_step and step <= stop_step:
|
||||||
# continue --------------------------
|
# continue --------------------------
|
||||||
target_node: NodeType = nodes[target_node_id]
|
target_node: NodeUnion = nodes[target_node_id]
|
||||||
|
|
||||||
# Based the action taken on the initiator type
|
# Based the action taken on the initiator type
|
||||||
if initiator == NodePOLInitiator.DIRECT:
|
if initiator == NodePOLInitiator.DIRECT:
|
||||||
|
|||||||
Reference in New Issue
Block a user