Zenoharsh01 commited on
Commit
2d8dc8b
·
verified ·
1 Parent(s): 57ff7d4

Update tasks.py

Browse files
Files changed (1) hide show
  1. tasks.py +22 -10
tasks.py CHANGED
@@ -49,19 +49,31 @@ def grade_task_3_kill_chain(env: SOCEnvironment) -> float:
49
  """
50
  compromised_host = "10.0.1.55"
51
 
52
- # 0.01 - Failure: The compromised host was never isolated. Malware reaches the database.
53
  if compromised_host not in env.isolated_hosts:
54
  return 0.01
55
 
56
- # Efficiency grading (all inside the 0 to 1 boundary)
57
- if env.step_count <= 2:
58
- return 0.99 # Perfect efficiency
59
- elif env.step_count <= 5:
60
- return 0.7 # Good, but took a few unnecessary actions
61
- elif env.step_count <= 9:
62
- return 0.4 # Barely caught it in time
63
- else:
64
- return 0.1 # Isolated it at the very last possible second
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
 
67
  # A master dictionary to easily call the right grader dynamically during evaluation
 
49
  """
50
  compromised_host = "10.0.1.55"
51
 
52
+ # 0.01 - Critical Failure: The compromised host was never isolated.
53
  if compromised_host not in env.isolated_hosts:
54
  return 0.01
55
 
56
+ # Variables for continuous decay
57
+ optimal_steps = 2
58
+ max_steps = 10
59
+ max_score = 0.99
60
+ min_passing_score = 0.10
61
+
62
+ # If perfect, return max instantly
63
+ if env.step_count <= optimal_steps:
64
+ return max_score
65
+
66
+ # Calculate the continuous linear decay
67
+ excess_steps = env.step_count - optimal_steps
68
+ max_excess = max_steps - optimal_steps
69
+
70
+ continuous_score = max_score - (excess_steps / max_excess) * (max_score - min_passing_score)
71
+
72
+ # Clamp the result just to be mathematically safe against boundary errors
73
+ final_score = max(0.01, min(0.99, continuous_score))
74
+
75
+ # Round to 3 decimal places to prevent JSON parser float errors on the backend
76
+ return round(float(final_score), 3)
77
 
78
 
79
  # A master dictionary to easily call the right grader dynamically during evaluation