From 452f8205d241f6964a1c74e1e97a04c900621335 Mon Sep 17 00:00:00 2001 From: Sebastian Garcia Date: Sat, 16 Aug 2025 18:35:07 +0200 Subject: [PATCH 1/2] Fix the log_parser because it gave errors. --- AIDojoCoordinator/utils/log_parser.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/AIDojoCoordinator/utils/log_parser.py b/AIDojoCoordinator/utils/log_parser.py index dd671dfe..11d3822c 100644 --- a/AIDojoCoordinator/utils/log_parser.py +++ b/AIDojoCoordinator/utils/log_parser.py @@ -11,14 +11,18 @@ def calculate_episode_lengths(step_sequence): Given the list with step numbers calculate the length of each episode and return a list of episode lengths. """ + if not step_sequence: + return [] + episode_lengths = [] for i in range(1, len(step_sequence)): - if step_seq[i] == 0: + if step_sequence[i] == 0: # If the step is zero then it's a new episode # Take the last value as episode length episode_lengths.append(step_sequence[i - 1] + 1) # For the last episode take the latest step value - episode_lengths.append(step_sequence[-1] + 1) + if step_sequence: # Only append if we have steps + episode_lengths.append(step_sequence[-1] + 1) return episode_lengths def reached_limit(current_step, max_steps, invalid_steps): @@ -131,6 +135,12 @@ def reached_limit(current_step, max_steps, invalid_steps): print(f"Episodes: {len(episode_starts)}") print(f"Wins: {total_wins}") print(f"Detections: {total_detected}") + + # Add validation for when no episodes were found + if len(episode_starts) == 0: + print("No episodes found in the log file.") + exit(0) + print(f"Win rate: {100*total_wins/len(episode_starts):.3f}%") print(f"Detection rate: {100*total_detected/len(episode_starts):.3f}%") print(f"Average return: {np.mean(rewards):.3f} +- {np.std(rewards):.3f}") From b2deb3653c6f3f254eeb46e1ca823e0dc01042cd Mon Sep 17 00:00:00 2001 From: Sebastian Garcia Date: Mon, 18 Aug 2025 11:26:52 +0200 Subject: [PATCH 2/2] Update the scenario1 to include port numbers in the text description. It is not a new field, so it should not affect other code. --- .../scenarios/scenario_configuration.py | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/AIDojoCoordinator/scenarios/scenario_configuration.py b/AIDojoCoordinator/scenarios/scenario_configuration.py index ccb13efb..84a7b9b1 100644 --- a/AIDojoCoordinator/scenarios/scenario_configuration.py +++ b/AIDojoCoordinator/scenarios/scenario_configuration.py @@ -28,7 +28,7 @@ active_services=[], passive_services=[ cyst_cfg.PassiveServiceConfig( - name="microsoft-ds", + name="445/tcp, microsoft-ds", owner="Local system", version="10.0.19041", local=False, @@ -69,7 +69,7 @@ ] ), cyst_cfg.PassiveServiceConfig( - name="ms-wbt-server", + name="3389/tcp, ms-wbt-server", owner="Local system", version="10.0.19041", local=False, @@ -133,7 +133,7 @@ active_services=[], passive_services=[ cyst_cfg.PassiveServiceConfig( - name="ssh", + name="22/tcp, ssh", owner="openssh", version="8.1.0", local=False, @@ -159,7 +159,7 @@ )] ), cyst_cfg.PassiveServiceConfig( - name="postgresql", + name="5432/tcp, postgresql", owner="postgresql", version="14.3.0", private_data=[ @@ -199,7 +199,7 @@ active_services=[], passive_services=[ cyst_cfg.PassiveServiceConfig( - name="http", + name="80/tcp, http", owner="lighttpd", version="1.4.54", local=False, @@ -216,7 +216,7 @@ access_schemes=[] ), cyst_cfg.PassiveServiceConfig( - name="ssh", + name="22/tcp, ssh", owner="openssh", version="8.1.0", local=False, @@ -266,7 +266,7 @@ active_services=[], passive_services=[ cyst_cfg.PassiveServiceConfig( - name="ssh", + name="22/tcp, ssh", owner="openssh", version="8.1.0", local=False, @@ -311,7 +311,7 @@ active_services=[], passive_services=[ cyst_cfg.PassiveServiceConfig( - name="ssh", + name="22/tcp, ssh", owner="openssh", version="8.1.0", local=False, @@ -367,7 +367,7 @@ ], passive_services=[ cyst_cfg.PassiveServiceConfig( - name="ms-wbt-server", + name="3389/tcp, ms-wbt-server", owner="Local system", version="10.0.19041", local=False, @@ -424,7 +424,7 @@ active_services=[], passive_services=[ cyst_cfg.PassiveServiceConfig( - name="ms-wbt-server", + name="3389/tcp, ms-wbt-server", owner="Local system", version="10.0.19041", local=False, @@ -481,7 +481,7 @@ active_services=[], passive_services=[ cyst_cfg.PassiveServiceConfig( - name="ssh", + name="22/tcp, ssh", owner="openssh", version="8.1.0", local=False, @@ -536,7 +536,7 @@ active_services=[], passive_services=[ cyst_cfg.PassiveServiceConfig( - name="ssh", + name="22/tcp, ssh", owner="openssh", version="8.1.0", local=False, @@ -754,7 +754,7 @@ ExploitConfig( services=[ VulnerableServiceConfig( - service="microsoft-ds", + service="445/tcp, microsoft-ds", min_version="10.0. 19041", max_version="10.0.19041" )