diff --git a/docs/source/config.rst b/docs/source/config.rst index 74898ec1..fa58e6cf 100644 --- a/docs/source/config.rst +++ b/docs/source/config.rst @@ -28,6 +28,10 @@ The environment config file consists of the following attributes: * STABLE_BASELINES3_PPO - Use a SB3 PPO agent * STABLE_BASELINES3_A2C - use a SB3 A2C agent +* **random_red_agent** [bool] + + Determines if the session should be run with a random red agent + * **action_type** [enum] Determines whether a NODE, ACL, or ANY (combined NODE & ACL) action space format is adopted for the session diff --git a/src/primaite/config/_package_data/training/training_config_main.yaml b/src/primaite/config/_package_data/training/training_config_main.yaml index 3fe668e2..8f035d41 100644 --- a/src/primaite/config/_package_data/training/training_config_main.yaml +++ b/src/primaite/config/_package_data/training/training_config_main.yaml @@ -9,7 +9,7 @@ agent_identifier: STABLE_BASELINES3_A2C # RED AGENT IDENTIFIER # RANDOM or NONE -red_agent_identifier: "NONE" +random_red_agent: False # Sets How the Action Space is defined: # "NODE" diff --git a/src/primaite/config/_package_data/training/training_config_random_red_agent.yaml b/src/primaite/config/_package_data/training/training_config_random_red_agent.yaml index 9382a2b5..3e0a3e2f 100644 --- a/src/primaite/config/_package_data/training/training_config_random_red_agent.yaml +++ b/src/primaite/config/_package_data/training/training_config_random_red_agent.yaml @@ -9,7 +9,7 @@ agent_identifier: STABLE_BASELINES3_A2C # RED AGENT IDENTIFIER # RANDOM or NONE -red_agent_identifier: "RANDOM" +random_red_agent: True # Sets How the Action Space is defined: # "NODE" diff --git a/src/primaite/config/training_config.py b/src/primaite/config/training_config.py index 6e88e7cb..7995dfe8 100644 --- a/src/primaite/config/training_config.py +++ b/src/primaite/config/training_config.py @@ -21,7 +21,7 @@ class TrainingConfig: agent_identifier: str = "STABLE_BASELINES3_A2C" "The Red Agent algo/class to be used." - red_agent_identifier: str = "RANDOM" + random_red_agent: bool = False "Creates Random Red Agent Attacks" action_type: ActionType = ActionType.ANY diff --git a/src/primaite/environment/primaite_env.py b/src/primaite/environment/primaite_env.py index eb0bc5de..5cb85afd 100644 --- a/src/primaite/environment/primaite_env.py +++ b/src/primaite/environment/primaite_env.py @@ -277,7 +277,7 @@ class Primaite(Env): self.reset_environment() # Create a random red agent to use for this episode - if self.training_config.red_agent_identifier == "RANDOM": + if self.training_config.random_red_agent: self.create_random_red_agent() # Reset counters and totals diff --git a/tests/config/random_agent_main_config.yaml b/tests/config/random_agent_main_config.yaml deleted file mode 100644 index d2d18bbc..00000000 --- a/tests/config/random_agent_main_config.yaml +++ /dev/null @@ -1,96 +0,0 @@ -# Main Config File - -# Generic config values -# Choose one of these (dependent on Agent being trained) -# "STABLE_BASELINES3_PPO" -# "STABLE_BASELINES3_A2C" -# "GENERIC" -agent_identifier: GENERIC -# -red_agent_identifier: RANDOM -# Sets How the Action Space is defined: -# "NODE" -# "ACL" -# "ANY" node and acl actions -action_type: ANY -# Number of episodes to run per session -num_episodes: 1 -# Number of time_steps per episode -num_steps: 5 -# Time delay between steps (for generic agents) -time_delay: 1 -# Type of session to be run (TRAINING or EVALUATION) -session_type: TRAINING -# Determine whether to load an agent from file -load_agent: False -# File path and file name of agent if you're loading one in -agent_load_file: C:\[Path]\[agent_saved_filename.zip] - -# Environment config values -# The high value for the observation space -observation_space_high_value: 1_000_000_000 - -# Reward values -# Generic -all_ok: 0 -# Node Hardware State -off_should_be_on: -10 -off_should_be_resetting: -5 -on_should_be_off: -2 -on_should_be_resetting: -5 -resetting_should_be_on: -5 -resetting_should_be_off: -2 -resetting: -3 -# Node Software or Service State -good_should_be_patching: 2 -good_should_be_compromised: 5 -good_should_be_overwhelmed: 5 -patching_should_be_good: -5 -patching_should_be_compromised: 2 -patching_should_be_overwhelmed: 2 -patching: -3 -compromised_should_be_good: -20 -compromised_should_be_patching: -20 -compromised_should_be_overwhelmed: -20 -compromised: -20 -overwhelmed_should_be_good: -20 -overwhelmed_should_be_patching: -20 -overwhelmed_should_be_compromised: -20 -overwhelmed: -20 -# Node File System State -good_should_be_repairing: 2 -good_should_be_restoring: 2 -good_should_be_corrupt: 5 -good_should_be_destroyed: 10 -repairing_should_be_good: -5 -repairing_should_be_restoring: 2 -repairing_should_be_corrupt: 2 -repairing_should_be_destroyed: 0 -repairing: -3 -restoring_should_be_good: -10 -restoring_should_be_repairing: -2 -restoring_should_be_corrupt: 1 -restoring_should_be_destroyed: 2 -restoring: -6 -corrupt_should_be_good: -10 -corrupt_should_be_repairing: -10 -corrupt_should_be_restoring: -10 -corrupt_should_be_destroyed: 2 -corrupt: -10 -destroyed_should_be_good: -20 -destroyed_should_be_repairing: -20 -destroyed_should_be_restoring: -20 -destroyed_should_be_corrupt: -20 -destroyed: -20 -scanning: -2 -# IER status -red_ier_running: -5 -green_ier_blocked: -10 - -# Patching / Reset durations -os_patching_duration: 5 # The time taken to patch the OS -node_reset_duration: 5 # The time taken to reset a node (hardware) -service_patching_duration: 5 # The time taken to patch a service -file_system_repairing_limit: 5 # The time take to repair the file system -file_system_restoring_limit: 5 # The time take to restore the file system -file_system_scanning_limit: 5 # The time taken to scan the file system diff --git a/tests/test_red_random_agent_behaviour.py b/tests/test_red_random_agent_behaviour.py index 476a08f1..6b06dbb1 100644 --- a/tests/test_red_random_agent_behaviour.py +++ b/tests/test_red_random_agent_behaviour.py @@ -55,6 +55,8 @@ def test_random_red_agent_behaviour(): session_path=session_path, timestamp_str=timestamp_str, ) + # set red_agent_ + env.training_config.random_red_agent = True training_config = env.training_config training_config.num_steps = env.episode_steps