mal-toolbox


Namemal-toolbox JSON
Version 1.0.2 PyPI version JSON
download
home_pageNone
SummaryA collection of tools used to create MAL models and attack graphs.
upload_time2025-08-22 08:16:06
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseApache Software License
keywords mal
VCS
bugtrack_url
requirements docopt PyYAML py2neo antlr4-tools antlr4-python3-runtime mypy types-docopt types-PyYAML
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # MAL Toolbox overview

MAL Toolbox is a collection of python modules to help developers create and work with
MAL ([Meta Attack Language](https://mal-lang.org/)) models and attack graphs.

Attack graphs can be used to run simulations (see MAL Simulator) or analysis.

[Documentation](https://mal-lang.org/mal-toolbox/index.html)(Work in progress)

## The Language Module

The language module provides various tools to process MAL languages.

### The Language Specification Submodule

The language specification submodule provides functions to load the
specification from a .mar archive(`load_language_specification_from_mar`) or a
JSON file(`load_language_specification_from_json`). This specification will
then be used to generate python classes representing the assets and
associations of the language and to determine the attack steps for each asset
when generating the attack graph.

## The Model Module

With a MAL language a Model (a MAL instance model) can be created either
from a model file or empty.

The model class will store all of the relevant information to the MAL
instance model, most importantly the assets and their associations.

Model objects can be used to generate attack graphs with the AttackGraph module.

## The Attack Graph Module

The attack graph module contains tools used to generate attack graphs from
existing MAL instance models and analyse MAL attack graphs. The function used
to generate the attack graph is `generate_graph` and it requires the instance
model and language specification. The resulting attack graph will contain
nodes for each of the attack steps. The structure of the attack node data
class can be seen in `attackgraph/node.py` file. Of note are the lists of
children and parents which allow for easy reference to the other attack step
nodes related and the asset field which will contain the object in the model
instance to which this attack step belongs to, if this information is
available.

## Ingestors Module

The ingestors module contains various tools that can make use of the instance
model or attack graph. Currently the Neo4J ingestor is the only one available
and it can be used to visualise the instance model and the attack graph.


# Usage

## Installation

```
pip install mal-toolbox
```

## Configuration
You can use a `maltoolbox.yml` file in the current working directory to
configure the toolbox.

The config should look like this:
```yml
logging:
  log_level: INFO
  log_file: "logs/log.txt"
  attackgraph_file: "logs/attackgraph.json"
  model_file: "logs/model.yml"
  langspec_file: "logs/langspec_file.yml"
  langgraph_file: "logs/langspec_file.yml"
```

Alternatively, you can use the `MALTOOLBOX_CONFIG`
environment variable to set a custom config file location.

```bash
# in your shell, e.g. bash do:
export MALTOOLBOX_CONFIG=path/to/yml/config/file
```

The default configuration can be found here:

https://github.com/mal-lang/mal-toolbox/blob/main/maltoolbox/__init__.py#L39-L53

## Command Line Client

You can use the maltoolbox cli to:

- Generate attack graphs from model files
- Compile MAL languages
- Upgrade model files from older versions

```
Command-line interface for MAL toolbox operations

Usage:
    maltoolbox attack-graph generate [options] <model_file> <lang_file>
    maltoolbox compile <lang_file> <output_file>
    maltoolbox upgrade-model <model_file> <lang_file> <output_file>

Arguments:
    <model_file>    Path to JSON instance model file.
    <lang_file>     Path to .mar or .mal file containing MAL spec.
    <output_file>   Path to write the result of the compilation (yml/json).

Notes:
    - <lang_file> can be either a .mar file (generated by the older MAL
      compiler) or a .mal file containing the DSL written in MAL.
```

## Code examples / Tutorial

To find code examples and tutorials, visit the
[MAL Toolbox Tutorial](https://github.com/mal-lang/mal-toolbox-tutorial/tree/main) repository.

# Tests
There are unit tests inside of ./tests.
Before running the tests, make sure to install the requirements in ./tests/requirements.txt with `python -m pip install -r ./tests/requirements.txt`.

To run all tests, use the `pytest` command. To run just a specific file or test function use `pytest tests/<filename>` or `pytest -k <function_name>`.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "mal-toolbox",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "mal",
    "author": null,
    "author_email": "Andrei Buhaiu <buhaiu@kth.se>, Joakim Loxdal <loxdal@kth.se>, Nikolaos Kakouros <nkak@kth.se>, Jakob Nyberg <jaknyb@kth.se>, Giuseppe Nebbione <nebbione@kth.se>",
    "download_url": "https://files.pythonhosted.org/packages/55/e9/1bf2ab0d3a2211330f23b5f1ce869aaa6f8a8c3846b99e30240f9642c16b/mal_toolbox-1.0.2.tar.gz",
    "platform": null,
    "description": "# MAL Toolbox overview\n\nMAL Toolbox is a collection of python modules to help developers create and work with\nMAL ([Meta Attack Language](https://mal-lang.org/)) models and attack graphs.\n\nAttack graphs can be used to run simulations (see MAL Simulator) or analysis.\n\n[Documentation](https://mal-lang.org/mal-toolbox/index.html)(Work in progress)\n\n## The Language Module\n\nThe language module provides various tools to process MAL languages.\n\n### The Language Specification Submodule\n\nThe language specification submodule provides functions to load the\nspecification from a .mar archive(`load_language_specification_from_mar`) or a\nJSON file(`load_language_specification_from_json`). This specification will\nthen be used to generate python classes representing the assets and\nassociations of the language and to determine the attack steps for each asset\nwhen generating the attack graph.\n\n## The Model Module\n\nWith a MAL language a Model (a MAL instance model) can be created either\nfrom a model file or empty.\n\nThe model class will store all of the relevant information to the MAL\ninstance model, most importantly the assets and their associations.\n\nModel objects can be used to generate attack graphs with the AttackGraph module.\n\n## The Attack Graph Module\n\nThe attack graph module contains tools used to generate attack graphs from\nexisting MAL instance models and analyse MAL attack graphs. The function used\nto generate the attack graph is `generate_graph` and it requires the instance\nmodel and language specification. The resulting attack graph will contain\nnodes for each of the attack steps. The structure of the attack node data\nclass can be seen in `attackgraph/node.py` file. Of note are the lists of\nchildren and parents which allow for easy reference to the other attack step\nnodes related and the asset field which will contain the object in the model\ninstance to which this attack step belongs to, if this information is\navailable.\n\n## Ingestors Module\n\nThe ingestors module contains various tools that can make use of the instance\nmodel or attack graph. Currently the Neo4J ingestor is the only one available\nand it can be used to visualise the instance model and the attack graph.\n\n\n# Usage\n\n## Installation\n\n```\npip install mal-toolbox\n```\n\n## Configuration\nYou can use a `maltoolbox.yml` file in the current working directory to\nconfigure the toolbox.\n\nThe config should look like this:\n```yml\nlogging:\n  log_level: INFO\n  log_file: \"logs/log.txt\"\n  attackgraph_file: \"logs/attackgraph.json\"\n  model_file: \"logs/model.yml\"\n  langspec_file: \"logs/langspec_file.yml\"\n  langgraph_file: \"logs/langspec_file.yml\"\n```\n\nAlternatively, you can use the `MALTOOLBOX_CONFIG`\nenvironment variable to set a custom config file location.\n\n```bash\n# in your shell, e.g. bash do:\nexport MALTOOLBOX_CONFIG=path/to/yml/config/file\n```\n\nThe default configuration can be found here:\n\nhttps://github.com/mal-lang/mal-toolbox/blob/main/maltoolbox/__init__.py#L39-L53\n\n## Command Line Client\n\nYou can use the maltoolbox cli to:\n\n- Generate attack graphs from model files\n- Compile MAL languages\n- Upgrade model files from older versions\n\n```\nCommand-line interface for MAL toolbox operations\n\nUsage:\n    maltoolbox attack-graph generate [options] <model_file> <lang_file>\n    maltoolbox compile <lang_file> <output_file>\n    maltoolbox upgrade-model <model_file> <lang_file> <output_file>\n\nArguments:\n    <model_file>    Path to JSON instance model file.\n    <lang_file>     Path to .mar or .mal file containing MAL spec.\n    <output_file>   Path to write the result of the compilation (yml/json).\n\nNotes:\n    - <lang_file> can be either a .mar file (generated by the older MAL\n      compiler) or a .mal file containing the DSL written in MAL.\n```\n\n## Code examples / Tutorial\n\nTo find code examples and tutorials, visit the\n[MAL Toolbox Tutorial](https://github.com/mal-lang/mal-toolbox-tutorial/tree/main) repository.\n\n# Tests\nThere are unit tests inside of ./tests.\nBefore running the tests, make sure to install the requirements in ./tests/requirements.txt with `python -m pip install -r ./tests/requirements.txt`.\n\nTo run all tests, use the `pytest` command. To run just a specific file or test function use `pytest tests/<filename>` or `pytest -k <function_name>`.\n",
    "bugtrack_url": null,
    "license": "Apache Software License",
    "summary": "A collection of tools used to create MAL models and attack graphs.",
    "version": "1.0.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/mal-lang/mal-toolbox/issues",
        "Homepage": "https://github.com/mal-lang/mal-toolbox",
        "Repository": "https://github.com/mal-lang/mal-toolbox"
    },
    "split_keywords": [
        "mal"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "09933947886f064208240dfa5dcf64be907cd10d2fe763d229e84539138a00d7",
                "md5": "cd53a1d77b7918e003e724130e1a735b",
                "sha256": "ab7bdf53f4e0cc510f96c68753068de7c273bc1a563c202525d2e2716d6e00e0"
            },
            "downloads": -1,
            "filename": "mal_toolbox-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cd53a1d77b7918e003e724130e1a735b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 60867,
            "upload_time": "2025-08-22T08:16:04",
            "upload_time_iso_8601": "2025-08-22T08:16:04.823881Z",
            "url": "https://files.pythonhosted.org/packages/09/93/3947886f064208240dfa5dcf64be907cd10d2fe763d229e84539138a00d7/mal_toolbox-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "55e91bf2ab0d3a2211330f23b5f1ce869aaa6f8a8c3846b99e30240f9642c16b",
                "md5": "ab69bd543c099d54fc5e9143dbc1adc7",
                "sha256": "b9265d99c6d3e12c1a2ef152e12b798f8f54aa0ca0f9b9d1fbd1cef7ab2db559"
            },
            "downloads": -1,
            "filename": "mal_toolbox-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "ab69bd543c099d54fc5e9143dbc1adc7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 57163,
            "upload_time": "2025-08-22T08:16:06",
            "upload_time_iso_8601": "2025-08-22T08:16:06.292662Z",
            "url": "https://files.pythonhosted.org/packages/55/e9/1bf2ab0d3a2211330f23b5f1ce869aaa6f8a8c3846b99e30240f9642c16b/mal_toolbox-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-22 08:16:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mal-lang",
    "github_project": "mal-toolbox",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "docopt",
            "specs": []
        },
        {
            "name": "PyYAML",
            "specs": []
        },
        {
            "name": "py2neo",
            "specs": []
        },
        {
            "name": "antlr4-tools",
            "specs": []
        },
        {
            "name": "antlr4-python3-runtime",
            "specs": []
        },
        {
            "name": "mypy",
            "specs": []
        },
        {
            "name": "types-docopt",
            "specs": []
        },
        {
            "name": "types-PyYAML",
            "specs": []
        }
    ],
    "lcname": "mal-toolbox"
}
        
Elapsed time: 1.10228s