Skip to content

Commit 6ddc356

Browse files
committed
feat: Add goal description validation to the config parser and update an example attacker goal with a specific C&C IP.
1 parent b3567e8 commit 6ddc356

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

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 = {}

0 commit comments

Comments
 (0)