Skip to content

Commit a12f84b

Browse files
authored
Merge pull request #452 from stratosphereips/ondra-update-required-cyst-core-version
Ondra update required cyst core version
2 parents b3567e8 + 5ec26a4 commit a12f84b

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

examples/example_task_configuration.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ coordinator:
99
Attacker: # Configuration of 'Attacker' agents
1010
max_steps: 50
1111
goal:
12-
description: "Exfiltrate data from Samba server to remote C&C server."
12+
description: "Exfiltrate data from Samba server to remote C&C server (213.47.23.195)."
1313
is_any_part_of_goal_random: True
1414
known_networks: []
1515
known_hosts: []

netsecgame/game/config_parser.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,13 @@ def get_goal_description(self, agent_role)->str:
304304
case "Attacker":
305305
try:
306306
description = self.config['coordinator']['agents'][agent_role]["goal"]["description"]
307+
self.validate_goal_description(agent_role, description)
307308
except KeyError:
308309
description = ""
309310
case "Defender":
310311
try:
311312
description = self.config['coordinator']['agents'][agent_role]["goal"]["description"]
313+
self.validate_goal_description(agent_role, description)
312314
except KeyError:
313315
description = ""
314316
case "Benign":
@@ -317,6 +319,37 @@ def get_goal_description(self, agent_role)->str:
317319
raise ValueError(f"Unsupported agent role: {agent_role}")
318320
return description
319321

322+
def validate_goal_description(self, agent_role: str, description: str):
323+
"""
324+
Warns if the goal description misses key targets from the actual win conditions.
325+
"""
326+
if not description:
327+
return # No description to validate
328+
329+
description_lower = description.lower()
330+
missing_elements = []
331+
332+
try:
333+
win_conditions = self.config['coordinator']['agents'][agent_role]['goal']
334+
except KeyError:
335+
return
336+
337+
# Check controlled hosts
338+
for host in win_conditions.get('controlled_hosts', []):
339+
if str(host) not in description_lower and str(host) != "random":
340+
missing_elements.append(f"Controlled Host: {host}")
341+
342+
# Check known data targets
343+
for host, data_set in win_conditions.get('known_data', {}).items():
344+
if str(host) not in description_lower and str(host) != "random":
345+
# Only require host IP if it isn't "random"
346+
missing_elements.append(f"Target Host IP defined for data: {host}")
347+
348+
if missing_elements:
349+
self.logger.warning(
350+
f"[{agent_role}] Goal description '{description}' might be missing some actual win condition targets: {missing_elements}"
351+
)
352+
320353
def get_rewards(self, reward_names:list, default_value=0)->dict:
321354
"Reads configuration for rewards for cases listed in 'rewards_names'"
322355
rewards = {}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ requires-python = ">=3.12"
3030
# dependencies allowing to run the game server and the simulation
3131
server = [
3232
"aiohttp>=3.11",
33-
"cyst-core>=0.5.0",
33+
"cyst-core>=0.6.6",
3434
"Faker>=23.2",
3535
"numpy>=1.26",
3636
"PyYAML>=6.0",

0 commit comments

Comments
 (0)