A MAL compliant simulator.
Project description
MAL Simulator
Overview
The MAL Simulator is a tool designed for running simulations on systems modeled in the Modeling Attack Language (MAL).
It allows you to:
- Simulate the adversarial and defensive actions of intelligent agents (attackers and defenders).
- Analyze system security and evaluate attack/defense strategies.
- Develop machine learning agents (e.g., using Reinforcement Learning) in a safe, dynamic environment.
- Incorporate stochastic modeling through Time-to-Compromise (TTC) distributions.
For in-depth documentation please refer to the official Wiki.
Contributing
- Use Conventional commits
- The CI pipeline runs
mypyandrufffor linting and type checking, and PRs will only be merged if pipeline succeeds.
🛠️ How to Run a Simulation
1. Installation
pip install mal-simulator
To also get ML dependencies (pettingzoo, gymnasium):
pip install mal-simulator[ml]
For additional dev tools:
pip install mal-simulator[dev]
2. Running a Scenario via CLI
You can execute a simulation using a YAML scenario file, which defines the MAL model, the agents (attackers and defenders), their policies, and their goals.
The basic command structure is:
malsim <scenario_file> [options]
Example
Execute a simulation defined in my_scenario.yml:
malsim my_scenario.yml
Common Options:
| Option | Description |
|---|---|
-s, --seed SEED |
Sets the random seed for deterministic simulations. |
-t, --ttc-mode MODE |
Sets the Time-to-Compromise mode (e.g., DISABLED, PER_STEP_SAMPLE). |
-g, --send-to-gui |
Sends simulation data to the malsim-gui for visualization (requires the GUI to be running). |
3. Programmatic Usage
For advanced and customized simulations (e.g., integrating with a custom ML training loop), you can initialize and run the simulator directly in a Python script:
from malsim import MalSimulator, run_simulation, Scenario
# 1. Load the scenario configuration
SCENARIO_FILE = "my_scenario.yml"
scenario = Scenario.load_from_file(SCENARIO_FILE)
# 2. Create the simulator instance
sim = MalSimulator.from_scenario(scenario)
# 3. Run the simulation
agent_actions = run_simulation(sim, scenario.agents)
print("Simulation finished. Agent actions:", agent_actions)
You can also run your own simulation loop.
from malsim import MalSimulator, Scenario
scenario = Scenario.load_from_file("my_scenario.yml")
sim = MalSimulator.from_scenario(scenario)
agent_states = sim.reset()
while not sim.done():
# ... calculate actions for each agent
agent_states = sim.step(actions)
Read the Wiki for more ways to run the simulator.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mal_simulator-2.3.0.tar.gz.
File metadata
- Download URL: mal_simulator-2.3.0.tar.gz
- Upload date:
- Size: 81.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15e66469485a8e2b4dfa994ac62e728c714a630a241ed7d2c887374fc1e26629
|
|
| MD5 |
57071abd7055783a1fe2614ca02b2e44
|
|
| BLAKE2b-256 |
f0b86e80f399d1b25cb03ae6cc6f98b8555fe4925f5dcfe3fa4897343a8c9214
|
Provenance
The following attestation bundles were made for mal_simulator-2.3.0.tar.gz:
Publisher:
publish-to-pypi-and-test-pypi.yml on mal-lang/mal-simulator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mal_simulator-2.3.0.tar.gz -
Subject digest:
15e66469485a8e2b4dfa994ac62e728c714a630a241ed7d2c887374fc1e26629 - Sigstore transparency entry: 919243588
- Sigstore integration time:
-
Permalink:
mal-lang/mal-simulator@f3f14b5d9689aa5870f85b24c252109d09526aa1 -
Branch / Tag:
refs/tags/2.3.0 - Owner: https://github.com/mal-lang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi-and-test-pypi.yml@f3f14b5d9689aa5870f85b24c252109d09526aa1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mal_simulator-2.3.0-py3-none-any.whl.
File metadata
- Download URL: mal_simulator-2.3.0-py3-none-any.whl
- Upload date:
- Size: 87.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08beeaf2aa3c93d512e2b87021ca9ed1637fb34f81d703db2e8e2ac43f6d5237
|
|
| MD5 |
255c6cf04c14756d7e3babf85fae17f6
|
|
| BLAKE2b-256 |
ea92400b6178cf6fab787d1ef98d5422ef76231f1437f27e169fc763319ced7e
|
Provenance
The following attestation bundles were made for mal_simulator-2.3.0-py3-none-any.whl:
Publisher:
publish-to-pypi-and-test-pypi.yml on mal-lang/mal-simulator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mal_simulator-2.3.0-py3-none-any.whl -
Subject digest:
08beeaf2aa3c93d512e2b87021ca9ed1637fb34f81d703db2e8e2ac43f6d5237 - Sigstore transparency entry: 919243590
- Sigstore integration time:
-
Permalink:
mal-lang/mal-simulator@f3f14b5d9689aa5870f85b24c252109d09526aa1 -
Branch / Tag:
refs/tags/2.3.0 - Owner: https://github.com/mal-lang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi-and-test-pypi.yml@f3f14b5d9689aa5870f85b24c252109d09526aa1 -
Trigger Event:
push
-
Statement type: