Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion AIDojoCoordinator/worlds/NSEGameCoordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand All @@ -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")

Expand Down Expand Up @@ -229,15 +231,17 @@ 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}"
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
Expand Down Expand Up @@ -920,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 = {}
Expand Down