From 7053d6d3f2cee8bb96ce10991ea8a785072822fc Mon Sep 17 00:00:00 2001 From: Joakim Loxdal Date: Mon, 14 Oct 2024 17:03:51 +0200 Subject: [PATCH] Remove base false positive/negative rates --- README.md | 4 ---- malsim/scenario.py | 9 --------- tests/test_scenario.py | 13 +++++++++---- .../scenarios/traininglang_fp_fn_scenario.yml | 4 ---- 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 1cef4870..85d55f35 100644 --- a/README.md +++ b/README.md @@ -102,10 +102,6 @@ observable_attack_steps: # will be observed as inactive at a rate of x in each observation # Default false positive/negative rate is 0, which is assumed if none are given. -# A baseline that applies to all attack steps (default 0) -false_positive_base_rate: -false_negative_base_rate: - # Applies false positive rates per attack step (default 0) false_positive_rates: : diff --git a/malsim/scenario.py b/malsim/scenario.py index 712285c0..57258c7f 100644 --- a/malsim/scenario.py +++ b/malsim/scenario.py @@ -42,9 +42,7 @@ 'rewards', 'attacker_entry_points', 'observable_attack_steps', - 'false_positive_base_rate', 'false_positive_rates', - 'false_negative_base_rate', 'false_negative_rates', ] @@ -193,13 +191,6 @@ def apply_scenario_false_positive_and_negative_rates( AttackGraph either to the default value, from the base rate or from the specifically set rates per attack step""" - # Apply false positive/negative base rates for all nodes (default 0) - fp_baseline = scenario_conf.get('false_positive_base_rate', 0) - fn_baseline = scenario_conf.get('false_negative_base_rate', 0) - for node in attack_graph.nodes: - node.extras['false_positive_rate'] = fp_baseline - node.extras['false_negative_rate'] = fn_baseline - # Apply false positive rates to specified attack nodes fp_rates_per_attackstep = scenario_conf.get('false_positive_rates') if fp_rates_per_attackstep: diff --git a/tests/test_scenario.py b/tests/test_scenario.py index 7705a2ac..559859f5 100644 --- a/tests/test_scenario.py +++ b/tests/test_scenario.py @@ -274,12 +274,13 @@ def test_load_scenario_false_positive_negative_rate(): ) # Defined in scenario file - fp_base_rate = 0.1 - fn_base_rate = 0.1 + fp_base_rate = 0 + fn_base_rate = 0 host_0_access_fp_rate = 0.2 host_1_access_fp_rate = 0.3 host_0_access_fn_rate = 0.4 host_1_access_fn_rate = 0.5 + user_3_compromise_fn_rate = 1.0 for node in attack_graph.nodes: if node.full_name == "Host:0:access": @@ -288,6 +289,10 @@ def test_load_scenario_false_positive_negative_rate(): elif node.full_name == "Host:1:access": assert node.extras['false_positive_rate'] == host_1_access_fp_rate assert node.extras['false_negative_rate'] == host_1_access_fn_rate + elif node.full_name == "User:3:compromise": + assert 'false_positive_rate' not in node.extras + assert node.extras['false_negative_rate'] \ + == user_3_compromise_fn_rate else: - assert node.extras['false_positive_rate'] == fp_base_rate - assert node.extras['false_negative_rate'] == fn_base_rate + assert 'false_positive_rate' not in node.extras + assert 'false_negative_rate' not in node.extras diff --git a/tests/testdata/scenarios/traininglang_fp_fn_scenario.yml b/tests/testdata/scenarios/traininglang_fp_fn_scenario.yml index 69e24041..fb83ca34 100644 --- a/tests/testdata/scenarios/traininglang_fp_fn_scenario.yml +++ b/tests/testdata/scenarios/traininglang_fp_fn_scenario.yml @@ -20,10 +20,6 @@ attacker_entry_points: attacker_agent_class: 'BreadthFirstAttacker' defender_agent_class: 'KeyboardAgent' -# Baseline applies to all attack steps -false_positive_base_rate: 0.1 -false_negative_base_rate: 0.1 - # Specific fpr/fnr for some specific steps false_positive_rates: 'Host:0:access': 0.2