Merge branch '4.0.0a1-dev' into feature/2887-Align_Node_Types

This commit is contained in:
Charlie Crane
2025-01-28 09:40:27 +00:00
5 changed files with 11 additions and 14 deletions

View File

@@ -1 +1,7 @@
# © Crown-owned copyright 2025, Defence Science and Technology Laboratory UK # © Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
from primaite.game.agent.interface import ProxyAgent
from primaite.game.agent.scripted_agents.data_manipulation_bot import DataManipulationAgent
from primaite.game.agent.scripted_agents.probabilistic_agent import ProbabilisticAgent
from primaite.game.agent.scripted_agents.random_agent import PeriodicAgent, RandomAgent
__all__ = ("ProbabilisticAgent", "ProxyAgent", "RandomAgent", "PeriodicAgent", "DataManipulationAgent")

View File

@@ -26,7 +26,7 @@ class ACLAddRuleAbstractAction(AbstractAction, ABC):
class ConfigSchema(AbstractAction.ConfigSchema): class ConfigSchema(AbstractAction.ConfigSchema):
"""Configuration Schema base for ACL add rule abstract actions.""" """Configuration Schema base for ACL add rule abstract actions."""
src_ip: IPV4Address src_ip: Union[IPV4Address, Literal["ALL"]]
protocol_name: Union[IPProtocol, Literal["ALL"]] protocol_name: Union[IPProtocol, Literal["ALL"]]
permission: Literal["PERMIT", "DENY"] permission: Literal["PERMIT", "DENY"]
position: int position: int

View File

@@ -44,10 +44,12 @@ class PeriodicAgent(AbstractScriptedAgent, identifier="PeriodicAgent"):
start_step: int = 5 start_step: int = 5
"The timestep at which an agent begins performing it's actions" "The timestep at which an agent begins performing it's actions"
start_variance: int = 0
frequency: int = 5 frequency: int = 5
"The number of timesteps to wait between performing actions" "The number of timesteps to wait between performing actions"
variance: int = 0 variance: int = 0
"The amount the frequency can randomly change to" "The amount the frequency can randomly change to"
max_executions: int = 999999
possible_start_nodes: List[str] possible_start_nodes: List[str]
target_application: str target_application: str
@@ -76,8 +78,6 @@ class PeriodicAgent(AbstractScriptedAgent, identifier="PeriodicAgent"):
default_factory=lambda: PeriodicAgent.AgentSettingsSchema() default_factory=lambda: PeriodicAgent.AgentSettingsSchema()
) )
max_executions: int = 999999
"Maximum number of times the agent can execute its action."
num_executions: int = 0 num_executions: int = 0
"""Number of times the agent has executed an action.""" """Number of times the agent has executed an action."""
next_execution_timestep: int = 0 next_execution_timestep: int = 0
@@ -102,7 +102,7 @@ class PeriodicAgent(AbstractScriptedAgent, identifier="PeriodicAgent"):
def get_action(self, obs: ObsType, timestep: int) -> Tuple[str, Dict]: def get_action(self, obs: ObsType, timestep: int) -> Tuple[str, Dict]:
"""Do nothing, unless the current timestep is the next execution timestep, in which case do the action.""" """Do nothing, unless the current timestep is the next execution timestep, in which case do the action."""
if timestep == self.next_execution_timestep and self.num_executions < self.max_executions: if timestep == self.next_execution_timestep and self.num_executions < self.config.agent_settings.max_executions:
self.num_executions += 1 self.num_executions += 1
self._set_next_execution_timestep( self._set_next_execution_timestep(
timestep + self.config.agent_settings.frequency, self.config.agent_settings.variance timestep + self.config.agent_settings.frequency, self.config.agent_settings.variance

View File

@@ -320,7 +320,7 @@ class PrimaiteGame:
if service_class is not None: if service_class is not None:
_LOGGER.debug(f"installing {service_type} on node {new_node.config.hostname}") _LOGGER.debug(f"installing {service_type} on node {new_node.config.hostname}")
new_node.software_manager.install(service_class) new_node.software_manager.install(service_class, software_config=service_cfg.get("options", {}))
new_service = new_node.software_manager.software[service_class.__name__] new_service = new_node.software_manager.software[service_class.__name__]
# fixing duration for the service # fixing duration for the service

View File

@@ -6,7 +6,6 @@ from prettytable import MARKDOWN, PrettyTable
from pydantic import Field, validate_call from pydantic import Field, validate_call
from primaite.simulator.core import RequestManager, RequestType from primaite.simulator.core import RequestManager, RequestType
from primaite.simulator.network.hardware.node_operating_state import NodeOperatingState
from primaite.simulator.network.hardware.nodes.network.router import ( from primaite.simulator.network.hardware.nodes.network.router import (
AccessControlList, AccessControlList,
ACLAction, ACLAction,
@@ -268,23 +267,15 @@ class Firewall(Router, identifier="firewall"):
:param dmz: If True, shows ACL rules for DMZ interfaces. :param dmz: If True, shows ACL rules for DMZ interfaces.
:param markdown: If True, formats the output in Markdown, enhancing readability in Markdown-compatible viewers. :param markdown: If True, formats the output in Markdown, enhancing readability in Markdown-compatible viewers.
""" """
print(f"{self.hostname} Firewall Rules")
print()
if external: if external:
self.external_inbound_acl.show(markdown) self.external_inbound_acl.show(markdown)
print()
self.external_outbound_acl.show(markdown) self.external_outbound_acl.show(markdown)
print()
if internal: if internal:
self.internal_inbound_acl.show(markdown) self.internal_inbound_acl.show(markdown)
print()
self.internal_outbound_acl.show(markdown) self.internal_outbound_acl.show(markdown)
print()
if dmz: if dmz:
self.dmz_inbound_acl.show(markdown) self.dmz_inbound_acl.show(markdown)
print()
self.dmz_outbound_acl.show(markdown) self.dmz_outbound_acl.show(markdown)
print()
def receive_frame(self, frame: Frame, from_network_interface: RouterInterface): def receive_frame(self, frame: Frame, from_network_interface: RouterInterface):
""" """