From c9d2c85721761edfbeb524adaa2c6ce1a1affcae Mon Sep 17 00:00:00 2001 From: Sebastian Garcia Date: Wed, 3 Sep 2025 23:33:19 +0200 Subject: [PATCH 1/2] Fix the the netsecenv an issue not reading all the data from each host while reading the configuration --- AIDojoCoordinator/worlds/NSEGameCoordinator.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/AIDojoCoordinator/worlds/NSEGameCoordinator.py b/AIDojoCoordinator/worlds/NSEGameCoordinator.py index 0917b99a..35a27ada 100644 --- a/AIDojoCoordinator/worlds/NSEGameCoordinator.py +++ b/AIDojoCoordinator/worlds/NSEGameCoordinator.py @@ -229,15 +229,22 @@ def process_node_config(node_obj:NodeConfig) -> None: self.logger.info(f"\t\t\tProcessing data in node '{node_obj.id}':'{service.name}' service") try: for data in service.private_data: + self.logger.info(f"\t\t\t\tData: {data}") if node_obj.id not in self._data: self._data[node_obj.id] = set() datapoint = Data(data.owner, data.description) self._data[node_obj.id].add(datapoint) # add content - self._data_content[node_obj.id, datapoint.id] = f"Content of {datapoint.id}" + try: + self._data_content[node_obj.id, datapoint.id] = f"Content of {datapoint.id}" + except AttributeError: + # If self._data_content does not exist, create it here. + self._data_content = {} + self._data_content[node_obj.id, datapoint.id] = f"Content of {datapoint.id}" except AttributeError: + # Service does not contain any data pass - #service does not contain any data + def process_router_config(router_obj:RouterConfig)->None: self.logger.info(f"\tProcessing config of router '{router_obj.id}'") # Process a router From c655266e743476fa142ee1153af6e4eb4103d20a Mon Sep 17 00:00:00 2001 From: Sebastian Garcia Date: Thu, 4 Sep 2025 08:31:21 +0200 Subject: [PATCH 2/2] Better fix of issue with data read. Just create the proper variable. --- AIDojoCoordinator/worlds/NSEGameCoordinator.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/AIDojoCoordinator/worlds/NSEGameCoordinator.py b/AIDojoCoordinator/worlds/NSEGameCoordinator.py index 35a27ada..dd64106b 100644 --- a/AIDojoCoordinator/worlds/NSEGameCoordinator.py +++ b/AIDojoCoordinator/worlds/NSEGameCoordinator.py @@ -27,6 +27,7 @@ def __init__(self, game_host, game_port, task_config:str, allowed_roles=["Attack self._networks = {} # A `dict` of the networks present in the environment. Keys: `Network` objects, values `set` of `IP` objects. self._services = {} # Dict of all services in the environment. Keys: hostname (`str`), values: `set` of `Service` objetcs. self._data = {} # Dict of all services in the environment. Keys: hostname (`str`), values `set` of `Service` objetcs. + self._data_content = {} # ??? Not sure. Added by by sebas to fix error in reading config file self._firewall = {} # dict of all the allowed connections in the environment. Keys `IP` ,values: `set` of `IP` objects. self._fw_blocks = {} self._agent_fw_rules = {} @@ -53,6 +54,7 @@ def _initialize(self)->None: Faker.seed(self._seed) # store initial values for parts which are modified during the game self._data_original = copy.deepcopy(self._data) + self._data_content_original = copy.deepcopy(self._data_content) self._firewall_original = copy.deepcopy(self._firewall) self.logger.info("Environment initialization finished") @@ -235,12 +237,7 @@ def process_node_config(node_obj:NodeConfig) -> None: datapoint = Data(data.owner, data.description) self._data[node_obj.id].add(datapoint) # add content - try: - self._data_content[node_obj.id, datapoint.id] = f"Content of {datapoint.id}" - except AttributeError: - # If self._data_content does not exist, create it here. - self._data_content = {} - self._data_content[node_obj.id, datapoint.id] = f"Content of {datapoint.id}" + self._data_content[node_obj.id, datapoint.id] = f"Content of {datapoint.id}" except AttributeError: # Service does not contain any data pass @@ -927,6 +924,7 @@ async def reset(self)->bool: # reset self._data to orignal state self._data = copy.deepcopy(self._data_original) # reset self._data_content to orignal state + self._data_content = copy.deepcopy(self._data_content_original) # reset all firewall related data structure self._firewall = copy.deepcopy(self._firewall_original) self._fw_blocks = {}