mal-simulator 3.0.1__tar.gz → 3.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mal_simulator-3.0.1/mal_simulator.egg-info → mal_simulator-3.2.0}/PKG-INFO +3 -1
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/README.md +2 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0/mal_simulator.egg-info}/PKG-INFO +3 -1
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/__init__.py +2 -2
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/attack_surface.py +0 -2
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/attacker_state_factories.py +1 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/attacker_step.py +2 -5
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/simulator.py +11 -1
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/scenario/scenario.py +5 -2
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/pyproject.toml +1 -1
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/tests/test_scenario.py +33 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/AUTHORS +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/LICENSE +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/mal_simulator.egg-info/SOURCES.txt +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/mal_simulator.egg-info/dependency_links.txt +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/mal_simulator.egg-info/entry_points.txt +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/mal_simulator.egg-info/requires.txt +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/mal_simulator.egg-info/top_level.txt +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/__main__.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/config/__init__.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/config/agent_settings.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/config/agent_settings_factories.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/config/node_property_rule.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/config/sim_settings.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/envs/__init__.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/envs/base_classes.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/envs/graph/__init__.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/envs/graph/graph_env.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/envs/graph/mal_spaces.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/envs/graph/serialization.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/envs/graph/utils.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/envs/graph/wrapper.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/__init__.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/agent_state.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/agent_states.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/attacker_state.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/defender_state.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/defender_state_factories.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/defender_step.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/defense_surface.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/event_logger.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/false_alerts.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/graph_processing.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/graph_state.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/graph_utils.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/node_getters.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/observability.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/reset_agent.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/rewards.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/run_simulation.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/simulator_state.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/simulator_static_data.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/state_query.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/ttc_utils.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/policies/__init__.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/policies/attackers/__init__.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/policies/attackers/searchers.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/policies/attackers/shortest_path.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/policies/attackers/ttc_soft_min.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/policies/decision_agent.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/policies/defenders/__init__.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/policies/defenders/heuristic_agent.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/policies/keyboard_input.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/policies/passive_agent.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/policies/random_agent.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/policies/utils/path_finding.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/scenario/__init__.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/types.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/visualization/malsim_gui_client.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/setup.cfg +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/tests/test_attacker.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/tests/test_attacker_settings.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/tests/test_defender.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/tests/test_event_logger.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/tests/test_graph_processing.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/tests/test_main.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/tests/test_mal_simulator.py +0 -0
- {mal_simulator-3.0.1 → mal_simulator-3.2.0}/tests/test_ttc_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mal-simulator
|
|
3
|
-
Version: 3.0
|
|
3
|
+
Version: 3.2.0
|
|
4
4
|
Summary: A MAL compliant simulator.
|
|
5
5
|
Author-email: Andrei Buhaiu <buhaiu@kth.se>, Joakim Loxdal <loxdal@kth.se>, Jakob Nyberg <jaknyb@kth.se>, Nikolaos Kakouros <nkak@kth.se>, Sandor Berglund <sandorb@kth.se>
|
|
6
6
|
License: Apache Software License
|
|
@@ -53,6 +53,8 @@ For in-depth documentation, refer to:
|
|
|
53
53
|
- The official **[Wiki](https://github.com/mal-lang/mal-simulator/wiki)**.
|
|
54
54
|
- The official MAL infrastructure **[tutorials](https://github.com/mal-lang/mal-tutorials)**.
|
|
55
55
|
|
|
56
|
+
The simulator also has a DOI at the KTH Open and FAIR Data repository for easier referencing: [10.71775/kth.gx42q-9m748](https://doi.org/10.71775/kth.gx42q-9m748)
|
|
57
|
+
|
|
56
58
|
## Contributing
|
|
57
59
|
|
|
58
60
|
- Use [Conventional commits](https://www.conventionalcommits.org/en/v1.0.0/)
|
|
@@ -14,6 +14,8 @@ For in-depth documentation, refer to:
|
|
|
14
14
|
- The official **[Wiki](https://github.com/mal-lang/mal-simulator/wiki)**.
|
|
15
15
|
- The official MAL infrastructure **[tutorials](https://github.com/mal-lang/mal-tutorials)**.
|
|
16
16
|
|
|
17
|
+
The simulator also has a DOI at the KTH Open and FAIR Data repository for easier referencing: [10.71775/kth.gx42q-9m748](https://doi.org/10.71775/kth.gx42q-9m748)
|
|
18
|
+
|
|
17
19
|
## Contributing
|
|
18
20
|
|
|
19
21
|
- Use [Conventional commits](https://www.conventionalcommits.org/en/v1.0.0/)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mal-simulator
|
|
3
|
-
Version: 3.0
|
|
3
|
+
Version: 3.2.0
|
|
4
4
|
Summary: A MAL compliant simulator.
|
|
5
5
|
Author-email: Andrei Buhaiu <buhaiu@kth.se>, Joakim Loxdal <loxdal@kth.se>, Jakob Nyberg <jaknyb@kth.se>, Nikolaos Kakouros <nkak@kth.se>, Sandor Berglund <sandorb@kth.se>
|
|
6
6
|
License: Apache Software License
|
|
@@ -53,6 +53,8 @@ For in-depth documentation, refer to:
|
|
|
53
53
|
- The official **[Wiki](https://github.com/mal-lang/mal-simulator/wiki)**.
|
|
54
54
|
- The official MAL infrastructure **[tutorials](https://github.com/mal-lang/mal-tutorials)**.
|
|
55
55
|
|
|
56
|
+
The simulator also has a DOI at the KTH Open and FAIR Data repository for easier referencing: [10.71775/kth.gx42q-9m748](https://doi.org/10.71775/kth.gx42q-9m748)
|
|
57
|
+
|
|
56
58
|
## Contributing
|
|
57
59
|
|
|
58
60
|
- Use [Conventional commits](https://www.conventionalcommits.org/en/v1.0.0/)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# MAL Simulator v3.0
|
|
1
|
+
# MAL Simulator v3.2.0
|
|
2
2
|
# Copyright 2025, Andrei Buhaiu.
|
|
3
3
|
#
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -26,7 +26,7 @@ from malsim.scenario import Scenario
|
|
|
26
26
|
from malsim.config import AttackerSettings, DefenderSettings
|
|
27
27
|
|
|
28
28
|
__title__ = 'malsim'
|
|
29
|
-
__version__ = '3.0
|
|
29
|
+
__version__ = '3.2.0'
|
|
30
30
|
__authors__ = [
|
|
31
31
|
'Andrei Buhaiu',
|
|
32
32
|
'Joakim Loxdal',
|
|
@@ -9,7 +9,6 @@ from malsim.mal_simulator.graph_utils import (
|
|
|
9
9
|
node_is_actionable,
|
|
10
10
|
node_is_necessary,
|
|
11
11
|
node_is_traversable,
|
|
12
|
-
node_is_blocked,
|
|
13
12
|
)
|
|
14
13
|
|
|
15
14
|
if TYPE_CHECKING:
|
|
@@ -83,7 +82,6 @@ def get_attack_surface(
|
|
|
83
82
|
is_action = node.causal_mode != 'effect'
|
|
84
83
|
return (
|
|
85
84
|
is_action
|
|
86
|
-
and not node_is_blocked(sim_state, node)
|
|
87
85
|
and (uncompromised(node) if skip_compromised else True)
|
|
88
86
|
and (necessary(node) if skip_unnecessary else True)
|
|
89
87
|
and actionable(node)
|
|
@@ -9,7 +9,6 @@ from maltoolbox.attackgraph import AttackGraphNode
|
|
|
9
9
|
from malsim.mal_simulator.attack_surface import get_effects_of_attack_step
|
|
10
10
|
from malsim.mal_simulator.graph_utils import (
|
|
11
11
|
node_is_traversable,
|
|
12
|
-
node_is_blocked,
|
|
13
12
|
)
|
|
14
13
|
from malsim.mal_simulator.state_query import node_ttc_value
|
|
15
14
|
from malsim.config.sim_settings import TTCMode
|
|
@@ -143,10 +142,8 @@ def attacker_step(
|
|
|
143
142
|
can_compromise = True
|
|
144
143
|
else:
|
|
145
144
|
# Otherwise attacker is limited by attack surface and traversability
|
|
146
|
-
can_compromise = (
|
|
147
|
-
|
|
148
|
-
and not node_is_blocked(sim_state, node)
|
|
149
|
-
and node_is_traversable(sim_state, agent.performed_nodes, node)
|
|
145
|
+
can_compromise = node in agent.action_surface and node_is_traversable(
|
|
146
|
+
sim_state, agent.performed_nodes, node
|
|
150
147
|
)
|
|
151
148
|
|
|
152
149
|
if can_compromise:
|
|
@@ -328,7 +328,13 @@ class MalSimulator:
|
|
|
328
328
|
def agent_is_terminated(self, agent_name: str) -> bool:
|
|
329
329
|
return agent_is_terminated(self._agent_states, agent_name)
|
|
330
330
|
|
|
331
|
-
def reset(
|
|
331
|
+
def reset(
|
|
332
|
+
self, seed: int | None = None
|
|
333
|
+
) -> dict[str, AttackerState | DefenderState]:
|
|
334
|
+
"""
|
|
335
|
+
Reset the simulator to the initial state.
|
|
336
|
+
Optionally, a seed can be provided to re-seed the random number generator.
|
|
337
|
+
"""
|
|
332
338
|
(
|
|
333
339
|
self._agent_states,
|
|
334
340
|
self.sim_state,
|
|
@@ -339,6 +345,10 @@ class MalSimulator:
|
|
|
339
345
|
self.rng,
|
|
340
346
|
self.rest_api_client,
|
|
341
347
|
)
|
|
348
|
+
|
|
349
|
+
if seed is not None:
|
|
350
|
+
self.rng = default_rng(seed)
|
|
351
|
+
|
|
342
352
|
return self._agent_states
|
|
343
353
|
|
|
344
354
|
@property
|
|
@@ -273,8 +273,11 @@ def load_scenario_dict(scenario_file: str) -> Mapping[str, Any]:
|
|
|
273
273
|
)
|
|
274
274
|
scenario = dict(_extend_scenario(original_scenario_path, scenario))
|
|
275
275
|
|
|
276
|
-
# Convert path relative to scenario file
|
|
277
|
-
scenario['lang_file']
|
|
276
|
+
# Convert path relative to scenario file if lang_file is a local file
|
|
277
|
+
if not scenario['lang_file'].startswith('git@'):
|
|
278
|
+
scenario['lang_file'] = path_relative_to_file_dir(
|
|
279
|
+
scenario['lang_file'], s_file
|
|
280
|
+
)
|
|
278
281
|
|
|
279
282
|
if 'model_file' in scenario:
|
|
280
283
|
scenario['model_file'] = path_relative_to_file_dir(
|
|
@@ -56,6 +56,39 @@ def test_load_scenario() -> None:
|
|
|
56
56
|
assert scenario.defender_settings['Defender1'].policy == PassiveAgent
|
|
57
57
|
|
|
58
58
|
|
|
59
|
+
@pytest.mark.integration
|
|
60
|
+
def test_load_scenario_git_url_as_lang() -> None:
|
|
61
|
+
"""Make sure we can load a scenario with git url as lang file"""
|
|
62
|
+
|
|
63
|
+
# Load the scenario
|
|
64
|
+
scenario = Scenario.load_from_file(
|
|
65
|
+
path_relative_to_tests('./testdata/scenarios/simple_scenario_git_url.yml')
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
# Results should be the same as loading the scenario with a local lang file
|
|
69
|
+
assert scenario.defender_settings['Defender1'].rewards
|
|
70
|
+
rewards_per_node = scenario.defender_settings['Defender1'].rewards
|
|
71
|
+
assert rewards_per_node.by_asset_name
|
|
72
|
+
# Verify rewards were added as defined in './testdata/simple_scenario_git_url.yml'
|
|
73
|
+
assert rewards_per_node.by_asset_name['OS App']['notPresent'] == 2
|
|
74
|
+
assert rewards_per_node.by_asset_name['OS App']['supplyChainAuditing'] == 7
|
|
75
|
+
assert rewards_per_node.by_asset_name['Program 1']['notPresent'] == 3
|
|
76
|
+
assert rewards_per_node.by_asset_name['Program 1']['supplyChainAuditing'] == 7
|
|
77
|
+
assert rewards_per_node.by_asset_name['SoftwareVulnerability:4']['notPresent'] == 4
|
|
78
|
+
assert rewards_per_node.by_asset_name['Data:5']['notPresent'] == 1
|
|
79
|
+
assert rewards_per_node.by_asset_name['Credentials:6']['notPhishable'] == 7
|
|
80
|
+
assert rewards_per_node.by_asset_name['Identity:11']['notPresent'] == 3.5
|
|
81
|
+
|
|
82
|
+
# Verify attacker entrypoint was added
|
|
83
|
+
attack_step = get_node(scenario.attack_graph, 'OS App:fullAccess')
|
|
84
|
+
attacker1 = scenario.attacker_settings['Attacker1']
|
|
85
|
+
assert isinstance(attacker1, AttackerSettings)
|
|
86
|
+
assert attack_step in attacker1.entry_points
|
|
87
|
+
|
|
88
|
+
assert scenario.attacker_settings['Attacker1'].policy == BreadthFirstAttacker
|
|
89
|
+
assert scenario.defender_settings['Defender1'].policy == PassiveAgent
|
|
90
|
+
|
|
91
|
+
|
|
59
92
|
def test_save_scenario(model: Model, tmp_path: Any) -> None:
|
|
60
93
|
"""Make sure we can load and save a scenario"""
|
|
61
94
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mal_simulator-3.0.1 → mal_simulator-3.2.0}/malsim/mal_simulator/defender_state_factories.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|