From 40d052141c92b0634f683d6ce830cd234a6bfc99 Mon Sep 17 00:00:00 2001 From: Marek Wolan Date: Tue, 14 Jan 2025 13:48:18 +0000 Subject: [PATCH] #2869 - Remove outdated parameters from actionmanager (action map achieves the same result) [skip ci] --- docs/source/configuration/agents.rst | 17 -- .../how_to_guides/extensible_agents.rst | 13 +- .../applications/data_manipulation_bot.rst | 12 -- .../_package_data/data_manipulation.yaml | 104 ---------- .../_package_data/data_manipulation_marl.yaml | 176 ----------------- .../base_scenario.yaml | 18 -- .../scenario_with_placeholders/greens_1.yaml | 8 - .../scenario_with_placeholders/greens_2.yaml | 8 - .../scenario_with_placeholders/reds_1.yaml | 8 - .../scenario_with_placeholders/reds_2.yaml | 8 - .../scenario_with_placeholders/scenario.yaml | 19 -- src/primaite/game/agent/actions/manager.py | 58 +----- src/primaite/game/agent/interface.py | 4 +- src/primaite/game/game.py | 4 +- ...ommand-and-Control-E2E-Demonstration.ipynb | 72 ++----- ...a-Manipulation-Customising-Red-Agent.ipynb | 21 +- tests/assets/configs/action_penalty.yaml | 67 ------- .../assets/configs/bad_primaite_session.yaml | 78 -------- tests/assets/configs/basic_firewall.yaml | 12 -- .../configs/basic_switched_network.yaml | 30 --- tests/assets/configs/data_manipulation.yaml | 107 ----------- tests/assets/configs/dmz_network.yaml | 12 -- .../configs/eval_only_primaite_session.yaml | 78 -------- tests/assets/configs/extended_config.yaml | 105 ---------- .../configs/firewall_actions_network.yaml | 20 -- .../assets/configs/fix_duration_one_item.yaml | 30 --- .../configs/install_and_configure_apps.yaml | 13 -- tests/assets/configs/multi_agent_session.yaml | 179 ------------------ ...etwork_service_recon_red_agent_config.yaml | 11 -- .../nmap_ping_scan_red_agent_config.yaml | 11 -- .../nmap_port_scan_red_agent_config.yaml | 11 -- .../scenario_with_placeholders/greens_1.yaml | 8 - .../scenario_with_placeholders/greens_2.yaml | 8 - .../scenario_with_placeholders/reds_1.yaml | 8 - .../scenario_with_placeholders/reds_2.yaml | 8 - .../scenario_with_placeholders/scenario.yaml | 19 -- tests/assets/configs/shared_rewards.yaml | 107 ----------- .../assets/configs/software_fix_duration.yaml | 30 --- .../configs/test_application_install.yaml | 95 +--------- .../assets/configs/test_primaite_session.yaml | 90 --------- .../_primaite/_game/_agent/test_actions.py | 4 +- .../_game/_agent/test_probabilistic_agent.py | 24 +-- 42 files changed, 36 insertions(+), 1679 deletions(-) diff --git a/docs/source/configuration/agents.rst b/docs/source/configuration/agents.rst index d11f7892..cf2b618f 100644 --- a/docs/source/configuration/agents.rst +++ b/docs/source/configuration/agents.rst @@ -23,19 +23,6 @@ Agents can be scripted (deterministic and stochastic), or controlled by a reinfo observation_space: type: UC2GreenObservation action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client_2 - applications: - - application_name: WebBrowser - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_applications_per_node: 1 - reward_function: reward_components: - type: DUMMY @@ -91,10 +78,6 @@ For more information see :py:mod:`primaite.game.agent.observations` The action space is configured to be made up of individual action types. Once configured, the agent can select an action type and some optional action parameters at every step. For example: The ``NODE_SERVICE_SCAN`` action takes the parameters ``node_id`` and ``service_id``. -``action_list`` -^^^^^^^^^^^^^^^ - -A list of action modules. The options are listed in the :py:mod:`primaite.game.agent.actions.ActionManager.act_class_identifiers` module. ``action_map`` ^^^^^^^^^^^^^^ diff --git a/docs/source/how_to_guides/extensible_agents.rst b/docs/source/how_to_guides/extensible_agents.rst index 5bbca13a..169af094 100644 --- a/docs/source/how_to_guides/extensible_agents.rst +++ b/docs/source/how_to_guides/extensible_agents.rst @@ -42,28 +42,17 @@ The core features that should be implemented in any new agent are detailed below """Host node that this agent should start from in the given environment.""" - .. code-block:: YAML + .. code-block:: yaml - ref: example_green_agent team: GREEN type: ExampleAgent observation_space: null action_space: - action_list: - - type: do_nothing action_map: 0: action: do_nothing options: {} - options: - nodes: - - node_name: client_1 - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_nics_per_node: 2 - max_acl_rules: 10 - reward_function: reward_components: - type: DUMMY diff --git a/docs/source/simulation_components/system/applications/data_manipulation_bot.rst b/docs/source/simulation_components/system/applications/data_manipulation_bot.rst index 91c33ede..49dc3baf 100644 --- a/docs/source/simulation_components/system/applications/data_manipulation_bot.rst +++ b/docs/source/simulation_components/system/applications/data_manipulation_bot.rst @@ -113,18 +113,6 @@ If not using the data manipulation bot manually, it needs to be used with a data folders: {} action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client_1 - applications: - - application_ref: data_manipulation_bot - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - reward_function: reward_components: - type: DUMMY diff --git a/src/primaite/config/_package_data/data_manipulation.yaml b/src/primaite/config/_package_data/data_manipulation.yaml index 58986bce..4869d5d1 100644 --- a/src/primaite/config/_package_data/data_manipulation.yaml +++ b/src/primaite/config/_package_data/data_manipulation.yaml @@ -32,19 +32,6 @@ agents: 2: 0.1 observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client_2 - applications: - - application_name: WebBrowser - - application_name: DatabaseClient - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_applications_per_node: 2 action_map: 0: action: DONOTHING @@ -81,19 +68,6 @@ agents: 2: 0.1 observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client_1 - applications: - - application_name: WebBrowser - - application_name: DatabaseClient - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_applications_per_node: 2 action_map: 0: action: DONOTHING @@ -131,20 +105,6 @@ agents: observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client_1 - applications: - - application_name: DataManipulationBot - - node_name: client_2 - applications: - - application_name: DataManipulationBot - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 reward_function: reward_components: @@ -236,35 +196,6 @@ agents: options: {} action_space: - action_list: - - type: DONOTHING - - type: NODE_SERVICE_SCAN - - type: NODE_SERVICE_STOP - - type: NODE_SERVICE_START - - type: NODE_SERVICE_PAUSE - - type: NODE_SERVICE_RESUME - - type: NODE_SERVICE_RESTART - - type: NODE_SERVICE_DISABLE - - type: NODE_SERVICE_ENABLE - - type: NODE_SERVICE_FIX - - type: NODE_FILE_SCAN - - type: NODE_FILE_CHECKHASH - - type: NODE_FILE_DELETE - - type: NODE_FILE_REPAIR - - type: NODE_FILE_RESTORE - - type: NODE_FOLDER_SCAN - - type: NODE_FOLDER_CHECKHASH - - type: NODE_FOLDER_REPAIR - - type: NODE_FOLDER_RESTORE - - type: NODE_OS_SCAN - - type: NODE_SHUTDOWN - - type: NODE_STARTUP - - type: NODE_RESET - - type: ROUTER_ACL_ADDRULE - - type: ROUTER_ACL_REMOVERULE - - type: HOST_NIC_ENABLE - - type: HOST_NIC_DISABLE - action_map: 0: action: DONOTHING @@ -685,41 +616,6 @@ agents: - options: - nodes: - - node_name: domain_controller - - node_name: web_server - applications: - - application_name: DatabaseClient - services: - - service_name: WebServer - - node_name: database_server - folders: - - folder_name: database - files: - - file_name: database.db - services: - - service_name: DatabaseService - - node_name: backup_server - - node_name: security_suite - - node_name: client_1 - - node_name: client_2 - - max_folders_per_node: 2 - max_files_per_folder: 2 - max_services_per_node: 2 - max_nics_per_node: 8 - max_acl_rules: 10 - ip_list: - - 192.168.1.10 - - 192.168.1.12 - - 192.168.1.14 - - 192.168.1.16 - - 192.168.1.110 - - 192.168.10.21 - - 192.168.10.22 - - 192.168.10.110 - reward_function: reward_components: diff --git a/src/primaite/config/_package_data/data_manipulation_marl.yaml b/src/primaite/config/_package_data/data_manipulation_marl.yaml index c4a3b562..512afc64 100644 --- a/src/primaite/config/_package_data/data_manipulation_marl.yaml +++ b/src/primaite/config/_package_data/data_manipulation_marl.yaml @@ -28,19 +28,6 @@ agents: 2: 0.1 observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client_2 - applications: - - application_name: WebBrowser - - application_name: DatabaseClient - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_applications_per_node: 2 action_map: 0: action: DONOTHING @@ -77,19 +64,6 @@ agents: 2: 0.1 observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client_1 - applications: - - application_name: WebBrowser - - application_name: DatabaseClient - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_applications_per_node: 2 action_map: 0: action: DONOTHING @@ -127,23 +101,6 @@ agents: observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - - type: NODE_FILE_DELETE - - type: NODE_FILE_CORRUPT - - type: NODE_OS_SCAN - options: - nodes: - - node_name: client_1 - applications: - - application_name: DataManipulationBot - - node_name: client_2 - applications: - - application_name: DataManipulationBot - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 reward_function: reward_components: @@ -230,35 +187,6 @@ agents: options: {} action_space: - action_list: - - type: DONOTHING - - type: NODE_SERVICE_SCAN - - type: NODE_SERVICE_STOP - - type: NODE_SERVICE_START - - type: NODE_SERVICE_PAUSE - - type: NODE_SERVICE_RESUME - - type: NODE_SERVICE_RESTART - - type: NODE_SERVICE_DISABLE - - type: NODE_SERVICE_ENABLE - - type: NODE_SERVICE_FIX - - type: NODE_FILE_SCAN - - type: NODE_FILE_CHECKHASH - - type: NODE_FILE_DELETE - - type: NODE_FILE_REPAIR - - type: NODE_FILE_RESTORE - - type: NODE_FOLDER_SCAN - - type: NODE_FOLDER_CHECKHASH - - type: NODE_FOLDER_REPAIR - - type: NODE_FOLDER_RESTORE - - type: NODE_OS_SCAN - - type: NODE_SHUTDOWN - - type: NODE_STARTUP - - type: NODE_RESET - - type: ROUTER_ACL_ADDRULE - - type: ROUTER_ACL_REMOVERULE - - type: HOST_NIC_ENABLE - - type: HOST_NIC_DISABLE - action_map: 0: action: DONOTHING @@ -678,42 +606,6 @@ agents: nic_id: 0 - options: - nodes: - - node_name: domain_controller - - node_name: web_server - applications: - - application_name: DatabaseClient - services: - - service_name: WebServer - - node_name: database_server - folders: - - folder_name: database - files: - - file_name: database.db - services: - - service_name: DatabaseService - - node_name: backup_server - - node_name: security_suite - - node_name: client_1 - - node_name: client_2 - - max_folders_per_node: 2 - max_files_per_folder: 2 - max_services_per_node: 2 - max_nics_per_node: 8 - max_acl_rules: 10 - ip_list: - - 192.168.1.10 - - 192.168.1.12 - - 192.168.1.14 - - 192.168.1.16 - - 192.168.1.110 - - 192.168.10.21 - - 192.168.10.22 - - 192.168.10.110 - - reward_function: reward_components: - type: DATABASE_FILE_INTEGRITY @@ -810,39 +702,6 @@ agents: options: {} action_space: - action_list: - - type: DONOTHING - - type: NODE_SERVICE_SCAN - - type: NODE_SERVICE_STOP - - type: NODE_SERVICE_START - - type: NODE_SERVICE_PAUSE - - type: NODE_SERVICE_RESUME - - type: NODE_SERVICE_RESTART - - type: NODE_SERVICE_DISABLE - - type: NODE_SERVICE_ENABLE - - type: NODE_SERVICE_FIX - - type: NODE_FILE_SCAN - - type: NODE_FILE_CHECKHASH - - type: NODE_FILE_DELETE - - type: NODE_FILE_REPAIR - - type: NODE_FILE_RESTORE - - type: NODE_FOLDER_SCAN - - type: NODE_FOLDER_CHECKHASH - - type: NODE_FOLDER_REPAIR - - type: NODE_FOLDER_RESTORE - - type: NODE_OS_SCAN - - type: NODE_SHUTDOWN - - type: NODE_STARTUP - - type: NODE_RESET - - type: ROUTER_ACL_ADDRULE - options: - target_router: router_1 - - type: ROUTER_ACL_REMOVERULE - options: - target_router: router_1 - - type: HOST_NIC_ENABLE - - type: HOST_NIC_DISABLE - action_map: 0: action: DONOTHING @@ -1263,41 +1122,6 @@ agents: - options: - nodes: - - node_name: domain_controller - - node_name: web_server - applications: - - application_name: DatabaseClient - services: - - service_name: WebServer - - node_name: database_server - folders: - - folder_name: database - files: - - file_name: database.db - services: - - service_name: DatabaseService - - node_name: backup_server - - node_name: security_suite - - node_name: client_1 - - node_name: client_2 - - max_folders_per_node: 2 - max_files_per_folder: 2 - max_services_per_node: 2 - max_nics_per_node: 8 - max_acl_rules: 10 - ip_list: - - 192.168.1.10 - - 192.168.1.12 - - 192.168.1.14 - - 192.168.1.16 - - 192.168.1.110 - - 192.168.10.21 - - 192.168.10.22 - - 192.168.10.110 - reward_function: reward_components: - type: DATABASE_FILE_INTEGRITY diff --git a/src/primaite/config/_package_data/mini_scenario_with_simulation_variation/base_scenario.yaml b/src/primaite/config/_package_data/mini_scenario_with_simulation_variation/base_scenario.yaml index b4457a28..e461eccc 100644 --- a/src/primaite/config/_package_data/mini_scenario_with_simulation_variation/base_scenario.yaml +++ b/src/primaite/config/_package_data/mini_scenario_with_simulation_variation/base_scenario.yaml @@ -8,12 +8,6 @@ agents: type: ProxyAgent observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_SHUTDOWN - - type: NODE_STARTUP - - type: HOST_NIC_ENABLE - - type: HOST_NIC_DISABLE action_map: 0: action: DONOTHING @@ -54,18 +48,6 @@ agents: options: node_id: 1 nic_id: 0 - options: - nodes: - - node_name: client_1 - - node_name: server - max_folders_per_node: 0 - max_files_per_folder: 0 - max_services_per_node: 0 - max_nics_per_node: 1 - max_acl_rules: 0 - ip_list: - - 192.168.1.2 - - 192.168.1.3 reward_function: reward_components: [] diff --git a/src/primaite/config/_package_data/scenario_with_placeholders/greens_1.yaml b/src/primaite/config/_package_data/scenario_with_placeholders/greens_1.yaml index 98d2392a..ce670f5f 100644 --- a/src/primaite/config/_package_data/scenario_with_placeholders/greens_1.yaml +++ b/src/primaite/config/_package_data/scenario_with_placeholders/greens_1.yaml @@ -8,14 +8,6 @@ agents: &greens 1: 0.8 observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client - applications: - - application_name: DatabaseClient action_map: 0: action: DONOTHING diff --git a/src/primaite/config/_package_data/scenario_with_placeholders/greens_2.yaml b/src/primaite/config/_package_data/scenario_with_placeholders/greens_2.yaml index 17a5977b..9ff099dd 100644 --- a/src/primaite/config/_package_data/scenario_with_placeholders/greens_2.yaml +++ b/src/primaite/config/_package_data/scenario_with_placeholders/greens_2.yaml @@ -8,14 +8,6 @@ agents: &greens 1: 0.05 observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client - applications: - - application_name: DatabaseClient action_map: 0: action: DONOTHING diff --git a/src/primaite/config/_package_data/scenario_with_placeholders/reds_1.yaml b/src/primaite/config/_package_data/scenario_with_placeholders/reds_1.yaml index b775cb24..b7e7560d 100644 --- a/src/primaite/config/_package_data/scenario_with_placeholders/reds_1.yaml +++ b/src/primaite/config/_package_data/scenario_with_placeholders/reds_1.yaml @@ -6,14 +6,6 @@ reds: &reds observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client - applications: - - application_name: DataManipulationBot reward_function: reward_components: diff --git a/src/primaite/config/_package_data/scenario_with_placeholders/reds_2.yaml b/src/primaite/config/_package_data/scenario_with_placeholders/reds_2.yaml index 4cae1ec6..1d9012d7 100644 --- a/src/primaite/config/_package_data/scenario_with_placeholders/reds_2.yaml +++ b/src/primaite/config/_package_data/scenario_with_placeholders/reds_2.yaml @@ -6,14 +6,6 @@ reds: &reds observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client - applications: - - application_name: DataManipulationBot reward_function: reward_components: diff --git a/src/primaite/config/_package_data/scenario_with_placeholders/scenario.yaml b/src/primaite/config/_package_data/scenario_with_placeholders/scenario.yaml index 8c83bf79..0223beb6 100644 --- a/src/primaite/config/_package_data/scenario_with_placeholders/scenario.yaml +++ b/src/primaite/config/_package_data/scenario_with_placeholders/scenario.yaml @@ -54,12 +54,6 @@ agents: - server:eth-1<->switch_1:eth-2 action_space: - action_list: - - type: do_nothing - - type: node_shutdown - - type: node_startup - - type: host_nic_enable - - type: host_nic_enable action_map: 0: action: do_nothing @@ -100,19 +94,6 @@ agents: options: node_name: server nic_id: 0 - options: - nodes: - - node_name: client - - node_name: server - - max_folders_per_node: 0 - max_files_per_folder: 0 - max_services_per_node: 0 - max_nics_per_node: 1 - max_acl_rules: 0 - ip_list: - - 192.168.1.2 - - 192.168.1.3 reward_function: reward_components: diff --git a/src/primaite/game/agent/actions/manager.py b/src/primaite/game/agent/actions/manager.py index c3e14379..400d30e4 100644 --- a/src/primaite/game/agent/actions/manager.py +++ b/src/primaite/game/agent/actions/manager.py @@ -13,7 +13,7 @@ agents: from __future__ import annotations -from typing import Dict, List, Optional, Tuple +from typing import Dict, Optional, Tuple from gymnasium import spaces @@ -41,31 +41,12 @@ class DoNothingAction(AbstractAction, identifier="do_nothing"): class ActionManager: """Class which manages the action space for an agent.""" - def __init__( - self, - actions: List[Dict], # stores list of actions available to agent - nodes: List[Dict], # extra configuration for each node - act_map: Optional[ - Dict[int, Dict] - ] = None, # allows restricting set of possible actions - TODO: Refactor to be a list? - *args, - **kwargs, - ) -> None: + def __init__(self, act_map: Optional[Dict[int, Dict]] = None) -> None: """Init method for ActionManager. - :param game: Reference to the game to which the agent belongs. - :type game: PrimaiteGame - :param actions: List of action specs which should be made available to the agent. The keys of each spec are: - 'type' and 'options' for passing any options to the action class's init method - :type actions: List[dict] :param act_map: Action map which maps integers to actions. Used for restricting the set of possible actions. :type act_map: Optional[Dict[int, Dict]] """ - self.actions: Dict[str, AbstractAction] = {} - for act_spec in actions: - act_type = act_spec.get("type") - self.actions[act_type] = AbstractAction._registry[act_type] - self.action_map: Dict[int, Tuple[str, Dict]] = {} """ Action mapping that converts an integer to a specific action and parameter choice. @@ -73,6 +54,7 @@ class ActionManager: For example : {0: ("node_service_scan", {node_name:"client_1", service_name:"WebBrowser"})} """ + # allows restricting set of possible actions - TODO: Refactor to be a list? if act_map is None: # raise RuntimeError("Action map must be specified in the config file.") pass @@ -100,39 +82,17 @@ class ActionManager: return spaces.Discrete(len(self.action_map)) @classmethod - def from_config(cls, game: "PrimaiteGame", cfg: Dict) -> "ActionManager": # noqa: F821 + def from_config(cls, cfg: Dict) -> "ActionManager": """ - Construct an ActionManager from a config definition. + Construct an ActionManager from a config dictionary. - The action space config supports the following three sections: - 1. ``action_list`` - ``action_list`` contains a list action components which need to be included in the action space. - Each action component has a ``type`` which maps to a subclass of AbstractAction, and additional options - which will be passed to the action class's __init__ method during initialisation. - 2. ``action_map`` - Since the agent uses a discrete action space which acts as a flattened version of the component-based - action space, action_map provides a mapping between an integer (chosen by the agent) and a meaningful - action and values of parameters. For example action 0 can correspond to do nothing, action 1 can - correspond to "node_service_scan" with ``node_name="server"`` and - ``service_name="WebBrowser"``, action 2 can be " - 3. ``options`` - ``options`` contains a dictionary of options which are passed to the ActionManager's __init__ method. - These options are used to calculate the shape of the action space, and to provide additional information - to the ActionManager which is required to convert the agent's action choice into a CAOS request. + The action space config supports must contain the following key: + ``action_map`` - List of actions available to the agent, formatted as a dictionary where the key is the + action number between 0 - N, and the value is the CAOS-formatted action. - :param game: The Primaite Game to which the agent belongs. - :type game: PrimaiteGame :param cfg: The action space config. :type cfg: Dict :return: The constructed ActionManager. :rtype: ActionManager """ - obj = cls( - actions=cfg["action_list"], - **cfg["options"], - protocols=game.options.protocols, - ports=game.options.ports, - act_map=cfg.get("action_map"), - ) - - return obj + return cls(**cfg.get("options", {}), act_map=cfg.get("action_map")) diff --git a/src/primaite/game/agent/interface.py b/src/primaite/game/agent/interface.py index ec9d6c61..9d8f3f63 100644 --- a/src/primaite/game/agent/interface.py +++ b/src/primaite/game/agent/interface.py @@ -93,8 +93,8 @@ class AbstractAgent(BaseModel): return ValueError(f"Invalid Agent Type: {config['type']}") obj = cls( config=cls.ConfigSchema(**config["agent_settings"]), - action_manager=ActionManager.from_config(config["game"], config["action_manager"]), - observation_manager=ObservationManager.from_config(config["observation_manager"]), + action_manager=ActionManager.from_config(config["action_space"]), + observation_manager=ObservationManager.from_config(config["observation_space"]), reward_function=RewardFunction.from_config(config["reward_function"]), ) return obj diff --git a/src/primaite/game/game.py b/src/primaite/game/game.py index bf480d0e..5220e874 100644 --- a/src/primaite/game/game.py +++ b/src/primaite/game/game.py @@ -534,8 +534,8 @@ class PrimaiteGame: agent_config = { "type": agent_type, - "action_manager": action_space_cfg, - "observation_manager": observation_space_cfg, + "action_space": action_space_cfg, + "observation_space": observation_space_cfg, "reward_function": reward_function_cfg, "agent_settings": agent_settings, "game": game, diff --git a/src/primaite/notebooks/Command-and-Control-E2E-Demonstration.ipynb b/src/primaite/notebooks/Command-and-Control-E2E-Demonstration.ipynb index d2972fa9..1a5c8b87 100644 --- a/src/primaite/notebooks/Command-and-Control-E2E-Demonstration.ipynb +++ b/src/primaite/notebooks/Command-and-Control-E2E-Demonstration.ipynb @@ -53,22 +53,13 @@ " type: ProxyAgent\n", " observation_space: null\n", " action_space:\n", - " action_list:\n", - " - type: DONOTHING\n", - " - type: NODE_APPLICATION_INSTALL\n", - " - type: NODE_APPLICATION_EXECUTE\n", - " - type: CONFIGURE_C2_BEACON\n", - " - type: C2_SERVER_RANSOMWARE_LAUNCH\n", - " - type: C2_SERVER_RANSOMWARE_CONFIGURE\n", - " - type: C2_SERVER_TERMINAL_COMMAND\n", - " - type: C2_SERVER_DATA_EXFILTRATE\n", " options:\n", " nodes:\n", " - node_name: web_server\n", - " applications: \n", + " applications:\n", " - application_name: C2Beacon\n", " - node_name: client_1\n", - " applications: \n", + " applications:\n", " - application_name: C2Server\n", " max_folders_per_node: 1\n", " max_files_per_folder: 1\n", @@ -102,7 +93,7 @@ " action: NODE_APPLICATION_EXECUTE\n", " options:\n", " node_id: 0\n", - " application_id: 0 \n", + " application_id: 0\n", " 4:\n", " action: C2_SERVER_TERMINAL_COMMAND\n", " options:\n", @@ -112,7 +103,7 @@ " username: admin\n", " password: admin\n", " commands:\n", - " - \n", + " -\n", " - software_manager\n", " - application\n", " - install\n", @@ -134,7 +125,7 @@ " target_ip_address: 192.168.1.14\n", " account:\n", " username: admin\n", - " password: admin \n", + " password: admin\n", "\n", " 7:\n", " action: C2_SERVER_RANSOMWARE_LAUNCH\n", @@ -177,7 +168,7 @@ " # removing all agents & adding the custom agent.\n", " cfg['agents'] = {}\n", " cfg['agents'] = c2_agent_yaml\n", - " \n", + "\n", "\n", "env = PrimaiteGymEnv(env_config=cfg)" ] @@ -230,10 +221,6 @@ "\n", "```yaml\n", " action_space:\n", - " action_list:\n", - " ...\n", - " - type: NODE_APPLICATION_INSTALL\n", - " ...\n", " options:\n", " nodes: # Node List\n", " - node_name: web_server\n", @@ -273,10 +260,6 @@ "\n", "```yaml\n", " action_space:\n", - " action_list:\n", - " ...\n", - " - type: CONFIGURE_C2_BEACON\n", - " ...\n", " options:\n", " nodes: # Node List\n", " - node_name: web_server\n", @@ -320,10 +303,6 @@ "\n", "```yaml\n", " action_space:\n", - " action_list:\n", - " ...\n", - " - type: NODE_APPLICATION_EXECUTE\n", - " ...\n", " options:\n", " nodes: # Node List\n", " - node_name: web_server\n", @@ -347,7 +326,7 @@ "metadata": {}, "outputs": [], "source": [ - "env.step(3) " + "env.step(3)" ] }, { @@ -390,10 +369,6 @@ "\n", "``` yaml\n", " action_space:\n", - " action_list:\n", - " ...\n", - " - type: C2_SERVER_TERMINAL_COMMAND\n", - " ...\n", " options:\n", " nodes: # Node List\n", " ...\n", @@ -451,10 +426,6 @@ "\n", "``` yaml\n", " action_space:\n", - " action_list:\n", - " ...\n", - " - type: C2_SERVER_RANSOMWARE_CONFIGURE\n", - " ...\n", " options:\n", " nodes: # Node List\n", " ...\n", @@ -507,10 +478,6 @@ "\n", "``` yaml\n", " action_space:\n", - " action_list:\n", - " ...\n", - " - type: C2_SERVER_DATA_EXFILTRATE\n", - " ...\n", " options:\n", " nodes: # Node List\n", " ...\n", @@ -577,10 +544,6 @@ "\n", "``` yaml\n", " action_space:\n", - " action_list:\n", - " ...\n", - " - type: C2_SERVER_RANSOMWARE_LAUNCH\n", - " ...\n", " options:\n", " nodes: # Node List\n", " ...\n", @@ -632,7 +595,7 @@ "metadata": {}, "outputs": [], "source": [ - "custom_blue_agent_yaml = \"\"\" \n", + "custom_blue_agent_yaml = \"\"\"\n", " - ref: defender\n", " team: BLUE\n", " type: ProxyAgent\n", @@ -715,13 +678,8 @@ " - type: \"NONE\"\n", " label: ICS\n", " options: {}\n", - " \n", + "\n", " action_space:\n", - " action_list:\n", - " - type: NODE_APPLICATION_REMOVE\n", - " - type: NODE_SHUTDOWN\n", - " - type: ROUTER_ACL_ADDRULE\n", - " - type: DONOTHING\n", " action_map:\n", " 0:\n", " action: DONOTHING\n", @@ -747,7 +705,7 @@ " dest_port_id: 2\n", " protocol_id: 1\n", " source_wildcard_id: 0\n", - " dest_wildcard_id: 0 \n", + " dest_wildcard_id: 0\n", "\n", "\n", " options:\n", @@ -796,7 +754,7 @@ " # removing all agents & adding the custom agent.\n", " cfg['agents'] = {}\n", " cfg['agents'] = custom_blue\n", - " \n", + "\n", "\n", "blue_env = PrimaiteGymEnv(env_config=cfg)" ] @@ -1468,7 +1426,7 @@ " # removing all agents & adding the custom agent.\n", " cfg['agents'] = {}\n", " cfg['agents'] = c2_agent_yaml\n", - " \n", + "\n", "\n", "c2_config_env = PrimaiteGymEnv(env_config=cfg)" ] @@ -1555,7 +1513,7 @@ "source": [ "for i in range(6):\n", " env.step(0)\n", - " \n", + "\n", "c2_server_1.show()" ] }, @@ -1676,7 +1634,7 @@ "metadata": {}, "outputs": [], "source": [ - "# Comparing the OBS of the default frequency to a timestep frequency of 1 \n", + "# Comparing the OBS of the default frequency to a timestep frequency of 1\n", "for i in range(2):\n", " keep_alive_obs, _, _, _, _ = blue_config_env.step(0)\n", " display_obs_diffs(default_obs, keep_alive_obs, blue_config_env.game.step_counter)" @@ -1760,7 +1718,7 @@ "metadata": {}, "outputs": [], "source": [ - "# Capturing default C2 Traffic \n", + "# Capturing default C2 Traffic\n", "for i in range(3):\n", " tcp_c2_obs, _, _, _, _ = blue_config_env.step(0)\n", "\n", diff --git a/src/primaite/notebooks/Data-Manipulation-Customising-Red-Agent.ipynb b/src/primaite/notebooks/Data-Manipulation-Customising-Red-Agent.ipynb index 07881131..50bfa59f 100644 --- a/src/primaite/notebooks/Data-Manipulation-Customising-Red-Agent.ipynb +++ b/src/primaite/notebooks/Data-Manipulation-Customising-Red-Agent.ipynb @@ -147,12 +147,7 @@ " nodes: {}\n", "\n", " action_space:\n", - "\n", - " # The agent has two action choices, either do nothing, or execute a pre-scripted attack by using \n", - " action_list:\n", - " - type: DONOTHING\n", - " - type: NODE_APPLICATION_EXECUTE\n", - "\n", + " \n", " # The agent has access to the DataManipulationBoth on clients 1 and 2.\n", " options:\n", " nodes:\n", @@ -306,19 +301,9 @@ "outputs": [], "source": [ "change = yaml.safe_load(\"\"\"\n", - "action_space:\n", - " action_list:\n", - " - type: DONOTHING\n", - " - type: NODE_APPLICATION_EXECUTE\n", - " options:\n", - " nodes:\n", - " - node_name: client_1\n", - " applications:\n", - " - application_name: DataManipulationBot\n", - " max_folders_per_node: 1\n", - " max_files_per_folder: 1\n", - " max_services_per_node: 1\n", + "# TODO:\n", "\"\"\")\n", + "#TODO 2869 fix\n", "\n", "with open(data_manipulation_config_path(), 'r') as f:\n", " cfg = yaml.safe_load(f)\n", diff --git a/tests/assets/configs/action_penalty.yaml b/tests/assets/configs/action_penalty.yaml index 1771ba5f..2ebe1963 100644 --- a/tests/assets/configs/action_penalty.yaml +++ b/tests/assets/configs/action_penalty.yaml @@ -96,35 +96,6 @@ agents: options: {} action_space: - action_list: - - type: DONOTHING - - type: NODE_SERVICE_SCAN - - type: NODE_SERVICE_STOP - - type: NODE_SERVICE_START - - type: NODE_SERVICE_PAUSE - - type: NODE_SERVICE_RESUME - - type: NODE_SERVICE_RESTART - - type: NODE_SERVICE_DISABLE - - type: NODE_SERVICE_ENABLE - - type: NODE_SERVICE_FIX - - type: NODE_FILE_SCAN - - type: NODE_FILE_CHECKHASH - - type: NODE_FILE_DELETE - - type: NODE_FILE_REPAIR - - type: NODE_FILE_RESTORE - - type: NODE_FOLDER_SCAN - - type: NODE_FOLDER_CHECKHASH - - type: NODE_FOLDER_REPAIR - - type: NODE_FOLDER_RESTORE - - type: NODE_OS_SCAN - - type: NODE_SHUTDOWN - - type: NODE_STARTUP - - type: NODE_RESET - - type: ROUTER_ACL_ADDRULE - - type: ROUTER_ACL_REMOVERULE - - type: HOST_NIC_ENABLE - - type: HOST_NIC_DISABLE - action_map: 0: action: DONOTHING @@ -543,44 +514,6 @@ agents: node_id: 6 nic_id: 0 - - - options: - nodes: - - node_name: domain_controller - - node_name: web_server - applications: - - application_name: DatabaseClient - services: - - service_name: WebServer - - node_name: database_server - folders: - - folder_name: database - files: - - file_name: database.db - services: - - service_name: DatabaseService - - node_name: backup_server - - node_name: security_suite - - node_name: client_1 - - node_name: client_2 - - max_folders_per_node: 2 - max_files_per_folder: 2 - max_services_per_node: 2 - max_nics_per_node: 8 - max_acl_rules: 10 - ip_list: - - 192.168.1.10 - - 192.168.1.12 - - 192.168.1.14 - - 192.168.1.16 - - 192.168.1.110 - - 192.168.10.21 - - 192.168.10.22 - - 192.168.10.110 - - reward_function: reward_components: - type: ACTION_PENALTY diff --git a/tests/assets/configs/bad_primaite_session.yaml b/tests/assets/configs/bad_primaite_session.yaml index 6a19c2fb..9f3e6da5 100644 --- a/tests/assets/configs/bad_primaite_session.yaml +++ b/tests/assets/configs/bad_primaite_session.yaml @@ -15,16 +15,6 @@ agents: type: ProbabilisticAgent observation_space: null action_space: - action_list: - - type: DONOTHING - options: - nodes: - - node_name: client_2 - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_nics_per_node: 2 - max_acl_rules: 10 reward_function: reward_components: @@ -42,20 +32,6 @@ agents: observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - - type: NODE_FILE_DELETE - - type: NODE_FILE_CORRUPT - - type: NODE_OS_SCAN - options: - nodes: - - node_name: client_1 - applications: - - application_name: DataManipulationBot - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 reward_function: reward_components: @@ -140,34 +116,6 @@ agents: options: {} action_space: - action_list: - - type: DONOTHING - - type: NODE_SERVICE_SCAN - - type: NODE_SERVICE_STOP - - type: NODE_SERVICE_START - - type: NODE_SERVICE_PAUSE - - type: NODE_SERVICE_RESUME - - type: NODE_SERVICE_RESTART - - type: NODE_SERVICE_DISABLE - - type: NODE_SERVICE_ENABLE - - type: NODE_SERVICE_FIX - - type: NODE_FILE_SCAN - - type: NODE_FILE_CHECKHASH - - type: NODE_FILE_DELETE - - type: NODE_FILE_REPAIR - - type: NODE_FILE_RESTORE - - type: NODE_FOLDER_SCAN - - type: NODE_FOLDER_CHECKHASH - - type: NODE_FOLDER_REPAIR - - type: NODE_FOLDER_RESTORE - - type: NODE_OS_SCAN - - type: NODE_SHUTDOWN - - type: NODE_STARTUP - - type: NODE_RESET - - type: ROUTER_ACL_ADDRULE - - type: ROUTER_ACL_REMOVERULE - - type: HOST_NIC_ENABLE - - type: HOST_NIC_DISABLE action_map: 0: @@ -490,32 +438,6 @@ agents: node_id: 6 nic_id: 0 - - - options: - nodes: - - node_name: domain_controller - - node_name: web_server - - node_name: database_server - - node_name: backup_server - - node_name: security_suite - - node_name: client_1 - - node_name: client_2 - max_folders_per_node: 2 - max_files_per_folder: 2 - max_services_per_node: 2 - max_nics_per_node: 8 - max_acl_rules: 10 - ip_list: - - 192.168.1.10 - - 192.168.1.12 - - 192.168.1.14 - - 192.168.1.16 - - 192.168.1.110 - - 192.168.10.21 - - 192.168.10.22 - - 192.168.10.110 - reward_function: reward_components: - type: DATABASE_FILE_INTEGRITY diff --git a/tests/assets/configs/basic_firewall.yaml b/tests/assets/configs/basic_firewall.yaml index fe5e0099..09e070d5 100644 --- a/tests/assets/configs/basic_firewall.yaml +++ b/tests/assets/configs/basic_firewall.yaml @@ -29,9 +29,6 @@ agents: type: ProbabilisticAgent observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE action_map: 0: action: DONOTHING @@ -41,15 +38,6 @@ agents: options: node_id: 0 application_id: 0 - options: - nodes: - - node_name: client_2 - applications: - - application_name: WebBrowser - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_applications_per_node: 1 reward_function: reward_components: diff --git a/tests/assets/configs/basic_switched_network.yaml b/tests/assets/configs/basic_switched_network.yaml index 8aa97a6b..453db4b0 100644 --- a/tests/assets/configs/basic_switched_network.yaml +++ b/tests/assets/configs/basic_switched_network.yaml @@ -32,9 +32,6 @@ agents: type: ProbabilisticAgent observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE action_map: 0: action: DONOTHING @@ -44,15 +41,6 @@ agents: options: node_id: 0 application_id: 0 - options: - nodes: - - node_name: client_2 - applications: - - application_name: WebBrowser - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_applications_per_node: 1 reward_function: reward_components: @@ -125,28 +113,10 @@ agents: options: {} action_space: - action_list: - - type: DONOTHING - action_map: 0: action: DONOTHING options: {} - options: - nodes: - - node_name: switch - - node_name: client_1 - - node_name: client_2 - - node_name: client_3 - max_folders_per_node: 2 - max_files_per_folder: 2 - max_services_per_node: 2 - max_nics_per_node: 8 - max_acl_rules: 10 - ip_list: - - 192.168.10.21 - - 192.168.10.22 - - 192.168.10.23 reward_function: reward_components: diff --git a/tests/assets/configs/data_manipulation.yaml b/tests/assets/configs/data_manipulation.yaml index a2d9bb55..90d8f806 100644 --- a/tests/assets/configs/data_manipulation.yaml +++ b/tests/assets/configs/data_manipulation.yaml @@ -32,19 +32,6 @@ agents: 2: 0.1 observation_space: null action_space: - action_list: - - type: do_nothing - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client_2 - applications: - - application_name: WebBrowser - - application_name: DatabaseClient - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_applications_per_node: 2 action_map: 0: action: do_nothing @@ -81,19 +68,6 @@ agents: 2: 0.1 observation_space: null action_space: - action_list: - - type: do_nothing - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client_1 - applications: - - application_name: WebBrowser - - application_name: DatabaseClient - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_applications_per_node: 2 action_map: 0: action: do_nothing @@ -131,20 +105,6 @@ agents: observation_space: null action_space: - action_list: - - type: do_nothing - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client_1 - applications: - - application_name: DataManipulationBot - - node_name: client_2 - applications: - - application_name: DataManipulationBot - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 reward_function: reward_components: @@ -234,35 +194,6 @@ agents: options: {} action_space: - action_list: - - type: do_nothing - - type: NODE_SERVICE_SCAN - - type: NODE_SERVICE_STOP - - type: NODE_SERVICE_START - - type: NODE_SERVICE_PAUSE - - type: NODE_SERVICE_RESUME - - type: NODE_SERVICE_RESTART - - type: NODE_SERVICE_DISABLE - - type: NODE_SERVICE_ENABLE - - type: NODE_SERVICE_FIX - - type: NODE_FILE_SCAN - - type: NODE_FILE_CHECKHASH - - type: NODE_FILE_DELETE - - type: NODE_FILE_REPAIR - - type: NODE_FILE_RESTORE - - type: NODE_FOLDER_SCAN - - type: NODE_FOLDER_CHECKHASH - - type: NODE_FOLDER_REPAIR - - type: NODE_FOLDER_RESTORE - - type: NODE_OS_SCAN - - type: NODE_SHUTDOWN - - type: NODE_STARTUP - - type: NODE_RESET - - type: ROUTER_ACL_ADDRULE - - type: ROUTER_ACL_REMOVERULE - - type: HOST_NIC_ENABLE - - type: HOST_NIC_DISABLE - action_map: 0: action: do_nothing @@ -681,44 +612,6 @@ agents: node_id: 6 nic_id: 0 - - - options: - nodes: - - node_name: domain_controller - - node_name: web_server - applications: - - application_name: DatabaseClient - services: - - service_name: WebServer - - node_name: database_server - folders: - - folder_name: database - files: - - file_name: database.db - services: - - service_name: DatabaseService - - node_name: backup_server - - node_name: security_suite - - node_name: client_1 - - node_name: client_2 - - max_folders_per_node: 2 - max_files_per_folder: 2 - max_services_per_node: 2 - max_nics_per_node: 8 - max_acl_rules: 10 - ip_list: - - 192.168.1.10 - - 192.168.1.12 - - 192.168.1.14 - - 192.168.1.16 - - 192.168.1.110 - - 192.168.10.21 - - 192.168.10.22 - - 192.168.10.110 - - reward_function: reward_components: - type: DATABASE_FILE_INTEGRITY diff --git a/tests/assets/configs/dmz_network.yaml b/tests/assets/configs/dmz_network.yaml index 41a530b0..b0876768 100644 --- a/tests/assets/configs/dmz_network.yaml +++ b/tests/assets/configs/dmz_network.yaml @@ -54,9 +54,6 @@ agents: type: ProbabilisticAgent observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE action_map: 0: action: DONOTHING @@ -66,15 +63,6 @@ agents: options: node_id: 0 application_id: 0 - options: - nodes: - - node_name: client_1 - applications: - - application_name: WebBrowser - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_applications_per_node: 1 reward_function: reward_components: diff --git a/tests/assets/configs/eval_only_primaite_session.yaml b/tests/assets/configs/eval_only_primaite_session.yaml index dc0acdaa..73930e7f 100644 --- a/tests/assets/configs/eval_only_primaite_session.yaml +++ b/tests/assets/configs/eval_only_primaite_session.yaml @@ -15,20 +15,10 @@ agents: type: ProbabilisticAgent observation_space: null action_space: - action_list: - - type: DONOTHING action_map: 0: action: DONOTHING options: {} - options: - nodes: - - node_name: client_2 - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_nics_per_node: 2 - max_acl_rules: 10 reward_function: reward_components: @@ -46,12 +36,6 @@ agents: observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - - type: NODE_FILE_DELETE - - type: NODE_FILE_CORRUPT - - type: NODE_OS_SCAN action_map: 0: action: DONOTHING @@ -61,14 +45,6 @@ agents: options: node_id: 0 application_id: 0 - options: - nodes: - - node_name: client_1 - applications: - - application_name: DataManipulationBot - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 reward_function: reward_components: - type: DUMMY @@ -152,34 +128,6 @@ agents: options: {} action_space: - action_list: - - type: DONOTHING - - type: NODE_SERVICE_SCAN - - type: NODE_SERVICE_STOP - - type: NODE_SERVICE_START - - type: NODE_SERVICE_PAUSE - - type: NODE_SERVICE_RESUME - - type: NODE_SERVICE_RESTART - - type: NODE_SERVICE_DISABLE - - type: NODE_SERVICE_ENABLE - - type: NODE_SERVICE_FIX - - type: NODE_FILE_SCAN - - type: NODE_FILE_CHECKHASH - - type: NODE_FILE_DELETE - - type: NODE_FILE_REPAIR - - type: NODE_FILE_RESTORE - - type: NODE_FOLDER_SCAN - - type: NODE_FOLDER_CHECKHASH - - type: NODE_FOLDER_REPAIR - - type: NODE_FOLDER_RESTORE - - type: NODE_OS_SCAN - - type: NODE_SHUTDOWN - - type: NODE_STARTUP - - type: NODE_RESET - - type: ROUTER_ACL_ADDRULE - - type: ROUTER_ACL_REMOVERULE - - type: HOST_NIC_ENABLE - - type: HOST_NIC_DISABLE action_map: 0: @@ -502,32 +450,6 @@ agents: node_id: 6 nic_id: 0 - - - options: - nodes: - - node_name: domain_controller - - node_name: web_server - - node_name: database_server - - node_name: backup_server - - node_name: security_suite - - node_name: client_1 - - node_name: client_2 - max_folders_per_node: 2 - max_files_per_folder: 2 - max_services_per_node: 2 - max_nics_per_node: 8 - max_acl_rules: 10 - ip_list: - - 192.168.1.10 - - 192.168.1.12 - - 192.168.1.14 - - 192.168.1.16 - - 192.168.1.110 - - 192.168.10.21 - - 192.168.10.22 - - 192.168.10.110 - reward_function: reward_components: - type: DATABASE_FILE_INTEGRITY diff --git a/tests/assets/configs/extended_config.yaml b/tests/assets/configs/extended_config.yaml index fc1b72dd..f8e86d31 100644 --- a/tests/assets/configs/extended_config.yaml +++ b/tests/assets/configs/extended_config.yaml @@ -32,19 +32,6 @@ agents: 2: 0.1 observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client_2 - applications: - - application_name: WebBrowser - - application_name: DatabaseClient - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_applications_per_node: 2 action_map: 0: action: DONOTHING @@ -81,19 +68,6 @@ agents: 2: 0.1 observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client_1 - applications: - - application_name: WebBrowser - - application_name: DatabaseClient - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_applications_per_node: 2 action_map: 0: action: DONOTHING @@ -131,20 +105,6 @@ agents: observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client_1 - applications: - - application_name: DataManipulationBot - - node_name: client_2 - applications: - - application_name: DataManipulationBot - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 reward_function: reward_components: @@ -234,35 +194,6 @@ agents: options: {} action_space: - action_list: - - type: DONOTHING - - type: NODE_SERVICE_SCAN - - type: NODE_SERVICE_STOP - - type: NODE_SERVICE_START - - type: NODE_SERVICE_PAUSE - - type: NODE_SERVICE_RESUME - - type: NODE_SERVICE_RESTART - - type: NODE_SERVICE_DISABLE - - type: NODE_SERVICE_ENABLE - - type: NODE_SERVICE_FIX - - type: NODE_FILE_SCAN - - type: NODE_FILE_CHECKHASH - - type: NODE_FILE_DELETE - - type: NODE_FILE_REPAIR - - type: NODE_FILE_RESTORE - - type: NODE_FOLDER_SCAN - - type: NODE_FOLDER_CHECKHASH - - type: NODE_FOLDER_REPAIR - - type: NODE_FOLDER_RESTORE - - type: NODE_OS_SCAN - - type: NODE_SHUTDOWN - - type: NODE_STARTUP - - type: NODE_RESET - - type: ROUTER_ACL_ADDRULE - - type: ROUTER_ACL_REMOVERULE - - type: HOST_NIC_ENABLE - - type: HOST_NIC_DISABLE - action_map: 0: action: DONOTHING @@ -683,42 +614,6 @@ agents: - options: - nodes: - - node_name: domain_controller - - node_name: web_server - applications: - - application_name: DatabaseClient - services: - - service_name: WebServer - - node_name: database_server - folders: - - folder_name: database - files: - - file_name: database.db - services: - - service_name: DatabaseService - - node_name: backup_server - - node_name: security_suite - - node_name: client_1 - - node_name: client_2 - - max_folders_per_node: 2 - max_files_per_folder: 2 - max_services_per_node: 2 - max_nics_per_node: 8 - max_acl_rules: 10 - ip_list: - - 192.168.1.10 - - 192.168.1.12 - - 192.168.1.14 - - 192.168.1.16 - - 192.168.1.110 - - 192.168.10.21 - - 192.168.10.22 - - 192.168.10.110 - - reward_function: reward_components: - type: DATABASE_FILE_INTEGRITY diff --git a/tests/assets/configs/firewall_actions_network.yaml b/tests/assets/configs/firewall_actions_network.yaml index d88942a8..ceb9c924 100644 --- a/tests/assets/configs/firewall_actions_network.yaml +++ b/tests/assets/configs/firewall_actions_network.yaml @@ -95,12 +95,6 @@ agents: options: {} action_space: - action_list: - - type: do_nothing - - type: firewall_acl_add_rule - - type: firewall_acl_remove_rule - - type: network_port_disable - - type: network_port_enable action_map: 0: action: do_nothing @@ -250,20 +244,6 @@ agents: type: network_port_enable target_nodename: firewall port_id: 3 - options: - nodes: - - node_name: client_1 - - node_name: dmz_server - - node_name: external_computer - ip_list: - - 192.168.0.10 - - 192.168.10.10 - - 192.168.20.10 - max_folders_per_node: 2 - max_files_per_folder: 2 - max_services_per_node: 2 - max_nics_per_node: 8 - max_acl_rules: 10 reward_function: reward_components: - type: DUMMY diff --git a/tests/assets/configs/fix_duration_one_item.yaml b/tests/assets/configs/fix_duration_one_item.yaml index 704616f6..26ee574a 100644 --- a/tests/assets/configs/fix_duration_one_item.yaml +++ b/tests/assets/configs/fix_duration_one_item.yaml @@ -29,9 +29,6 @@ agents: type: ProbabilisticAgent observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE action_map: 0: action: DONOTHING @@ -41,15 +38,6 @@ agents: options: node_id: 0 application_id: 0 - options: - nodes: - - node_name: client_2 - applications: - - application_name: WebBrowser - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_applications_per_node: 1 reward_function: reward_components: @@ -120,28 +108,10 @@ agents: options: {} action_space: - action_list: - - type: DONOTHING - action_map: 0: action: DONOTHING options: {} - options: - nodes: - - node_name: switch - - node_name: client_1 - - node_name: client_2 - - node_name: client_3 - max_folders_per_node: 2 - max_files_per_folder: 2 - max_services_per_node: 2 - max_nics_per_node: 8 - max_acl_rules: 10 - ip_list: - - 192.168.10.21 - - 192.168.10.22 - - 192.168.10.23 reward_function: reward_components: diff --git a/tests/assets/configs/install_and_configure_apps.yaml b/tests/assets/configs/install_and_configure_apps.yaml index 18a9724b..efe4428a 100644 --- a/tests/assets/configs/install_and_configure_apps.yaml +++ b/tests/assets/configs/install_and_configure_apps.yaml @@ -20,13 +20,6 @@ agents: observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_INSTALL - - type: CONFIGURE_DATABASE_CLIENT - - type: CONFIGURE_DOSBOT - - type: CONFIGURE_RANSOMWARE_SCRIPT - - type: NODE_APPLICATION_REMOVE action_map: 0: action: DONOTHING @@ -83,12 +76,6 @@ agents: options: node_id: 1 application_name: DatabaseClient - options: - nodes: - - node_name: client_1 - - node_name: client_2 - - node_name: client_3 - ip_list: [] reward_function: reward_components: - type: DUMMY diff --git a/tests/assets/configs/multi_agent_session.yaml b/tests/assets/configs/multi_agent_session.yaml index 13cffab1..9f2cbd84 100644 --- a/tests/assets/configs/multi_agent_session.yaml +++ b/tests/assets/configs/multi_agent_session.yaml @@ -28,19 +28,6 @@ agents: 2: 0.1 observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client_2 - applications: - - application_name: WebBrowser - - application_name: DatabaseClient - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_applications_per_node: 2 action_map: 0: action: DONOTHING @@ -77,19 +64,6 @@ agents: 2: 0.1 observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client_1 - applications: - - application_name: WebBrowser - - application_name: DatabaseClient - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_applications_per_node: 2 action_map: 0: action: DONOTHING @@ -127,24 +101,6 @@ agents: observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - - type: NODE_FILE_DELETE - - type: NODE_FILE_CORRUPT - - type: NODE_OS_SCAN - options: - nodes: - - node_name: client_1 - applications: - - application_name: DataManipulationBot - - node_name: client_2 - applications: - - application_name: DataManipulationBot - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - reward_function: reward_components: - type: DUMMY @@ -228,35 +184,6 @@ agents: options: {} action_space: - action_list: - - type: DONOTHING - - type: NODE_SERVICE_SCAN - - type: NODE_SERVICE_STOP - - type: NODE_SERVICE_START - - type: NODE_SERVICE_PAUSE - - type: NODE_SERVICE_RESUME - - type: NODE_SERVICE_RESTART - - type: NODE_SERVICE_DISABLE - - type: NODE_SERVICE_ENABLE - - type: NODE_SERVICE_FIX - - type: NODE_FILE_SCAN - - type: NODE_FILE_CHECKHASH - - type: NODE_FILE_DELETE - - type: NODE_FILE_REPAIR - - type: NODE_FILE_RESTORE - - type: NODE_FOLDER_SCAN - - type: NODE_FOLDER_CHECKHASH - - type: NODE_FOLDER_REPAIR - - type: NODE_FOLDER_RESTORE - - type: NODE_OS_SCAN - - type: NODE_SHUTDOWN - - type: NODE_STARTUP - - type: NODE_RESET - - type: ROUTER_ACL_ADDRULE - - type: ROUTER_ACL_REMOVERULE - - type: HOST_NIC_ENABLE - - type: HOST_NIC_DISABLE - action_map: 0: action: DONOTHING @@ -675,43 +602,6 @@ agents: node_id: 6 nic_id: 0 - - options: - nodes: - - node_name: domain_controller - - node_name: web_server - applications: - - application_name: DatabaseClient - services: - - service_name: WebServer - - node_name: database_server - folders: - - folder_name: database - files: - - file_name: database.db - services: - - service_name: DatabaseService - - node_name: backup_server - - node_name: security_suite - - node_name: client_1 - - node_name: client_2 - - max_folders_per_node: 2 - max_files_per_folder: 2 - max_services_per_node: 2 - max_nics_per_node: 8 - max_acl_rules: 10 - ip_list: - - 192.168.1.10 - - 192.168.1.12 - - 192.168.1.14 - - 192.168.1.16 - - 192.168.1.110 - - 192.168.10.21 - - 192.168.10.22 - - 192.168.10.110 - - reward_function: reward_components: - type: DATABASE_FILE_INTEGRITY @@ -808,39 +698,6 @@ agents: options: {} action_space: - action_list: - - type: DONOTHING - - type: NODE_SERVICE_SCAN - - type: NODE_SERVICE_STOP - - type: NODE_SERVICE_START - - type: NODE_SERVICE_PAUSE - - type: NODE_SERVICE_RESUME - - type: NODE_SERVICE_RESTART - - type: NODE_SERVICE_DISABLE - - type: NODE_SERVICE_ENABLE - - type: NODE_SERVICE_FIX - - type: NODE_FILE_SCAN - - type: NODE_FILE_CHECKHASH - - type: NODE_FILE_DELETE - - type: NODE_FILE_REPAIR - - type: NODE_FILE_RESTORE - - type: NODE_FOLDER_SCAN - - type: NODE_FOLDER_CHECKHASH - - type: NODE_FOLDER_REPAIR - - type: NODE_FOLDER_RESTORE - - type: NODE_OS_SCAN - - type: NODE_SHUTDOWN - - type: NODE_STARTUP - - type: NODE_RESET - - type: ROUTER_ACL_ADDRULE - options: - target_router: router_1 - - type: ROUTER_ACL_REMOVERULE - options: - target_router: router_1 - - type: HOST_NIC_ENABLE - - type: HOST_NIC_DISABLE - action_map: 0: action: DONOTHING @@ -1260,42 +1117,6 @@ agents: nic_id: 0 - - options: - nodes: - - node_name: domain_controller - - node_name: web_server - applications: - - application_name: DatabaseClient - services: - - service_name: WebServer - - node_name: database_server - folders: - - folder_name: database - files: - - file_name: database.db - services: - - service_name: DatabaseService - - node_name: backup_server - - node_name: security_suite - - node_name: client_1 - - node_name: client_2 - - max_folders_per_node: 2 - max_files_per_folder: 2 - max_services_per_node: 2 - max_nics_per_node: 8 - max_acl_rules: 10 - ip_list: - - 192.168.1.10 - - 192.168.1.12 - - 192.168.1.14 - - 192.168.1.16 - - 192.168.1.110 - - 192.168.10.21 - - 192.168.10.22 - - 192.168.10.110 - reward_function: reward_components: - type: DATABASE_FILE_INTEGRITY diff --git a/tests/assets/configs/nmap_network_service_recon_red_agent_config.yaml b/tests/assets/configs/nmap_network_service_recon_red_agent_config.yaml index ec50ecdf..a4deff6f 100644 --- a/tests/assets/configs/nmap_network_service_recon_red_agent_config.yaml +++ b/tests/assets/configs/nmap_network_service_recon_red_agent_config.yaml @@ -24,17 +24,6 @@ agents: type: ProbabilisticAgent observation_space: null action_space: - options: - nodes: - - node_name: client_1 - applications: - - application_name: NMAP - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_applications_per_node: 1 - action_list: - - type: node_network_service_recon action_map: 0: action: node_network_service_recon diff --git a/tests/assets/configs/nmap_ping_scan_red_agent_config.yaml b/tests/assets/configs/nmap_ping_scan_red_agent_config.yaml index eb7b6752..ee6de2c5 100644 --- a/tests/assets/configs/nmap_ping_scan_red_agent_config.yaml +++ b/tests/assets/configs/nmap_ping_scan_red_agent_config.yaml @@ -24,17 +24,6 @@ agents: type: ProbabilisticAgent observation_space: null action_space: - options: - nodes: - - node_name: client_1 - applications: - - application_name: NMAP - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_applications_per_node: 1 - action_list: - - type: node_nmap_ping_scan action_map: 0: action: node_nmap_ping_scan diff --git a/tests/assets/configs/nmap_port_scan_red_agent_config.yaml b/tests/assets/configs/nmap_port_scan_red_agent_config.yaml index 15e2cb6a..47d34e52 100644 --- a/tests/assets/configs/nmap_port_scan_red_agent_config.yaml +++ b/tests/assets/configs/nmap_port_scan_red_agent_config.yaml @@ -24,17 +24,6 @@ agents: type: ProbabilisticAgent observation_space: null action_space: - options: - nodes: - - node_name: client_1 - applications: - - application_name: NMAP - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_applications_per_node: 1 - action_list: - - type: node_nmap_port_scan action_map: 0: action: node_nmap_port_scan diff --git a/tests/assets/configs/scenario_with_placeholders/greens_1.yaml b/tests/assets/configs/scenario_with_placeholders/greens_1.yaml index 98d2392a..ce670f5f 100644 --- a/tests/assets/configs/scenario_with_placeholders/greens_1.yaml +++ b/tests/assets/configs/scenario_with_placeholders/greens_1.yaml @@ -8,14 +8,6 @@ agents: &greens 1: 0.8 observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client - applications: - - application_name: DatabaseClient action_map: 0: action: DONOTHING diff --git a/tests/assets/configs/scenario_with_placeholders/greens_2.yaml b/tests/assets/configs/scenario_with_placeholders/greens_2.yaml index 17a5977b..9ff099dd 100644 --- a/tests/assets/configs/scenario_with_placeholders/greens_2.yaml +++ b/tests/assets/configs/scenario_with_placeholders/greens_2.yaml @@ -8,14 +8,6 @@ agents: &greens 1: 0.05 observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client - applications: - - application_name: DatabaseClient action_map: 0: action: DONOTHING diff --git a/tests/assets/configs/scenario_with_placeholders/reds_1.yaml b/tests/assets/configs/scenario_with_placeholders/reds_1.yaml index b775cb24..b7e7560d 100644 --- a/tests/assets/configs/scenario_with_placeholders/reds_1.yaml +++ b/tests/assets/configs/scenario_with_placeholders/reds_1.yaml @@ -6,14 +6,6 @@ reds: &reds observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client - applications: - - application_name: DataManipulationBot reward_function: reward_components: diff --git a/tests/assets/configs/scenario_with_placeholders/reds_2.yaml b/tests/assets/configs/scenario_with_placeholders/reds_2.yaml index 4cae1ec6..1d9012d7 100644 --- a/tests/assets/configs/scenario_with_placeholders/reds_2.yaml +++ b/tests/assets/configs/scenario_with_placeholders/reds_2.yaml @@ -6,14 +6,6 @@ reds: &reds observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client - applications: - - application_name: DataManipulationBot reward_function: reward_components: diff --git a/tests/assets/configs/scenario_with_placeholders/scenario.yaml b/tests/assets/configs/scenario_with_placeholders/scenario.yaml index ef930a1a..a61af830 100644 --- a/tests/assets/configs/scenario_with_placeholders/scenario.yaml +++ b/tests/assets/configs/scenario_with_placeholders/scenario.yaml @@ -54,12 +54,6 @@ agents: - server:eth-1<->switch_1:eth-2 action_space: - action_list: - - type: DONOTHING - - type: NODE_SHUTDOWN - - type: NODE_STARTUP - - type: HOST_NIC_ENABLE - - type: HOST_NIC_DISABLE action_map: 0: action: DONOTHING @@ -100,19 +94,6 @@ agents: options: node_id: 1 nic_id: 0 - options: - nodes: - - node_name: client - - node_name: server - - max_folders_per_node: 0 - max_files_per_folder: 0 - max_services_per_node: 0 - max_nics_per_node: 1 - max_acl_rules: 0 - ip_list: - - 192.168.1.2 - - 192.168.1.3 reward_function: reward_components: diff --git a/tests/assets/configs/shared_rewards.yaml b/tests/assets/configs/shared_rewards.yaml index 3ba480ea..60e22366 100644 --- a/tests/assets/configs/shared_rewards.yaml +++ b/tests/assets/configs/shared_rewards.yaml @@ -31,19 +31,6 @@ agents: 2: 0.1 observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client_2 - applications: - - application_name: WebBrowser - - application_name: DatabaseClient - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_applications_per_node: 2 action_map: 0: action: DONOTHING @@ -80,19 +67,6 @@ agents: 2: 0.1 observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client_1 - applications: - - application_name: WebBrowser - - application_name: DatabaseClient - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_applications_per_node: 2 action_map: 0: action: DONOTHING @@ -126,20 +100,6 @@ agents: observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client_1 - applications: - - application_name: DataManipulationBot - - node_name: client_2 - applications: - - application_name: DataManipulationBot - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 reward_function: reward_components: @@ -224,35 +184,6 @@ agents: options: {} action_space: - action_list: - - type: DONOTHING - - type: NODE_SERVICE_SCAN - - type: NODE_SERVICE_STOP - - type: NODE_SERVICE_START - - type: NODE_SERVICE_PAUSE - - type: NODE_SERVICE_RESUME - - type: NODE_SERVICE_RESTART - - type: NODE_SERVICE_DISABLE - - type: NODE_SERVICE_ENABLE - - type: NODE_SERVICE_FIX - - type: NODE_FILE_SCAN - - type: NODE_FILE_CHECKHASH - - type: NODE_FILE_DELETE - - type: NODE_FILE_REPAIR - - type: NODE_FILE_RESTORE - - type: NODE_FOLDER_SCAN - - type: NODE_FOLDER_CHECKHASH - - type: NODE_FOLDER_REPAIR - - type: NODE_FOLDER_RESTORE - - type: NODE_OS_SCAN - - type: NODE_SHUTDOWN - - type: NODE_STARTUP - - type: NODE_RESET - - type: ROUTER_ACL_ADDRULE - - type: ROUTER_ACL_REMOVERULE - - type: HOST_NIC_ENABLE - - type: HOST_NIC_DISABLE - action_map: 0: action: DONOTHING @@ -671,44 +602,6 @@ agents: node_id: 6 nic_id: 0 - - - options: - nodes: - - node_name: domain_controller - - node_name: web_server - applications: - - application_name: DatabaseClient - services: - - service_name: WebServer - - node_name: database_server - folders: - - folder_name: database - files: - - file_name: database.db - services: - - service_name: DatabaseService - - node_name: backup_server - - node_name: security_suite - - node_name: client_1 - - node_name: client_2 - - max_folders_per_node: 2 - max_files_per_folder: 2 - max_services_per_node: 2 - max_nics_per_node: 8 - max_acl_rules: 10 - ip_list: - - 192.168.1.10 - - 192.168.1.12 - - 192.168.1.14 - - 192.168.1.16 - - 192.168.1.110 - - 192.168.10.21 - - 192.168.10.22 - - 192.168.10.110 - - reward_function: reward_components: - type: SHARED_REWARD diff --git a/tests/assets/configs/software_fix_duration.yaml b/tests/assets/configs/software_fix_duration.yaml index d57b88dd..006328ba 100644 --- a/tests/assets/configs/software_fix_duration.yaml +++ b/tests/assets/configs/software_fix_duration.yaml @@ -29,9 +29,6 @@ agents: type: ProbabilisticAgent observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE action_map: 0: action: DONOTHING @@ -41,15 +38,6 @@ agents: options: node_id: 0 application_id: 0 - options: - nodes: - - node_name: client_2 - applications: - - application_name: WebBrowser - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_applications_per_node: 1 reward_function: reward_components: @@ -120,28 +108,10 @@ agents: options: {} action_space: - action_list: - - type: DONOTHING - action_map: 0: action: DONOTHING options: {} - options: - nodes: - - node_name: switch - - node_name: client_1 - - node_name: client_2 - - node_name: client_3 - max_folders_per_node: 2 - max_files_per_folder: 2 - max_services_per_node: 2 - max_nics_per_node: 8 - max_acl_rules: 10 - ip_list: - - 192.168.10.21 - - 192.168.10.22 - - 192.168.10.23 reward_function: reward_components: diff --git a/tests/assets/configs/test_application_install.yaml b/tests/assets/configs/test_application_install.yaml index e8b080b7..c085fd63 100644 --- a/tests/assets/configs/test_application_install.yaml +++ b/tests/assets/configs/test_application_install.yaml @@ -31,9 +31,6 @@ agents: 2: 0.1 observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE options: nodes: - node_name: client_2 @@ -80,9 +77,6 @@ agents: 2: 0.1 observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE options: nodes: - node_name: client_1 @@ -130,20 +124,7 @@ agents: observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - options: - nodes: - - node_name: client_1 - applications: - - application_name: DataManipulationBot - - node_name: client_2 - applications: - - application_name: DataManipulationBot - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 + action_map: reward_function: reward_components: @@ -228,39 +209,6 @@ agents: options: {} action_space: - action_list: - - type: DONOTHING - - type: NODE_SERVICE_SCAN - - type: NODE_SERVICE_STOP - - type: NODE_SERVICE_START - - type: NODE_SERVICE_PAUSE - - type: NODE_SERVICE_RESUME - - type: NODE_SERVICE_RESTART - - type: NODE_SERVICE_DISABLE - - type: NODE_SERVICE_ENABLE - - type: NODE_SERVICE_FIX - - type: NODE_FILE_SCAN - - type: NODE_FILE_CHECKHASH - - type: NODE_FILE_DELETE - - type: NODE_FILE_REPAIR - - type: NODE_FILE_RESTORE - - type: NODE_FOLDER_SCAN - - type: NODE_FOLDER_CHECKHASH - - type: NODE_FOLDER_REPAIR - - type: NODE_FOLDER_RESTORE - - type: NODE_OS_SCAN - - type: NODE_SHUTDOWN - - type: NODE_STARTUP - - type: NODE_RESET - - type: ROUTER_ACL_ADDRULE - - type: ROUTER_ACL_REMOVERULE - - type: HOST_NIC_ENABLE - - type: HOST_NIC_DISABLE - - type: NODE_APPLICATION_INSTALL - - type: NODE_APPLICATION_REMOVE - - type: NODE_APPLICATION_EXECUTE - - type: CONFIGURE_DOSBOT - action_map: 0: action: DONOTHING @@ -706,47 +654,6 @@ agents: target_ip_address: 192.168.1.14 target_port: POSTGRES_SERVER - - - - options: - nodes: - - node_name: domain_controller - applications: - - application_name: DoSBot - - node_name: web_server - applications: - - application_name: DatabaseClient - services: - - service_name: WebServer - - node_name: database_server - folders: - - folder_name: database - files: - - file_name: database.db - services: - - service_name: DatabaseService - - node_name: backup_server - - node_name: security_suite - - node_name: client_1 - - node_name: client_2 - - max_folders_per_node: 2 - max_files_per_folder: 2 - max_services_per_node: 2 - max_nics_per_node: 8 - max_acl_rules: 10 - ip_list: - - 192.168.1.10 - - 192.168.1.12 - - 192.168.1.14 - - 192.168.1.16 - - 192.168.1.110 - - 192.168.10.21 - - 192.168.10.22 - - 192.168.10.110 - - reward_function: reward_components: - type: DATABASE_FILE_INTEGRITY diff --git a/tests/assets/configs/test_primaite_session.yaml b/tests/assets/configs/test_primaite_session.yaml index c59bbcbf..8c22fbed 100644 --- a/tests/assets/configs/test_primaite_session.yaml +++ b/tests/assets/configs/test_primaite_session.yaml @@ -23,21 +23,10 @@ agents: type: ProbabilisticAgent observation_space: null action_space: - action_list: - - type: DONOTHING action_map: 0: action: DONOTHING options: {} - options: - nodes: - - node_name: client_2 - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 - max_nics_per_node: 2 - max_acl_rules: 10 - reward_function: reward_components: - type: DUMMY @@ -56,12 +45,6 @@ agents: observation_space: null action_space: - action_list: - - type: DONOTHING - - type: NODE_APPLICATION_EXECUTE - - type: NODE_FILE_DELETE - - type: NODE_FILE_CORRUPT - - type: NODE_OS_SCAN action_map: 0: action: DONOTHING @@ -71,14 +54,6 @@ agents: options: node_id: 0 application_id: 0 - options: - nodes: - - node_name: client_1 - applications: - - application_name: DataManipulationBot - max_folders_per_node: 1 - max_files_per_folder: 1 - max_services_per_node: 1 reward_function: reward_components: @@ -163,35 +138,6 @@ agents: options: {} action_space: - action_list: - - type: DONOTHING - - type: NODE_SERVICE_SCAN - - type: NODE_SERVICE_STOP - - type: NODE_SERVICE_START - - type: NODE_SERVICE_PAUSE - - type: NODE_SERVICE_RESUME - - type: NODE_SERVICE_RESTART - - type: NODE_SERVICE_DISABLE - - type: NODE_SERVICE_ENABLE - - type: NODE_SERVICE_FIX - - type: NODE_FILE_SCAN - - type: NODE_FILE_CHECKHASH - - type: NODE_FILE_DELETE - - type: NODE_FILE_REPAIR - - type: NODE_FILE_RESTORE - - type: NODE_FOLDER_SCAN - - type: NODE_FOLDER_CHECKHASH - - type: NODE_FOLDER_REPAIR - - type: NODE_FOLDER_RESTORE - - type: NODE_OS_SCAN - - type: NODE_SHUTDOWN - - type: NODE_STARTUP - - type: NODE_RESET - - type: ROUTER_ACL_ADDRULE - - type: ROUTER_ACL_REMOVERULE - - type: HOST_NIC_ENABLE - - type: HOST_NIC_DISABLE - action_map: 0: action: DONOTHING @@ -513,42 +459,6 @@ agents: node_id: 6 nic_id: 0 - - options: - nodes: - - node_name: domain_controller - - node_name: web_server - applications: - - application_name: DatabaseClient - services: - - service_name: WebServer - - node_name: database_server - folders: - - folder_name: database - files: - - file_name: database.db - services: - - service_name: DatabaseService - - node_name: backup_server - - node_name: security_suite - - node_name: client_1 - - node_name: client_2 - - max_folders_per_node: 2 - max_files_per_folder: 2 - max_services_per_node: 2 - max_nics_per_node: 8 - max_acl_rules: 10 - ip_list: - - 192.168.1.10 - - 192.168.1.12 - - 192.168.1.14 - - 192.168.1.16 - - 192.168.1.110 - - 192.168.10.21 - - 192.168.10.22 - - 192.168.10.110 - reward_function: reward_components: - type: DATABASE_FILE_INTEGRITY diff --git a/tests/unit_tests/_primaite/_game/_agent/test_actions.py b/tests/unit_tests/_primaite/_game/_agent/test_actions.py index 79cf7e4b..cb2bb7a2 100644 --- a/tests/unit_tests/_primaite/_game/_agent/test_actions.py +++ b/tests/unit_tests/_primaite/_game/_agent/test_actions.py @@ -3,9 +3,7 @@ from unittest.mock import Mock import pytest -from primaite.game.agent.actions import ( # DoNothingAction,; NodeServiceDisableAction,; NodeServiceEnableAction,; NodeServicePauseAction,; NodeServiceRestartAction,; NodeServiceResumeAction,; NodeServiceScanAction,; NodeServiceStartAction,; NodeServiceStopAction, - ActionManager, -) +from primaite.game.agent.actions import ActionManager from primaite.game.agent.actions.manager import DoNothingAction from primaite.game.agent.actions.service import ( NodeServiceDisableAction, diff --git a/tests/unit_tests/_primaite/_game/_agent/test_probabilistic_agent.py b/tests/unit_tests/_primaite/_game/_agent/test_probabilistic_agent.py index 7824e71e..94a77a10 100644 --- a/tests/unit_tests/_primaite/_game/_agent/test_probabilistic_agent.py +++ b/tests/unit_tests/_primaite/_game/_agent/test_probabilistic_agent.py @@ -27,26 +27,6 @@ def test_probabilistic_agent(): MAX_NODE_FILE_DELETE = 6250 action_space_cfg = { - "action_list": [ - {"type": "do_nothing"}, - {"type": "node_application_execute"}, - {"type": "node_file_delete"}, - ], - "nodes": [ - { - "node_name": "client_1", - "applications": [{"application_name": "WebBrowser"}], - "folders": [{"folder_name": "downloads", "files": [{"file_name": "cat.png"}]}], - }, - ], - "max_folders_per_node": 2, - "max_files_per_folder": 2, - "max_services_per_node": 2, - "max_applications_per_node": 2, - "max_nics_per_node": 2, - "max_acl_rules": 10, - "protocols": ["TCP", "UDP", "ICMP"], - "ports": ["HTTP", "DNS", "ARP"], "act_map": { 0: {"action": "do_nothing", "options": {}}, 1: {"action": "node_application_execute", "options": {"node_id": 0, "application_id": 0}}, @@ -65,8 +45,8 @@ def test_probabilistic_agent(): pa_config = { "type": "ProbabilisticAgent", "game": game, - "action_manager": action_space_cfg, - "observation_manager": observation_space_cfg, + "action_space": action_space_cfg, + "observation_space": observation_space_cfg, "reward_function": reward_function_cfg, "agent_settings": { "action_probabilities": {0: P_DO_NOTHING, 1: P_NODE_APPLICATION_EXECUTE, 2: P_NODE_FILE_DELETE},