Spaces:
Sleeping
Sleeping
Update tasks.py
Browse files
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.
|
| 53 |
if compromised_host not in env.isolated_hosts:
|
| 54 |
return 0.01
|
| 55 |
|
| 56 |
-
#
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|