From ff17062e1cc0bfcfee645d553a5745e688cfaf3c Mon Sep 17 00:00:00 2001 From: Marek Wolan Date: Thu, 8 Feb 2024 09:19:18 +0000 Subject: [PATCH 1/7] Vary start node of red agent. --- .../config/_package_data/example_config.yaml | 12 +- .../example_config_2_rl_agents.yaml | 2 +- .../game/agent/data_manipulation_bot.py | 16 +- src/primaite/game/game.py | 12 +- src/primaite/notebooks/uc2_demo.ipynb | 739 +++++++++++++++++- .../assets/configs/bad_primaite_session.yaml | 2 +- .../configs/eval_only_primaite_session.yaml | 2 +- tests/assets/configs/multi_agent_session.yaml | 2 +- .../assets/configs/test_primaite_session.yaml | 2 +- .../configs/train_only_primaite_session.yaml | 2 +- 10 files changed, 745 insertions(+), 46 deletions(-) diff --git a/src/primaite/config/_package_data/example_config.yaml b/src/primaite/config/_package_data/example_config.yaml index 700a0c18..7290339e 100644 --- a/src/primaite/config/_package_data/example_config.yaml +++ b/src/primaite/config/_package_data/example_config.yaml @@ -85,7 +85,7 @@ agents: - - ref: client_1_data_manipulation_red_bot + - ref: data_manipulation_attacker team: RED type: RedDatabaseCorruptingAgent @@ -106,6 +106,9 @@ agents: - 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 @@ -730,6 +733,13 @@ simulation: type: WebBrowser options: target_url: http://arcd.com/users/ + - ref: data_manipulation_bot + type: DataManipulationBot + options: + port_scan_p_of_success: 0.8 + data_manipulation_p_of_success: 0.8 + payload: "DELETE" + server_ip: 192.168.1.14 services: - ref: client_2_dns_client type: DNSClient diff --git a/src/primaite/config/_package_data/example_config_2_rl_agents.yaml b/src/primaite/config/_package_data/example_config_2_rl_agents.yaml index 6aa54487..993b3283 100644 --- a/src/primaite/config/_package_data/example_config_2_rl_agents.yaml +++ b/src/primaite/config/_package_data/example_config_2_rl_agents.yaml @@ -54,7 +54,7 @@ agents: frequency: 4 variance: 3 - - ref: client_1_data_manipulation_red_bot + - ref: data_manipulation_attacker team: RED type: RedDatabaseCorruptingAgent diff --git a/src/primaite/game/agent/data_manipulation_bot.py b/src/primaite/game/agent/data_manipulation_bot.py index 58b790ec..126c55ec 100644 --- a/src/primaite/game/agent/data_manipulation_bot.py +++ b/src/primaite/game/agent/data_manipulation_bot.py @@ -1,21 +1,20 @@ import random -from typing import Dict, List, Tuple +from typing import Dict, Tuple from gymnasium.core import ObsType from primaite.game.agent.interface import AbstractScriptedAgent -from primaite.simulator.system.applications.red_applications.data_manipulation_bot import DataManipulationBot class DataManipulationAgent(AbstractScriptedAgent): """Agent that uses a DataManipulationBot to perform an SQL injection attack.""" - data_manipulation_bots: List["DataManipulationBot"] = [] next_execution_timestep: int = 0 + starting_node_idx: int = 0 def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self._set_next_execution_timestep(self.agent_settings.start_settings.start_step) + self.reset_agent_for_episode() def _set_next_execution_timestep(self, timestep: int) -> None: """Set the next execution timestep with a configured random variance. @@ -44,9 +43,16 @@ class DataManipulationAgent(AbstractScriptedAgent): self._set_next_execution_timestep(current_timestep + self.agent_settings.start_settings.frequency) - return "NODE_APPLICATION_EXECUTE", {"node_id": 0, "application_id": 0} + return "NODE_APPLICATION_EXECUTE", {"node_id": self.starting_node_idx, "application_id": 0} def reset_agent_for_episode(self) -> None: """Set the next execution timestep when the episode resets.""" super().reset_agent_for_episode() + self._select_start_node() self._set_next_execution_timestep(self.agent_settings.start_settings.start_step) + + def _select_start_node(self) -> None: + """Set the starting starting node of the agent to be a random node from this agent's action manager.""" + # we are assuming that every node in the node manager has a data manipulation application at idx 0 + num_nodes = len(self.action_manager.node_names) + self.starting_node_idx = random.randint(0, num_nodes - 1) diff --git a/src/primaite/game/game.py b/src/primaite/game/game.py index a2c4e86d..1fd0dc8b 100644 --- a/src/primaite/game/game.py +++ b/src/primaite/game/game.py @@ -1,6 +1,6 @@ """PrimAITE game - Encapsulates the simulation and agents.""" from ipaddress import IPv4Address -from typing import Dict, List +from typing import Dict, List, Tuple from pydantic import BaseModel, ConfigDict @@ -131,8 +131,14 @@ class PrimaiteGame: agent.update_reward(state) agent.reward_function.total_reward += agent.reward_function.current_reward - def apply_agent_actions(self) -> None: - """Apply all actions to simulation as requests.""" + def apply_agent_actions(self) -> Dict[str, Tuple[str, Dict]]: + """ + Apply all actions to simulation as requests. + + :return: A recap of each agent's actions, in CAOS format. + :rtype: Dict[str, Tuple[str, Dict]] + + """ agent_actions = {} for agent in self.agents: obs = agent.observation_manager.current_observation diff --git a/src/primaite/notebooks/uc2_demo.ipynb b/src/primaite/notebooks/uc2_demo.ipynb index 7454b6c4..b37e69fc 100644 --- a/src/primaite/notebooks/uc2_demo.ipynb +++ b/src/primaite/notebooks/uc2_demo.ipynb @@ -55,7 +55,7 @@ "source": [ "## Red agent\n", "\n", - "The red agent waits a bit then sends a DELETE query to the database from client 1. If the delete is successful, the database file is flagged as compromised to signal that data is not available.\n", + "At the start of every episode, the red agent randomly chooses either client 1 or client 2 to login to. It waits a bit then sends a DELETE query to the database from its chosen client. If the delete is successful, the database file is flagged as compromised to signal that data is not available.\n", "\n", "[](_package_data/uc2_attack.png)\n", "\n", @@ -68,7 +68,7 @@ "source": [ "## Blue agent\n", "\n", - "The blue agent can view the entire network, but the health statuses of components are not updated until a scan is performed. The blue agent should restore the database file from backup after it was compromised. It can also prevent further attacks by blocking client 1 from sending the malicious SQL query to the database server. This can be done by implementing an ACL rule on the router." + "The blue agent can view the entire network, but the health statuses of components are not updated until a scan is performed. The blue agent should restore the database file from backup after it was compromised. It can also prevent further attacks by blocking the red agent client from sending the malicious SQL query to the database server. This can be done by implementing an ACL rule on the router." ] }, { @@ -84,7 +84,7 @@ "source": [ "## Scripted agents:\n", "### Red\n", - "The red agent sits on client 1 and uses an application called DataManipulationBot whose sole purpose is to send a DELETE query to the database.\n", + "The red agent sits on a client and uses an application called DataManipulationBot whose sole purpose is to send a DELETE query to the database.\n", "The red agent can choose one of two action each timestep:\n", "1. do nothing\n", "2. execute the data manipulation application\n", @@ -92,6 +92,7 @@ "- start time\n", "- frequency\n", "- variance\n", + "\n", "Attacks start at a random timestep between (start_time - variance) and (start_time + variance). After each attack, another is attempted after a random delay between (frequency - variance) and (frequency + variance) timesteps.\n", "\n", "The data manipulation app itself has an element of randomness because the attack has a probability of success. The default is 0.8 to succeed with the port scan step and 0.8 to succeed with the attack itself.\n", @@ -290,10 +291,16 @@ "- `9`: Scan the database file - this refreshes the health status of the database file\n", "- `13`: Patch the database service - This triggers the database to restore data from the backup server\n", "- `19`: Shut down client 1\n", + "- `20`: Start up client 1\n", "- `22`: Block outgoing traffic from client 1\n", + "- `23`: Block outgoing traffic from client 2\n", "- `26`: Block TCP traffic from client 1 to the database node\n", + "- `27`: Block TCP traffic from client 2 to the database node\n", "- `28-37`: Remove ACL rules 1-10\n", "- `42`: Disconnect client 1 from the network\n", + "- `43`: Reconnect client 1 to the network\n", + "- `44`: Disconnect client 2 from the network\n", + "- `45`: Reconnect client 2 to the network\n", "\n", "The other actions will either have no effect or will negatively impact the network, so the blue agent should avoid taking them." ] @@ -326,7 +333,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -336,9 +343,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/cade/repos/PrimAITE/venv/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", + " from .autonotebook import tqdm as notebook_tqdm\n", + "2024-02-07 10:58:13,192\tINFO util.py:159 -- Missing packages: ['ipywidgets']. Run `pip install -U ipywidgets`, then restart the notebook server for rich notebook output.\n", + "2024-02-07 10:58:17,136\tINFO util.py:159 -- Missing packages: ['ipywidgets']. Run `pip install -U ipywidgets`, then restart the notebook server for rich notebook output.\n" + ] + } + ], "source": [ "# Imports\n", "from primaite.config.load import example_config_path\n", @@ -359,16 +377,143 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Resetting environment, episode 0, avg. reward: 0.0\n", + "env created successfully\n", + "{'ACL': {1: {'dest_node_id': 0,\n", + " 'dest_port': 0,\n", + " 'permission': 0,\n", + " 'position': 0,\n", + " 'protocol': 0,\n", + " 'source_node_id': 0,\n", + " 'source_port': 0},\n", + " 2: {'dest_node_id': 0,\n", + " 'dest_port': 0,\n", + " 'permission': 0,\n", + " 'position': 1,\n", + " 'protocol': 0,\n", + " 'source_node_id': 0,\n", + " 'source_port': 0},\n", + " 3: {'dest_node_id': 0,\n", + " 'dest_port': 0,\n", + " 'permission': 0,\n", + " 'position': 2,\n", + " 'protocol': 0,\n", + " 'source_node_id': 0,\n", + " 'source_port': 0},\n", + " 4: {'dest_node_id': 0,\n", + " 'dest_port': 0,\n", + " 'permission': 0,\n", + " 'position': 3,\n", + " 'protocol': 0,\n", + " 'source_node_id': 0,\n", + " 'source_port': 0},\n", + " 5: {'dest_node_id': 0,\n", + " 'dest_port': 0,\n", + " 'permission': 0,\n", + " 'position': 4,\n", + " 'protocol': 0,\n", + " 'source_node_id': 0,\n", + " 'source_port': 0},\n", + " 6: {'dest_node_id': 0,\n", + " 'dest_port': 0,\n", + " 'permission': 0,\n", + " 'position': 5,\n", + " 'protocol': 0,\n", + " 'source_node_id': 0,\n", + " 'source_port': 0},\n", + " 7: {'dest_node_id': 0,\n", + " 'dest_port': 0,\n", + " 'permission': 0,\n", + " 'position': 6,\n", + " 'protocol': 0,\n", + " 'source_node_id': 0,\n", + " 'source_port': 0},\n", + " 8: {'dest_node_id': 0,\n", + " 'dest_port': 0,\n", + " 'permission': 0,\n", + " 'position': 7,\n", + " 'protocol': 0,\n", + " 'source_node_id': 0,\n", + " 'source_port': 0},\n", + " 9: {'dest_node_id': 0,\n", + " 'dest_port': 0,\n", + " 'permission': 0,\n", + " 'position': 8,\n", + " 'protocol': 0,\n", + " 'source_node_id': 0,\n", + " 'source_port': 0},\n", + " 10: {'dest_node_id': 0,\n", + " 'dest_port': 0,\n", + " 'permission': 0,\n", + " 'position': 9,\n", + " 'protocol': 0,\n", + " 'source_node_id': 0,\n", + " 'source_port': 0}},\n", + " 'ICS': 0,\n", + " 'LINKS': {1: {'PROTOCOLS': {'ALL': 0}},\n", + " 2: {'PROTOCOLS': {'ALL': 0}},\n", + " 3: {'PROTOCOLS': {'ALL': 0}},\n", + " 4: {'PROTOCOLS': {'ALL': 0}},\n", + " 5: {'PROTOCOLS': {'ALL': 0}},\n", + " 6: {'PROTOCOLS': {'ALL': 0}},\n", + " 7: {'PROTOCOLS': {'ALL': 0}},\n", + " 8: {'PROTOCOLS': {'ALL': 0}},\n", + " 9: {'PROTOCOLS': {'ALL': 0}},\n", + " 10: {'PROTOCOLS': {'ALL': 0}}},\n", + " 'NODES': {1: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}},\n", + " 'health_status': 0}},\n", + " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", + " 'SERVICES': {1: {'health_status': 0, 'operating_status': 1}},\n", + " 'operating_status': 1},\n", + " 2: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}},\n", + " 'health_status': 0}},\n", + " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", + " 'SERVICES': {1: {'health_status': 0, 'operating_status': 1}},\n", + " 'operating_status': 1},\n", + " 3: {'FOLDERS': {1: {'FILES': {1: {'health_status': 1}},\n", + " 'health_status': 1}},\n", + " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", + " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", + " 'operating_status': 1},\n", + " 4: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}},\n", + " 'health_status': 0}},\n", + " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", + " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", + " 'operating_status': 1},\n", + " 5: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}},\n", + " 'health_status': 0}},\n", + " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", + " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", + " 'operating_status': 1},\n", + " 6: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}},\n", + " 'health_status': 0}},\n", + " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", + " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", + " 'operating_status': 1},\n", + " 7: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}},\n", + " 'health_status': 0}},\n", + " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", + " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", + " 'operating_status': 1}}}\n" + ] + } + ], "source": [ "# create the env\n", "with open(example_config_path(), 'r') as f:\n", " cfg = yaml.safe_load(f)\n", " # set success probability to 1.0 to avoid rerunning cells.\n", " cfg['simulation']['network']['nodes'][8]['applications'][0]['options']['data_manipulation_p_of_success'] = 1.0\n", + " cfg['simulation']['network']['nodes'][9]['applications'][0]['options']['data_manipulation_p_of_success'] = 1.0\n", " cfg['simulation']['network']['nodes'][8]['applications'][0]['options']['port_scan_p_of_success'] = 1.0\n", + " cfg['simulation']['network']['nodes'][9]['applications'][0]['options']['port_scan_p_of_success'] = 1.0\n", "game = PrimaiteGame.from_config(cfg)\n", "env = PrimaiteGymEnv(game = game)\n", "# Don't flatten obs as we are not training an agent and we wish to see the dict-formatted observations\n", @@ -382,18 +527,78 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The red agent will start attacking at some point between step 20 and 30. When this happens, the reward will go from 1.0 to 0.0, and to -1.0 when the green agent tries to access the webpage." + "The red agent will start attacking at some point between step 20 and 30. When this happens, the reward will drop immediately, then drop to -1.0 when green agents try to access the webpage." ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ - "for step in range(32):\n", + "def friendly_output_red_action(info):\n", + " # parse the info dict form step output and write out what the red agent is doing\n", + " red_info = info['agent_actions']['data_manipulation_attacker']\n", + " red_action = red_info[0]\n", + " if red_action == 'DONOTHING':\n", + " red_str = 'DO NOTHING'\n", + " elif red_action == 'NODE_APPLICATION_EXECUTE':\n", + " client = \"client 1\" if red_info[1]['node_id'] == 0 else \"client 2\"\n", + " red_str = f\"ATTACK from {client}\"\n", + " return red_str" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "step: 1, Red action: DO NOTHING, Blue reward:0.34\n", + "step: 2, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 3, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 4, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 5, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 6, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 7, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 8, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 9, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 10, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 11, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 12, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 13, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 14, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 15, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 16, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 17, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 18, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 19, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 20, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 21, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 22, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 23, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 24, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 25, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 26, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 27, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 28, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 29, Red action: DO NOTHING, Blue reward:1.0\n", + "step: 30, Red action: ATTACK from client 1, Blue reward:0.32\n", + "step: 31, Red action: DO NOTHING, Blue reward:0.32\n", + "step: 32, Red action: DO NOTHING, Blue reward:0.32\n", + "step: 33, Red action: DO NOTHING, Blue reward:-1.0\n", + "step: 34, Red action: DO NOTHING, Blue reward:-1.0\n", + "step: 35, Red action: DO NOTHING, Blue reward:-1.0\n" + ] + } + ], + "source": [ + "for step in range(35):\n", " obs, reward, terminated, truncated, info = env.step(0)\n", - " print(f\"step: {env.game.step_counter}, Red action: {info['agent_actions']['client_1_data_manipulation_red_bot'][0]}, Blue reward:{reward}\" )" + " print(f\"step: {env.game.step_counter}, Red action: {friendly_output_red_action(info)}, Blue reward:{reward}\" )" ] }, { @@ -405,9 +610,44 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{1: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", + " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", + " 'SERVICES': {1: {'health_status': 0, 'operating_status': 1}},\n", + " 'operating_status': 1},\n", + " 2: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", + " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", + " 'SERVICES': {1: {'health_status': 0, 'operating_status': 1}},\n", + " 'operating_status': 1},\n", + " 3: {'FOLDERS': {1: {'FILES': {1: {'health_status': 1}}, 'health_status': 1}},\n", + " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", + " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", + " 'operating_status': 1},\n", + " 4: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", + " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", + " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", + " 'operating_status': 1},\n", + " 5: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", + " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", + " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", + " 'operating_status': 1},\n", + " 6: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", + " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", + " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", + " 'operating_status': 1},\n", + " 7: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", + " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", + " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", + " 'operating_status': 1}}\n" + ] + } + ], "source": [ "pprint(obs['NODES'])" ] @@ -421,9 +661,44 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{1: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", + " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", + " 'SERVICES': {1: {'health_status': 0, 'operating_status': 1}},\n", + " 'operating_status': 1},\n", + " 2: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", + " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", + " 'SERVICES': {1: {'health_status': 3, 'operating_status': 1}},\n", + " 'operating_status': 1},\n", + " 3: {'FOLDERS': {1: {'FILES': {1: {'health_status': 2}}, 'health_status': 1}},\n", + " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", + " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", + " 'operating_status': 1},\n", + " 4: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", + " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", + " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", + " 'operating_status': 1},\n", + " 5: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", + " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", + " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", + " 'operating_status': 1},\n", + " 6: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", + " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", + " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", + " 'operating_status': 1},\n", + " 7: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", + " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", + " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", + " 'operating_status': 1}}\n" + ] + } + ], "source": [ "obs, reward, terminated, truncated, info = env.step(9) # scan database file\n", "obs, reward, terminated, truncated, info = env.step(1) # scan webapp service\n", @@ -447,13 +722,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "step: 38\n", + "Red action: DONOTHING\n", + "Green action: NODE_APPLICATION_EXECUTE\n", + "Green action: NODE_APPLICATION_EXECUTE\n", + "Blue reward:-1.0\n" + ] + } + ], "source": [ "obs, reward, terminated, truncated, info = env.step(13) # patch the database\n", "print(f\"step: {env.game.step_counter}\")\n", - "print(f\"Red action: {info['agent_actions']['client_1_data_manipulation_red_bot'][0]}\" )\n", + "print(f\"Red action: {info['agent_actions']['data_manipulation_attacker'][0]}\" )\n", "print(f\"Green action: {info['agent_actions']['client_1_green_user'][0]}\" )\n", "print(f\"Green action: {info['agent_actions']['client_2_green_user'][0]}\" )\n", "print(f\"Blue reward:{reward}\" )" @@ -465,20 +752,32 @@ "source": [ "The patching takes two steps, so the reward hasn't changed yet. Let's do nothing for another timestep, the reward should improve.\n", "\n", - "The reward will be 0 as soon as the file finishes restoring. Then, the reward will increase to 1 when the green agent makes a request. (Because the webapp access part of the reward does not update until a successful request is made.)\n", + "The reward will increase slightly as soon as the file finishes restoring. Then, the reward will increase to 1 when both green agents make successful requests.\n", "\n", "Run the following cell until the green action is `NODE_APPLICATION_EXECUTE`, then the reward should become 1. If you run it enough times, another red attack will happen and the reward will drop again." ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "step: 39\n", + "Red action: DONOTHING\n", + "Green action: NODE_APPLICATION_EXECUTE\n", + "Green action: DONOTHING\n", + "Blue reward:-0.32\n" + ] + } + ], "source": [ "obs, reward, terminated, truncated, info = env.step(0) # patch the database\n", "print(f\"step: {env.game.step_counter}\")\n", - "print(f\"Red action: {info['agent_actions']['client_1_data_manipulation_red_bot'][0]}\" )\n", + "print(f\"Red action: {info['agent_actions']['data_manipulation_attacker'][0]}\" )\n", "print(f\"Green action: {info['agent_actions']['client_2_green_user'][0]}\" )\n", "print(f\"Green action: {info['agent_actions']['client_1_green_user'][0]}\" )\n", "print(f\"Blue reward:{reward}\" )" @@ -488,24 +787,69 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The blue agent can prevent attacks by implementing an ACL rule to stop client_1 from sending POSTGRES traffic to the database. (Let's also patch the database file to get the reward back up.)" + "The blue agent can prevent attacks by implementing an ACL rule to stop client_1 or client_2 from sending POSTGRES traffic to the database. (Let's also patch the database file to get the reward back up.)\n", + "\n", + "Let's block both clients from communicating directly with the database." ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "step: 139, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 140, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 141, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 142, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 143, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 144, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 145, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 146, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 147, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 148, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 149, Red action: NODE_APPLICATION_EXECUTE, Blue reward:-0.32\n", + "step: 150, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 151, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 152, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 153, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 154, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 155, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 156, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 157, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 158, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 159, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 160, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 161, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 162, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 163, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 164, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 165, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 166, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 167, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 168, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 169, Red action: NODE_APPLICATION_EXECUTE, Blue reward:-0.32\n", + "step: 170, Red action: DONOTHING, Blue reward:-0.32\n", + "step: 171, Red action: DONOTHING, Blue reward:-0.32\n" + ] + } + ], "source": [ "env.step(13) # Patch the database\n", - "print(f\"step: {env.game.step_counter}, Red action: {info['agent_actions']['client_1_data_manipulation_red_bot'][0]}, Blue reward:{reward}\" )\n", + "print(f\"step: {env.game.step_counter}, Red action: {info['agent_actions']['data_manipulation_attacker'][0]}, Blue reward:{reward}\" )\n", "\n", "env.step(26) # Block client 1\n", - "print(f\"step: {env.game.step_counter}, Red action: {info['agent_actions']['client_1_data_manipulation_red_bot'][0]}, Blue reward:{reward}\" )\n", + "print(f\"step: {env.game.step_counter}, Red action: {info['agent_actions']['data_manipulation_attacker'][0]}, Blue reward:{reward}\" )\n", + "\n", + "env.step(27) # Block client 2\n", + "print(f\"step: {env.game.step_counter}, Red action: {info['agent_actions']['data_manipulation_attacker'][0]}, Blue reward:{reward}\" )\n", "\n", "for step in range(30):\n", " obs, reward, terminated, truncated, info = env.step(0) # do nothing\n", - " print(f\"step: {env.game.step_counter}, Red action: {info['agent_actions']['client_1_data_manipulation_red_bot'][0]}, Blue reward:{reward}\" )" + " print(f\"step: {env.game.step_counter}, Red action: {info['agent_actions']['data_manipulation_attacker'][0]}, Blue reward:{reward}\" )" ] }, { @@ -519,7 +863,340 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Let's also have a look at the ACL observation to verify our new ACL rule at position 5." + "Let's also have a look at the ACL observation to verify our new ACL rule at positions 5 and 6." + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{1: {'position': 0,\n", + " 'permission': 0,\n", + " 'source_node_id': 0,\n", + " 'source_port': 0,\n", + " 'dest_node_id': 0,\n", + " 'dest_port': 0,\n", + " 'protocol': 0},\n", + " 2: {'position': 1,\n", + " 'permission': 0,\n", + " 'source_node_id': 0,\n", + " 'source_port': 0,\n", + " 'dest_node_id': 0,\n", + " 'dest_port': 0,\n", + " 'protocol': 0},\n", + " 3: {'position': 2,\n", + " 'permission': 0,\n", + " 'source_node_id': 0,\n", + " 'source_port': 0,\n", + " 'dest_node_id': 0,\n", + " 'dest_port': 0,\n", + " 'protocol': 0},\n", + " 4: {'position': 3,\n", + " 'permission': 0,\n", + " 'source_node_id': 0,\n", + " 'source_port': 0,\n", + " 'dest_node_id': 0,\n", + " 'dest_port': 0,\n", + " 'protocol': 0},\n", + " 5: {'position': 4,\n", + " 'permission': 2,\n", + " 'source_node_id': 7,\n", + " 'source_port': 1,\n", + " 'dest_node_id': 4,\n", + " 'dest_port': 1,\n", + " 'protocol': 3},\n", + " 6: {'position': 5,\n", + " 'permission': 2,\n", + " 'source_node_id': 8,\n", + " 'source_port': 1,\n", + " 'dest_node_id': 4,\n", + " 'dest_port': 1,\n", + " 'protocol': 3},\n", + " 7: {'position': 6,\n", + " 'permission': 0,\n", + " 'source_node_id': 0,\n", + " 'source_port': 0,\n", + " 'dest_node_id': 0,\n", + " 'dest_port': 0,\n", + " 'protocol': 0},\n", + " 8: {'position': 7,\n", + " 'permission': 0,\n", + " 'source_node_id': 0,\n", + " 'source_port': 0,\n", + " 'dest_node_id': 0,\n", + " 'dest_port': 0,\n", + " 'protocol': 0},\n", + " 9: {'position': 8,\n", + " 'permission': 0,\n", + " 'source_node_id': 0,\n", + " 'source_port': 0,\n", + " 'dest_node_id': 0,\n", + " 'dest_port': 0,\n", + " 'protocol': 0},\n", + " 10: {'position': 9,\n", + " 'permission': 0,\n", + " 'source_node_id': 0,\n", + " 'source_port': 0,\n", + " 'dest_node_id': 0,\n", + " 'dest_port': 0,\n", + " 'protocol': 0}}" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "obs['ACL']" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [], + "source": [ + "router = env.game.simulation.network.get_node_by_hostname('router_1')" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "+------------------------------------------------------------------------------------------------------------+\n", + "| router_1 Access Control List |\n", + "+-------+--------+----------+---------------+------------------------+--------------+------------------------+\n", + "| Index | Action | Protocol | Src IP | Src Port | Dst IP | Dst Port |\n", + "+-------+--------+----------+---------------+------------------------+--------------+------------------------+\n", + "| 5 | DENY | TCP | 192.168.10.21 | ANY | 192.168.1.14 | ANY |\n", + "| 6 | DENY | TCP | 192.168.10.22 | ANY | 192.168.1.14 | ANY |\n", + "| 18 | PERMIT | ANY | ANY | 5432 (POSTGRES_SERVER) | ANY | 5432 (POSTGRES_SERVER) |\n", + "| 19 | PERMIT | ANY | ANY | 53 (DNS) | ANY | 53 (DNS) |\n", + "| 20 | PERMIT | ANY | ANY | 21 (FTP) | ANY | 21 (FTP) |\n", + "| 21 | PERMIT | ANY | ANY | 80 (HTTP) | ANY | 80 (HTTP) |\n", + "| 22 | PERMIT | ANY | ANY | 219 (ARP) | ANY | 219 (ARP) |\n", + "| 23 | PERMIT | ICMP | ANY | ANY | ANY | ANY |\n", + "| 24 | DENY | ANY | ANY | ANY | ANY | ANY |\n", + "+-------+--------+----------+---------------+------------------------+--------------+------------------------+\n" + ] + } + ], + "source": [ + "router.acl.show()" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[(, 0.34),\n", + " (,\n", + " 0.33),\n", + " (,\n", + " 0.33)]" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "env.agent.reward_function.reward_components" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [], + "source": [ + "client_1 = env.game.simulation.network.get_node_by_hostname('client_1')\n", + "client_2 = env.game.simulation.network.get_node_by_hostname('client_2')" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [], + "source": [ + "client_1_browser = client_1.software_manager.software.get(\"WebBrowser\")\n", + "client_2_browser = client_2.software_manager.software.get(\"WebBrowser\")" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", + " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=)]" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "client_2_browser.history" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 35, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "client_1_browser.get_webpage()" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": {}, + "outputs": [], + "source": [ + "database_server = env.game.simulation.network.get_node_by_hostname('database_server')" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "File(uuid='390c399a-c2ab-4d84-b98f-d5fc1f9114d2', name='database.db', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, folder_id='e602b9a6-ea1c-4c52-9025-8512d9116b1d', folder_name='database', file_type=, sim_size=15360000, real=False, sim_path=None, sim_root=PosixPath('/home/cade/primaite/3.0.0b6/sessions/2024-02-07/10-58-18/simulation_output/database_server/fs'), folder=Folder(uuid='e602b9a6-ea1c-4c52-9025-8512d9116b1d', name='database', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, files={'390c399a-c2ab-4d84-b98f-d5fc1f9114d2': File(uuid='390c399a-c2ab-4d84-b98f-d5fc1f9114d2', name='database.db', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, folder_id='e602b9a6-ea1c-4c52-9025-8512d9116b1d', folder_name='database', file_type=, sim_size=15360000, real=False, sim_path=None, sim_root=PosixPath('/home/cade/primaite/3.0.0b6/sessions/2024-02-07/10-58-18/simulation_output/database_server/fs'), folder=Folder(uuid='e602b9a6-ea1c-4c52-9025-8512d9116b1d', name='database', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, files={...}, deleted_files={'e63e23dc-c443-4434-822d-3c2c01cbfe1e': File(uuid='e63e23dc-c443-4434-822d-3c2c01cbfe1e', name='database.db', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=True, folder_id='e602b9a6-ea1c-4c52-9025-8512d9116b1d', folder_name='database', file_type=, sim_size=15360000, real=False, sim_path=None, sim_root=PosixPath('/home/cade/primaite/3.0.0b6/sessions/2024-02-07/10-58-18/simulation_output/database_server/fs'), folder=Folder(uuid='e602b9a6-ea1c-4c52-9025-8512d9116b1d', name='database', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, files={...}, deleted_files={...}, scan_duration=3, scan_countdown=-1, red_scan_duration=3, red_scan_countdown=-1, restore_duration=3, restore_countdown=-1, original_file_uuids=['e63e23dc-c443-4434-822d-3c2c01cbfe1e'])), '646a198e-6ac1-4aea-b526-7ca5c2c30dfc': File(uuid='646a198e-6ac1-4aea-b526-7ca5c2c30dfc', name='database.db', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=True, folder_id='e602b9a6-ea1c-4c52-9025-8512d9116b1d', folder_name='database', file_type=, sim_size=15360000, real=False, sim_path=None, sim_root=PosixPath('/home/cade/primaite/3.0.0b6/sessions/2024-02-07/10-58-18/simulation_output/database_server/fs'), folder=Folder(uuid='e602b9a6-ea1c-4c52-9025-8512d9116b1d', name='database', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, files={...}, deleted_files={...}, scan_duration=3, scan_countdown=-1, red_scan_duration=3, red_scan_countdown=-1, restore_duration=3, restore_countdown=-1, original_file_uuids=['e63e23dc-c443-4434-822d-3c2c01cbfe1e'])), '23df7aba-074e-4ffa-939a-d87ad1fe7af1': File(uuid='23df7aba-074e-4ffa-939a-d87ad1fe7af1', name='database.db', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=True, folder_id='e602b9a6-ea1c-4c52-9025-8512d9116b1d', folder_name='database', file_type=, sim_size=15360000, real=False, sim_path=None, sim_root=PosixPath('/home/cade/primaite/3.0.0b6/sessions/2024-02-07/10-58-18/simulation_output/database_server/fs'), folder=Folder(uuid='e602b9a6-ea1c-4c52-9025-8512d9116b1d', name='database', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, files={...}, deleted_files={...}, scan_duration=3, scan_countdown=-1, red_scan_duration=3, red_scan_countdown=-1, restore_duration=3, restore_countdown=-1, original_file_uuids=['e63e23dc-c443-4434-822d-3c2c01cbfe1e']))}, scan_duration=3, scan_countdown=-1, red_scan_duration=3, red_scan_countdown=-1, restore_duration=3, restore_countdown=-1, original_file_uuids=['e63e23dc-c443-4434-822d-3c2c01cbfe1e']))}, deleted_files={'e63e23dc-c443-4434-822d-3c2c01cbfe1e': File(uuid='e63e23dc-c443-4434-822d-3c2c01cbfe1e', name='database.db', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=True, folder_id='e602b9a6-ea1c-4c52-9025-8512d9116b1d', folder_name='database', file_type=, sim_size=15360000, real=False, sim_path=None, sim_root=PosixPath('/home/cade/primaite/3.0.0b6/sessions/2024-02-07/10-58-18/simulation_output/database_server/fs'), folder=Folder(uuid='e602b9a6-ea1c-4c52-9025-8512d9116b1d', name='database', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, files={'390c399a-c2ab-4d84-b98f-d5fc1f9114d2': File(uuid='390c399a-c2ab-4d84-b98f-d5fc1f9114d2', name='database.db', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, folder_id='e602b9a6-ea1c-4c52-9025-8512d9116b1d', folder_name='database', file_type=, sim_size=15360000, real=False, sim_path=None, sim_root=PosixPath('/home/cade/primaite/3.0.0b6/sessions/2024-02-07/10-58-18/simulation_output/database_server/fs'), folder=Folder(uuid='e602b9a6-ea1c-4c52-9025-8512d9116b1d', name='database', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, files={...}, deleted_files={...}, scan_duration=3, scan_countdown=-1, red_scan_duration=3, red_scan_countdown=-1, restore_duration=3, restore_countdown=-1, original_file_uuids=['e63e23dc-c443-4434-822d-3c2c01cbfe1e']))}, deleted_files={...}, scan_duration=3, scan_countdown=-1, red_scan_duration=3, red_scan_countdown=-1, restore_duration=3, restore_countdown=-1, original_file_uuids=['e63e23dc-c443-4434-822d-3c2c01cbfe1e'])), '646a198e-6ac1-4aea-b526-7ca5c2c30dfc': File(uuid='646a198e-6ac1-4aea-b526-7ca5c2c30dfc', name='database.db', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=True, folder_id='e602b9a6-ea1c-4c52-9025-8512d9116b1d', folder_name='database', file_type=, sim_size=15360000, real=False, sim_path=None, sim_root=PosixPath('/home/cade/primaite/3.0.0b6/sessions/2024-02-07/10-58-18/simulation_output/database_server/fs'), folder=Folder(uuid='e602b9a6-ea1c-4c52-9025-8512d9116b1d', name='database', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, files={'390c399a-c2ab-4d84-b98f-d5fc1f9114d2': File(uuid='390c399a-c2ab-4d84-b98f-d5fc1f9114d2', name='database.db', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, folder_id='e602b9a6-ea1c-4c52-9025-8512d9116b1d', folder_name='database', file_type=, sim_size=15360000, real=False, sim_path=None, sim_root=PosixPath('/home/cade/primaite/3.0.0b6/sessions/2024-02-07/10-58-18/simulation_output/database_server/fs'), folder=Folder(uuid='e602b9a6-ea1c-4c52-9025-8512d9116b1d', name='database', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, files={...}, deleted_files={...}, scan_duration=3, scan_countdown=-1, red_scan_duration=3, red_scan_countdown=-1, restore_duration=3, restore_countdown=-1, original_file_uuids=['e63e23dc-c443-4434-822d-3c2c01cbfe1e']))}, deleted_files={...}, scan_duration=3, scan_countdown=-1, red_scan_duration=3, red_scan_countdown=-1, restore_duration=3, restore_countdown=-1, original_file_uuids=['e63e23dc-c443-4434-822d-3c2c01cbfe1e'])), '23df7aba-074e-4ffa-939a-d87ad1fe7af1': File(uuid='23df7aba-074e-4ffa-939a-d87ad1fe7af1', name='database.db', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=True, folder_id='e602b9a6-ea1c-4c52-9025-8512d9116b1d', folder_name='database', file_type=, sim_size=15360000, real=False, sim_path=None, sim_root=PosixPath('/home/cade/primaite/3.0.0b6/sessions/2024-02-07/10-58-18/simulation_output/database_server/fs'), folder=Folder(uuid='e602b9a6-ea1c-4c52-9025-8512d9116b1d', name='database', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, files={'390c399a-c2ab-4d84-b98f-d5fc1f9114d2': File(uuid='390c399a-c2ab-4d84-b98f-d5fc1f9114d2', name='database.db', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, folder_id='e602b9a6-ea1c-4c52-9025-8512d9116b1d', folder_name='database', file_type=, sim_size=15360000, real=False, sim_path=None, sim_root=PosixPath('/home/cade/primaite/3.0.0b6/sessions/2024-02-07/10-58-18/simulation_output/database_server/fs'), folder=Folder(uuid='e602b9a6-ea1c-4c52-9025-8512d9116b1d', name='database', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, files={...}, deleted_files={...}, scan_duration=3, scan_countdown=-1, red_scan_duration=3, red_scan_countdown=-1, restore_duration=3, restore_countdown=-1, original_file_uuids=['e63e23dc-c443-4434-822d-3c2c01cbfe1e']))}, deleted_files={...}, scan_duration=3, scan_countdown=-1, red_scan_duration=3, red_scan_countdown=-1, restore_duration=3, restore_countdown=-1, original_file_uuids=['e63e23dc-c443-4434-822d-3c2c01cbfe1e']))}, scan_duration=3, scan_countdown=-1, red_scan_duration=3, red_scan_countdown=-1, restore_duration=3, restore_countdown=-1, original_file_uuids=['e63e23dc-c443-4434-822d-3c2c01cbfe1e']))" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "database_server.file_system.get_file('database', 'database.db')" ] }, { @@ -528,7 +1205,7 @@ "metadata": {}, "outputs": [], "source": [ - "obs['ACL']" + "database_server." ] } ], diff --git a/tests/assets/configs/bad_primaite_session.yaml b/tests/assets/configs/bad_primaite_session.yaml index 552351b2..662d704f 100644 --- a/tests/assets/configs/bad_primaite_session.yaml +++ b/tests/assets/configs/bad_primaite_session.yaml @@ -46,7 +46,7 @@ agents: frequency: 20 variance: 5 - - ref: client_1_data_manipulation_red_bot + - ref: data_manipulation_attacker team: RED type: RedDatabaseCorruptingAgent diff --git a/tests/assets/configs/eval_only_primaite_session.yaml b/tests/assets/configs/eval_only_primaite_session.yaml index d49562c8..254f7974 100644 --- a/tests/assets/configs/eval_only_primaite_session.yaml +++ b/tests/assets/configs/eval_only_primaite_session.yaml @@ -51,7 +51,7 @@ agents: frequency: 20 variance: 5 - - ref: client_1_data_manipulation_red_bot + - ref: data_manipulation_attacker team: RED type: RedDatabaseCorruptingAgent diff --git a/tests/assets/configs/multi_agent_session.yaml b/tests/assets/configs/multi_agent_session.yaml index 29f0ae7f..f01b1a63 100644 --- a/tests/assets/configs/multi_agent_session.yaml +++ b/tests/assets/configs/multi_agent_session.yaml @@ -57,7 +57,7 @@ agents: frequency: 20 variance: 5 - - ref: client_1_data_manipulation_red_bot + - ref: data_manipulation_attacker team: RED type: RedDatabaseCorruptingAgent diff --git a/tests/assets/configs/test_primaite_session.yaml b/tests/assets/configs/test_primaite_session.yaml index 0c70840d..55e8a273 100644 --- a/tests/assets/configs/test_primaite_session.yaml +++ b/tests/assets/configs/test_primaite_session.yaml @@ -55,7 +55,7 @@ agents: frequency: 20 variance: 5 - - ref: client_1_data_manipulation_red_bot + - ref: data_manipulation_attacker team: RED type: RedDatabaseCorruptingAgent diff --git a/tests/assets/configs/train_only_primaite_session.yaml b/tests/assets/configs/train_only_primaite_session.yaml index 0466a5ac..27236470 100644 --- a/tests/assets/configs/train_only_primaite_session.yaml +++ b/tests/assets/configs/train_only_primaite_session.yaml @@ -58,7 +58,7 @@ agents: frequency: 20 variance: 5 - - ref: client_1_data_manipulation_red_bot + - ref: data_manipulation_attacker team: RED type: RedDatabaseCorruptingAgent From 945db1341bb52af4cd1badbf60fe24972b99940c Mon Sep 17 00:00:00 2001 From: Marek Wolan Date: Tue, 20 Feb 2024 11:04:53 +0000 Subject: [PATCH 2/7] Make database client try to use most recent connection instead of generating new one --- .../simulator/system/applications/database_client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/primaite/simulator/system/applications/database_client.py b/src/primaite/simulator/system/applications/database_client.py index fbeefe6a..dfa5e445 100644 --- a/src/primaite/simulator/system/applications/database_client.py +++ b/src/primaite/simulator/system/applications/database_client.py @@ -193,7 +193,10 @@ class DatabaseClient(Application): return False if connection_id is None: - connection_id = str(uuid4()) + if self.connections: + connection_id = list(self.connections.keys())[-1] + else: + connection_id = str(uuid4()) if not self.connections.get(connection_id): if not self.connect(connection_id=connection_id): From 701781b23e58fbf9f7cf21b2ce7b2ef7682cdf95 Mon Sep 17 00:00:00 2001 From: Marek Wolan Date: Tue, 20 Feb 2024 11:05:09 +0000 Subject: [PATCH 3/7] Clear link load in new timestep --- src/primaite/simulator/network/hardware/base.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/primaite/simulator/network/hardware/base.py b/src/primaite/simulator/network/hardware/base.py index 5334021a..01dd736d 100644 --- a/src/primaite/simulator/network/hardware/base.py +++ b/src/primaite/simulator/network/hardware/base.py @@ -599,6 +599,11 @@ class Link(SimComponent): def __str__(self) -> str: return f"{self.endpoint_a}<-->{self.endpoint_b}" + def apply_timestep(self, timestep: int) -> None: + """Apply a timestep to the simulation.""" + super().apply_timestep(timestep) + self.current_load = 0.0 + class ARPCache: """ From 4a3c66bdc605e5ce0ee6863f30395a6d3a83ed84 Mon Sep 17 00:00:00 2001 From: Marek Wolan Date: Tue, 20 Feb 2024 12:04:07 +0000 Subject: [PATCH 4/7] Clear notebook code cells. --- src/primaite/notebooks/uc2_demo.ipynb | 680 +------------------------- 1 file changed, 21 insertions(+), 659 deletions(-) diff --git a/src/primaite/notebooks/uc2_demo.ipynb b/src/primaite/notebooks/uc2_demo.ipynb index b37e69fc..48ca795a 100644 --- a/src/primaite/notebooks/uc2_demo.ipynb +++ b/src/primaite/notebooks/uc2_demo.ipynb @@ -333,7 +333,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -343,20 +343,9 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/home/cade/repos/PrimAITE/venv/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", - " from .autonotebook import tqdm as notebook_tqdm\n", - "2024-02-07 10:58:13,192\tINFO util.py:159 -- Missing packages: ['ipywidgets']. Run `pip install -U ipywidgets`, then restart the notebook server for rich notebook output.\n", - "2024-02-07 10:58:17,136\tINFO util.py:159 -- Missing packages: ['ipywidgets']. Run `pip install -U ipywidgets`, then restart the notebook server for rich notebook output.\n" - ] - } - ], + "outputs": [], "source": [ "# Imports\n", "from primaite.config.load import example_config_path\n", @@ -377,134 +366,9 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Resetting environment, episode 0, avg. reward: 0.0\n", - "env created successfully\n", - "{'ACL': {1: {'dest_node_id': 0,\n", - " 'dest_port': 0,\n", - " 'permission': 0,\n", - " 'position': 0,\n", - " 'protocol': 0,\n", - " 'source_node_id': 0,\n", - " 'source_port': 0},\n", - " 2: {'dest_node_id': 0,\n", - " 'dest_port': 0,\n", - " 'permission': 0,\n", - " 'position': 1,\n", - " 'protocol': 0,\n", - " 'source_node_id': 0,\n", - " 'source_port': 0},\n", - " 3: {'dest_node_id': 0,\n", - " 'dest_port': 0,\n", - " 'permission': 0,\n", - " 'position': 2,\n", - " 'protocol': 0,\n", - " 'source_node_id': 0,\n", - " 'source_port': 0},\n", - " 4: {'dest_node_id': 0,\n", - " 'dest_port': 0,\n", - " 'permission': 0,\n", - " 'position': 3,\n", - " 'protocol': 0,\n", - " 'source_node_id': 0,\n", - " 'source_port': 0},\n", - " 5: {'dest_node_id': 0,\n", - " 'dest_port': 0,\n", - " 'permission': 0,\n", - " 'position': 4,\n", - " 'protocol': 0,\n", - " 'source_node_id': 0,\n", - " 'source_port': 0},\n", - " 6: {'dest_node_id': 0,\n", - " 'dest_port': 0,\n", - " 'permission': 0,\n", - " 'position': 5,\n", - " 'protocol': 0,\n", - " 'source_node_id': 0,\n", - " 'source_port': 0},\n", - " 7: {'dest_node_id': 0,\n", - " 'dest_port': 0,\n", - " 'permission': 0,\n", - " 'position': 6,\n", - " 'protocol': 0,\n", - " 'source_node_id': 0,\n", - " 'source_port': 0},\n", - " 8: {'dest_node_id': 0,\n", - " 'dest_port': 0,\n", - " 'permission': 0,\n", - " 'position': 7,\n", - " 'protocol': 0,\n", - " 'source_node_id': 0,\n", - " 'source_port': 0},\n", - " 9: {'dest_node_id': 0,\n", - " 'dest_port': 0,\n", - " 'permission': 0,\n", - " 'position': 8,\n", - " 'protocol': 0,\n", - " 'source_node_id': 0,\n", - " 'source_port': 0},\n", - " 10: {'dest_node_id': 0,\n", - " 'dest_port': 0,\n", - " 'permission': 0,\n", - " 'position': 9,\n", - " 'protocol': 0,\n", - " 'source_node_id': 0,\n", - " 'source_port': 0}},\n", - " 'ICS': 0,\n", - " 'LINKS': {1: {'PROTOCOLS': {'ALL': 0}},\n", - " 2: {'PROTOCOLS': {'ALL': 0}},\n", - " 3: {'PROTOCOLS': {'ALL': 0}},\n", - " 4: {'PROTOCOLS': {'ALL': 0}},\n", - " 5: {'PROTOCOLS': {'ALL': 0}},\n", - " 6: {'PROTOCOLS': {'ALL': 0}},\n", - " 7: {'PROTOCOLS': {'ALL': 0}},\n", - " 8: {'PROTOCOLS': {'ALL': 0}},\n", - " 9: {'PROTOCOLS': {'ALL': 0}},\n", - " 10: {'PROTOCOLS': {'ALL': 0}}},\n", - " 'NODES': {1: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}},\n", - " 'health_status': 0}},\n", - " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", - " 'SERVICES': {1: {'health_status': 0, 'operating_status': 1}},\n", - " 'operating_status': 1},\n", - " 2: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}},\n", - " 'health_status': 0}},\n", - " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", - " 'SERVICES': {1: {'health_status': 0, 'operating_status': 1}},\n", - " 'operating_status': 1},\n", - " 3: {'FOLDERS': {1: {'FILES': {1: {'health_status': 1}},\n", - " 'health_status': 1}},\n", - " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", - " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", - " 'operating_status': 1},\n", - " 4: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}},\n", - " 'health_status': 0}},\n", - " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", - " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", - " 'operating_status': 1},\n", - " 5: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}},\n", - " 'health_status': 0}},\n", - " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", - " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", - " 'operating_status': 1},\n", - " 6: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}},\n", - " 'health_status': 0}},\n", - " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", - " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", - " 'operating_status': 1},\n", - " 7: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}},\n", - " 'health_status': 0}},\n", - " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", - " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", - " 'operating_status': 1}}}\n" - ] - } - ], + "outputs": [], "source": [ "# create the env\n", "with open(example_config_path(), 'r') as f:\n", @@ -532,7 +396,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -550,51 +414,9 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "step: 1, Red action: DO NOTHING, Blue reward:0.34\n", - "step: 2, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 3, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 4, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 5, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 6, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 7, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 8, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 9, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 10, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 11, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 12, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 13, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 14, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 15, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 16, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 17, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 18, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 19, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 20, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 21, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 22, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 23, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 24, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 25, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 26, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 27, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 28, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 29, Red action: DO NOTHING, Blue reward:1.0\n", - "step: 30, Red action: ATTACK from client 1, Blue reward:0.32\n", - "step: 31, Red action: DO NOTHING, Blue reward:0.32\n", - "step: 32, Red action: DO NOTHING, Blue reward:0.32\n", - "step: 33, Red action: DO NOTHING, Blue reward:-1.0\n", - "step: 34, Red action: DO NOTHING, Blue reward:-1.0\n", - "step: 35, Red action: DO NOTHING, Blue reward:-1.0\n" - ] - } - ], + "outputs": [], "source": [ "for step in range(35):\n", " obs, reward, terminated, truncated, info = env.step(0)\n", @@ -610,44 +432,9 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{1: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", - " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", - " 'SERVICES': {1: {'health_status': 0, 'operating_status': 1}},\n", - " 'operating_status': 1},\n", - " 2: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", - " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", - " 'SERVICES': {1: {'health_status': 0, 'operating_status': 1}},\n", - " 'operating_status': 1},\n", - " 3: {'FOLDERS': {1: {'FILES': {1: {'health_status': 1}}, 'health_status': 1}},\n", - " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", - " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", - " 'operating_status': 1},\n", - " 4: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", - " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", - " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", - " 'operating_status': 1},\n", - " 5: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", - " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", - " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", - " 'operating_status': 1},\n", - " 6: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", - " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", - " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", - " 'operating_status': 1},\n", - " 7: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", - " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", - " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", - " 'operating_status': 1}}\n" - ] - } - ], + "outputs": [], "source": [ "pprint(obs['NODES'])" ] @@ -661,44 +448,9 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{1: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", - " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", - " 'SERVICES': {1: {'health_status': 0, 'operating_status': 1}},\n", - " 'operating_status': 1},\n", - " 2: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", - " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", - " 'SERVICES': {1: {'health_status': 3, 'operating_status': 1}},\n", - " 'operating_status': 1},\n", - " 3: {'FOLDERS': {1: {'FILES': {1: {'health_status': 2}}, 'health_status': 1}},\n", - " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", - " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", - " 'operating_status': 1},\n", - " 4: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", - " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", - " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", - " 'operating_status': 1},\n", - " 5: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", - " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", - " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", - " 'operating_status': 1},\n", - " 6: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", - " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", - " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", - " 'operating_status': 1},\n", - " 7: {'FOLDERS': {1: {'FILES': {1: {'health_status': 0}}, 'health_status': 0}},\n", - " 'NICS': {1: {'nic_status': 1}, 2: {'nic_status': 0}},\n", - " 'SERVICES': {1: {'health_status': 0, 'operating_status': 0}},\n", - " 'operating_status': 1}}\n" - ] - } - ], + "outputs": [], "source": [ "obs, reward, terminated, truncated, info = env.step(9) # scan database file\n", "obs, reward, terminated, truncated, info = env.step(1) # scan webapp service\n", @@ -722,21 +474,9 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "step: 38\n", - "Red action: DONOTHING\n", - "Green action: NODE_APPLICATION_EXECUTE\n", - "Green action: NODE_APPLICATION_EXECUTE\n", - "Blue reward:-1.0\n" - ] - } - ], + "outputs": [], "source": [ "obs, reward, terminated, truncated, info = env.step(13) # patch the database\n", "print(f\"step: {env.game.step_counter}\")\n", @@ -759,21 +499,9 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "step: 39\n", - "Red action: DONOTHING\n", - "Green action: NODE_APPLICATION_EXECUTE\n", - "Green action: DONOTHING\n", - "Blue reward:-0.32\n" - ] - } - ], + "outputs": [], "source": [ "obs, reward, terminated, truncated, info = env.step(0) # patch the database\n", "print(f\"step: {env.game.step_counter}\")\n", @@ -794,49 +522,9 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "step: 139, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 140, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 141, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 142, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 143, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 144, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 145, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 146, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 147, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 148, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 149, Red action: NODE_APPLICATION_EXECUTE, Blue reward:-0.32\n", - "step: 150, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 151, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 152, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 153, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 154, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 155, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 156, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 157, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 158, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 159, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 160, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 161, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 162, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 163, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 164, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 165, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 166, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 167, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 168, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 169, Red action: NODE_APPLICATION_EXECUTE, Blue reward:-0.32\n", - "step: 170, Red action: DONOTHING, Blue reward:-0.32\n", - "step: 171, Red action: DONOTHING, Blue reward:-0.32\n" - ] - } - ], + "outputs": [], "source": [ "env.step(13) # Patch the database\n", "print(f\"step: {env.game.step_counter}, Red action: {info['agent_actions']['data_manipulation_attacker'][0]}, Blue reward:{reward}\" )\n", @@ -868,345 +556,19 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{1: {'position': 0,\n", - " 'permission': 0,\n", - " 'source_node_id': 0,\n", - " 'source_port': 0,\n", - " 'dest_node_id': 0,\n", - " 'dest_port': 0,\n", - " 'protocol': 0},\n", - " 2: {'position': 1,\n", - " 'permission': 0,\n", - " 'source_node_id': 0,\n", - " 'source_port': 0,\n", - " 'dest_node_id': 0,\n", - " 'dest_port': 0,\n", - " 'protocol': 0},\n", - " 3: {'position': 2,\n", - " 'permission': 0,\n", - " 'source_node_id': 0,\n", - " 'source_port': 0,\n", - " 'dest_node_id': 0,\n", - " 'dest_port': 0,\n", - " 'protocol': 0},\n", - " 4: {'position': 3,\n", - " 'permission': 0,\n", - " 'source_node_id': 0,\n", - " 'source_port': 0,\n", - " 'dest_node_id': 0,\n", - " 'dest_port': 0,\n", - " 'protocol': 0},\n", - " 5: {'position': 4,\n", - " 'permission': 2,\n", - " 'source_node_id': 7,\n", - " 'source_port': 1,\n", - " 'dest_node_id': 4,\n", - " 'dest_port': 1,\n", - " 'protocol': 3},\n", - " 6: {'position': 5,\n", - " 'permission': 2,\n", - " 'source_node_id': 8,\n", - " 'source_port': 1,\n", - " 'dest_node_id': 4,\n", - " 'dest_port': 1,\n", - " 'protocol': 3},\n", - " 7: {'position': 6,\n", - " 'permission': 0,\n", - " 'source_node_id': 0,\n", - " 'source_port': 0,\n", - " 'dest_node_id': 0,\n", - " 'dest_port': 0,\n", - " 'protocol': 0},\n", - " 8: {'position': 7,\n", - " 'permission': 0,\n", - " 'source_node_id': 0,\n", - " 'source_port': 0,\n", - " 'dest_node_id': 0,\n", - " 'dest_port': 0,\n", - " 'protocol': 0},\n", - " 9: {'position': 8,\n", - " 'permission': 0,\n", - " 'source_node_id': 0,\n", - " 'source_port': 0,\n", - " 'dest_node_id': 0,\n", - " 'dest_port': 0,\n", - " 'protocol': 0},\n", - " 10: {'position': 9,\n", - " 'permission': 0,\n", - " 'source_node_id': 0,\n", - " 'source_port': 0,\n", - " 'dest_node_id': 0,\n", - " 'dest_port': 0,\n", - " 'protocol': 0}}" - ] - }, - "execution_count": 18, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "obs['ACL']" ] }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [], - "source": [ - "router = env.game.simulation.network.get_node_by_hostname('router_1')" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "+------------------------------------------------------------------------------------------------------------+\n", - "| router_1 Access Control List |\n", - "+-------+--------+----------+---------------+------------------------+--------------+------------------------+\n", - "| Index | Action | Protocol | Src IP | Src Port | Dst IP | Dst Port |\n", - "+-------+--------+----------+---------------+------------------------+--------------+------------------------+\n", - "| 5 | DENY | TCP | 192.168.10.21 | ANY | 192.168.1.14 | ANY |\n", - "| 6 | DENY | TCP | 192.168.10.22 | ANY | 192.168.1.14 | ANY |\n", - "| 18 | PERMIT | ANY | ANY | 5432 (POSTGRES_SERVER) | ANY | 5432 (POSTGRES_SERVER) |\n", - "| 19 | PERMIT | ANY | ANY | 53 (DNS) | ANY | 53 (DNS) |\n", - "| 20 | PERMIT | ANY | ANY | 21 (FTP) | ANY | 21 (FTP) |\n", - "| 21 | PERMIT | ANY | ANY | 80 (HTTP) | ANY | 80 (HTTP) |\n", - "| 22 | PERMIT | ANY | ANY | 219 (ARP) | ANY | 219 (ARP) |\n", - "| 23 | PERMIT | ICMP | ANY | ANY | ANY | ANY |\n", - "| 24 | DENY | ANY | ANY | ANY | ANY | ANY |\n", - "+-------+--------+----------+---------------+------------------------+--------------+------------------------+\n" - ] - } - ], - "source": [ - "router.acl.show()" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[(, 0.34),\n", - " (,\n", - " 0.33),\n", - " (,\n", - " 0.33)]" - ] - }, - "execution_count": 22, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "env.agent.reward_function.reward_components" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": {}, - "outputs": [], - "source": [ - "client_1 = env.game.simulation.network.get_node_by_hostname('client_1')\n", - "client_2 = env.game.simulation.network.get_node_by_hostname('client_2')" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": {}, - "outputs": [], - "source": [ - "client_1_browser = client_1.software_manager.software.get(\"WebBrowser\")\n", - "client_2_browser = client_2.software_manager.software.get(\"WebBrowser\")" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=),\n", - " BrowserHistoryItem(url='http://arcd.com/users/', status=<_HistoryItemStatus.LOADED: 'LOADED'>, response_code=)]" - ] - }, - "execution_count": 26, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "client_2_browser.history" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "False" - ] - }, - "execution_count": 35, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "client_1_browser.get_webpage()" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "metadata": {}, - "outputs": [], - "source": [ - "database_server = env.game.simulation.network.get_node_by_hostname('database_server')" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "File(uuid='390c399a-c2ab-4d84-b98f-d5fc1f9114d2', name='database.db', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, folder_id='e602b9a6-ea1c-4c52-9025-8512d9116b1d', folder_name='database', file_type=, sim_size=15360000, real=False, sim_path=None, sim_root=PosixPath('/home/cade/primaite/3.0.0b6/sessions/2024-02-07/10-58-18/simulation_output/database_server/fs'), folder=Folder(uuid='e602b9a6-ea1c-4c52-9025-8512d9116b1d', name='database', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, files={'390c399a-c2ab-4d84-b98f-d5fc1f9114d2': File(uuid='390c399a-c2ab-4d84-b98f-d5fc1f9114d2', name='database.db', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, folder_id='e602b9a6-ea1c-4c52-9025-8512d9116b1d', folder_name='database', file_type=, sim_size=15360000, real=False, sim_path=None, sim_root=PosixPath('/home/cade/primaite/3.0.0b6/sessions/2024-02-07/10-58-18/simulation_output/database_server/fs'), folder=Folder(uuid='e602b9a6-ea1c-4c52-9025-8512d9116b1d', name='database', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, files={...}, deleted_files={'e63e23dc-c443-4434-822d-3c2c01cbfe1e': File(uuid='e63e23dc-c443-4434-822d-3c2c01cbfe1e', name='database.db', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=True, folder_id='e602b9a6-ea1c-4c52-9025-8512d9116b1d', folder_name='database', file_type=, sim_size=15360000, real=False, sim_path=None, sim_root=PosixPath('/home/cade/primaite/3.0.0b6/sessions/2024-02-07/10-58-18/simulation_output/database_server/fs'), folder=Folder(uuid='e602b9a6-ea1c-4c52-9025-8512d9116b1d', name='database', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, files={...}, deleted_files={...}, scan_duration=3, scan_countdown=-1, red_scan_duration=3, red_scan_countdown=-1, restore_duration=3, restore_countdown=-1, original_file_uuids=['e63e23dc-c443-4434-822d-3c2c01cbfe1e'])), '646a198e-6ac1-4aea-b526-7ca5c2c30dfc': File(uuid='646a198e-6ac1-4aea-b526-7ca5c2c30dfc', name='database.db', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=True, folder_id='e602b9a6-ea1c-4c52-9025-8512d9116b1d', folder_name='database', file_type=, sim_size=15360000, real=False, sim_path=None, sim_root=PosixPath('/home/cade/primaite/3.0.0b6/sessions/2024-02-07/10-58-18/simulation_output/database_server/fs'), folder=Folder(uuid='e602b9a6-ea1c-4c52-9025-8512d9116b1d', name='database', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, files={...}, deleted_files={...}, scan_duration=3, scan_countdown=-1, red_scan_duration=3, red_scan_countdown=-1, restore_duration=3, restore_countdown=-1, original_file_uuids=['e63e23dc-c443-4434-822d-3c2c01cbfe1e'])), '23df7aba-074e-4ffa-939a-d87ad1fe7af1': File(uuid='23df7aba-074e-4ffa-939a-d87ad1fe7af1', name='database.db', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=True, folder_id='e602b9a6-ea1c-4c52-9025-8512d9116b1d', folder_name='database', file_type=, sim_size=15360000, real=False, sim_path=None, sim_root=PosixPath('/home/cade/primaite/3.0.0b6/sessions/2024-02-07/10-58-18/simulation_output/database_server/fs'), folder=Folder(uuid='e602b9a6-ea1c-4c52-9025-8512d9116b1d', name='database', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, files={...}, deleted_files={...}, scan_duration=3, scan_countdown=-1, red_scan_duration=3, red_scan_countdown=-1, restore_duration=3, restore_countdown=-1, original_file_uuids=['e63e23dc-c443-4434-822d-3c2c01cbfe1e']))}, scan_duration=3, scan_countdown=-1, red_scan_duration=3, red_scan_countdown=-1, restore_duration=3, restore_countdown=-1, original_file_uuids=['e63e23dc-c443-4434-822d-3c2c01cbfe1e']))}, deleted_files={'e63e23dc-c443-4434-822d-3c2c01cbfe1e': File(uuid='e63e23dc-c443-4434-822d-3c2c01cbfe1e', name='database.db', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=True, folder_id='e602b9a6-ea1c-4c52-9025-8512d9116b1d', folder_name='database', file_type=, sim_size=15360000, real=False, sim_path=None, sim_root=PosixPath('/home/cade/primaite/3.0.0b6/sessions/2024-02-07/10-58-18/simulation_output/database_server/fs'), folder=Folder(uuid='e602b9a6-ea1c-4c52-9025-8512d9116b1d', name='database', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, files={'390c399a-c2ab-4d84-b98f-d5fc1f9114d2': File(uuid='390c399a-c2ab-4d84-b98f-d5fc1f9114d2', name='database.db', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, folder_id='e602b9a6-ea1c-4c52-9025-8512d9116b1d', folder_name='database', file_type=, sim_size=15360000, real=False, sim_path=None, sim_root=PosixPath('/home/cade/primaite/3.0.0b6/sessions/2024-02-07/10-58-18/simulation_output/database_server/fs'), folder=Folder(uuid='e602b9a6-ea1c-4c52-9025-8512d9116b1d', name='database', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, files={...}, deleted_files={...}, scan_duration=3, scan_countdown=-1, red_scan_duration=3, red_scan_countdown=-1, restore_duration=3, restore_countdown=-1, original_file_uuids=['e63e23dc-c443-4434-822d-3c2c01cbfe1e']))}, deleted_files={...}, scan_duration=3, scan_countdown=-1, red_scan_duration=3, red_scan_countdown=-1, restore_duration=3, restore_countdown=-1, original_file_uuids=['e63e23dc-c443-4434-822d-3c2c01cbfe1e'])), '646a198e-6ac1-4aea-b526-7ca5c2c30dfc': File(uuid='646a198e-6ac1-4aea-b526-7ca5c2c30dfc', name='database.db', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=True, folder_id='e602b9a6-ea1c-4c52-9025-8512d9116b1d', folder_name='database', file_type=, sim_size=15360000, real=False, sim_path=None, sim_root=PosixPath('/home/cade/primaite/3.0.0b6/sessions/2024-02-07/10-58-18/simulation_output/database_server/fs'), folder=Folder(uuid='e602b9a6-ea1c-4c52-9025-8512d9116b1d', name='database', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, files={'390c399a-c2ab-4d84-b98f-d5fc1f9114d2': File(uuid='390c399a-c2ab-4d84-b98f-d5fc1f9114d2', name='database.db', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, folder_id='e602b9a6-ea1c-4c52-9025-8512d9116b1d', folder_name='database', file_type=, sim_size=15360000, real=False, sim_path=None, sim_root=PosixPath('/home/cade/primaite/3.0.0b6/sessions/2024-02-07/10-58-18/simulation_output/database_server/fs'), folder=Folder(uuid='e602b9a6-ea1c-4c52-9025-8512d9116b1d', name='database', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, files={...}, deleted_files={...}, scan_duration=3, scan_countdown=-1, red_scan_duration=3, red_scan_countdown=-1, restore_duration=3, restore_countdown=-1, original_file_uuids=['e63e23dc-c443-4434-822d-3c2c01cbfe1e']))}, deleted_files={...}, scan_duration=3, scan_countdown=-1, red_scan_duration=3, red_scan_countdown=-1, restore_duration=3, restore_countdown=-1, original_file_uuids=['e63e23dc-c443-4434-822d-3c2c01cbfe1e'])), '23df7aba-074e-4ffa-939a-d87ad1fe7af1': File(uuid='23df7aba-074e-4ffa-939a-d87ad1fe7af1', name='database.db', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=True, folder_id='e602b9a6-ea1c-4c52-9025-8512d9116b1d', folder_name='database', file_type=, sim_size=15360000, real=False, sim_path=None, sim_root=PosixPath('/home/cade/primaite/3.0.0b6/sessions/2024-02-07/10-58-18/simulation_output/database_server/fs'), folder=Folder(uuid='e602b9a6-ea1c-4c52-9025-8512d9116b1d', name='database', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, files={'390c399a-c2ab-4d84-b98f-d5fc1f9114d2': File(uuid='390c399a-c2ab-4d84-b98f-d5fc1f9114d2', name='database.db', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, folder_id='e602b9a6-ea1c-4c52-9025-8512d9116b1d', folder_name='database', file_type=, sim_size=15360000, real=False, sim_path=None, sim_root=PosixPath('/home/cade/primaite/3.0.0b6/sessions/2024-02-07/10-58-18/simulation_output/database_server/fs'), folder=Folder(uuid='e602b9a6-ea1c-4c52-9025-8512d9116b1d', name='database', health_status=, visible_health_status=, previous_hash=None, revealed_to_red=False, sys_log=, deleted=False, files={...}, deleted_files={...}, scan_duration=3, scan_countdown=-1, red_scan_duration=3, red_scan_countdown=-1, restore_duration=3, restore_countdown=-1, original_file_uuids=['e63e23dc-c443-4434-822d-3c2c01cbfe1e']))}, deleted_files={...}, scan_duration=3, scan_countdown=-1, red_scan_duration=3, red_scan_countdown=-1, restore_duration=3, restore_countdown=-1, original_file_uuids=['e63e23dc-c443-4434-822d-3c2c01cbfe1e']))}, scan_duration=3, scan_countdown=-1, red_scan_duration=3, red_scan_countdown=-1, restore_duration=3, restore_countdown=-1, original_file_uuids=['e63e23dc-c443-4434-822d-3c2c01cbfe1e']))" - ] - }, - "execution_count": 31, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "database_server.file_system.get_file('database', 'database.db')" - ] - }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "database_server." - ] + "source": [] } ], "metadata": { From 76db5dbaa234e32404ff9f89f1cd63b71137be10 Mon Sep 17 00:00:00 2001 From: Marek Wolan Date: Tue, 20 Feb 2024 12:05:02 +0000 Subject: [PATCH 5/7] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc39a2b9..79cce02a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +- Changed the red agent in the data manipulation scenario to randomly choose client 1 or client 2 to start its attack. - Changed the data manipulation scenario to include a second green agent on client 1. - Refactored actions and observations to be configurable via object name, instead of UUID. - Fixed a bug where ACL rules were not resetting on episode reset. From f7c1da31185cafaf1c01223c8bb137057f29bde0 Mon Sep 17 00:00:00 2001 From: Marek Wolan Date: Tue, 20 Feb 2024 12:06:30 +0000 Subject: [PATCH 6/7] Update MARL config. --- .../config/_package_data/example_config_2_rl_agents.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/primaite/config/_package_data/example_config_2_rl_agents.yaml b/src/primaite/config/_package_data/example_config_2_rl_agents.yaml index 993b3283..6d5b3602 100644 --- a/src/primaite/config/_package_data/example_config_2_rl_agents.yaml +++ b/src/primaite/config/_package_data/example_config_2_rl_agents.yaml @@ -74,7 +74,10 @@ agents: nodes: - node_ref: client_1 applications: - - application_ref: data_manipulation_bot + - 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 From 88f8e9cb42322a236d3718136afb52adb87ae1be Mon Sep 17 00:00:00 2001 From: Marek Wolan Date: Tue, 20 Feb 2024 12:09:32 +0000 Subject: [PATCH 7/7] Add todo comment. --- src/primaite/simulator/system/applications/database_client.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/primaite/simulator/system/applications/database_client.py b/src/primaite/simulator/system/applications/database_client.py index dfa5e445..2e0f4e3f 100644 --- a/src/primaite/simulator/system/applications/database_client.py +++ b/src/primaite/simulator/system/applications/database_client.py @@ -195,6 +195,7 @@ class DatabaseClient(Application): if connection_id is None: if self.connections: connection_id = list(self.connections.keys())[-1] + # TODO: if the most recent connection dies, it should be automatically cleared. else: connection_id = str(uuid4())