-
Notifications
You must be signed in to change notification settings - Fork 3
Code examples
Compiling a mal-lang in this manner is no longer recommended. Now, it is recommended to load the language directly from .mal files (go to Create a MAL Model) into the mal-toolbox. However, this compilation is still supported.
- Install maltoolbox
- Create/download a MAL language in .mal file(s)
- Use malc
- Compile your language with malc: https://github.com/mal-lang/malc?tab=readme-ov-file#usage
- This will result in a .mar-archive of your language that can be used by the MAL toolbox.
Example compile coreLang on ubuntu machine:
# Download coreLang (you can do this without git as well)
git clone https://github.com/mal-lang/coreLang.git
# Move into the coreLang directory
cd coreLang
# Download malc (correct version for your OS can be found on https://github.com/mal-lang/malc/releases)
wget https://github.com/mal-lang/malc/releases/download/release%2F0.2.0/malc_0.2.0-1_amd64.deb
# Install malc
sudo dpkg -i malc_0.2.0-1_amd64.deb
# Compile coreLang (we are in the coreLang root directory)
# This will output org.mal-lang.coreLang-1.0.0.mar which,
# a '.mar'-archive containing the language.
malc src/main/mal/main.mal
MAL-toolbox uses a config file that sets logging and visualizer settings.
To write your own config file, create a file called 'maltoolbox.yml' and place it in the directory from where you are running mal-toolbox. The content of the file should be this:
logging:
log_level: INFO
log_file: "logs/log.txt"
attackgraph_file: "logs/attackgraph.yml"
model_file: "logs/model.yml"
langspec_file: "logs/langspec_file.yml"You can change log level, log file, and output file paths.
- You have mal-toolbox installed.
- A MAL language (.mal or .mar-file).
- Install mal-gui.
- Launch mal-gui using the command
malguifrom the command line and select your language. - Drag and drop the assets you want and create associations between them by SHIFT+Left clicking and dragging from one asset to another.
- Export the model to either .yml or .json (you can export scenario files as well, this is for the
mal-simulator)
- Load your language using maltoolbox.language.LanguageGraph.
- Use the maltoolbox.model.Model class to create a model and add assets.
- Add associations to your assets using
asset.add_associated_assets.
See how in this tutorial.
Prerequisites:
- MAL Toolbox
- A MAL language (.mal or .mar-file).
- A model file (.yml/.json).
maltoolbox attack-graph generate [options] <model_file> <lang_file>
### Language given as a .mal
maltoolbox attack-graph generate [options] model.yml main.mal
### Language given as a .mar
maltoolbox attack-graph generate [options] model.yml org.mal-lang.coreLang-1.0.0.mar
This will output the attack-graph (.yml) to the logging directory of mal-toolbox.
The default logging directory is './logs' in the directory where the maltoolbox command is run.
Use maltoolbox.attackgraph.create_attack_graph
See how in this tutorial.
You can refer to the mal-simulator Wiki.