mal-toolbox 1.1.1__py3-none-any.whl → 1.1.3__py3-none-any.whl

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.
Files changed (31) hide show
  1. {mal_toolbox-1.1.1.dist-info → mal_toolbox-1.1.3.dist-info}/METADATA +25 -2
  2. mal_toolbox-1.1.3.dist-info/RECORD +32 -0
  3. maltoolbox/__init__.py +6 -7
  4. maltoolbox/__main__.py +17 -9
  5. maltoolbox/attackgraph/__init__.py +2 -3
  6. maltoolbox/attackgraph/attackgraph.py +379 -362
  7. maltoolbox/attackgraph/node.py +14 -19
  8. maltoolbox/exceptions.py +7 -10
  9. maltoolbox/file_utils.py +10 -4
  10. maltoolbox/language/__init__.py +1 -1
  11. maltoolbox/language/compiler/__init__.py +4 -4
  12. maltoolbox/language/compiler/mal_lexer.py +154 -154
  13. maltoolbox/language/compiler/mal_parser.py +784 -1136
  14. maltoolbox/language/languagegraph.py +487 -639
  15. maltoolbox/model.py +64 -77
  16. maltoolbox/patternfinder/attackgraph_patterns.py +17 -8
  17. maltoolbox/translators/__init__.py +8 -0
  18. maltoolbox/translators/networkx.py +42 -0
  19. maltoolbox/translators/updater.py +18 -25
  20. maltoolbox/visualization/__init__.py +4 -4
  21. maltoolbox/visualization/draw_io_utils.py +6 -5
  22. maltoolbox/visualization/graphviz_utils.py +4 -2
  23. maltoolbox/visualization/neo4j_utils.py +13 -14
  24. maltoolbox/visualization/utils.py +2 -3
  25. mal_toolbox-1.1.1.dist-info/RECORD +0 -32
  26. maltoolbox/translators/securicad.py +0 -179
  27. {mal_toolbox-1.1.1.dist-info → mal_toolbox-1.1.3.dist-info}/WHEEL +0 -0
  28. {mal_toolbox-1.1.1.dist-info → mal_toolbox-1.1.3.dist-info}/entry_points.txt +0 -0
  29. {mal_toolbox-1.1.1.dist-info → mal_toolbox-1.1.3.dist-info}/licenses/AUTHORS +0 -0
  30. {mal_toolbox-1.1.1.dist-info → mal_toolbox-1.1.3.dist-info}/licenses/LICENSE +0 -0
  31. {mal_toolbox-1.1.1.dist-info → mal_toolbox-1.1.3.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mal-toolbox
3
- Version: 1.1.1
3
+ Version: 1.1.3
4
4
  Summary: A collection of tools used to create MAL models and attack graphs.
5
5
  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>, Sandor Berglund <sandor@kth.se>
6
6
  License: Apache Software License
@@ -24,6 +24,7 @@ Requires-Dist: antlr4-python3-runtime
24
24
  Requires-Dist: docopt
25
25
  Requires-Dist: PyYAML
26
26
  Requires-Dist: py2neo
27
+ Requires-Dist: networkx
27
28
  Provides-Extra: dev
28
29
  Requires-Dist: pytest; extra == "dev"
29
30
  Dynamic: license-file
@@ -178,8 +179,30 @@ attack_graph = AttackGraph(lang_graph, model)
178
179
  ```
179
180
 
180
181
 
182
+ ## Contributing
183
+
184
+ # CI Pipeline
185
+
186
+ Checks are made with:
187
+
188
+ - `mypy`
189
+ - `ruff`
190
+ - `pytest`
191
+
192
+ Make sure pipeline passes before PR is marked "Ready for review".
193
+
181
194
  # Tests
182
195
  There are unit tests inside of ./tests.
183
- Before running the tests, make sure to install the requirements in ./tests/requirements.txt with `python -m pip install -r ./tests/requirements.txt`.
184
196
 
185
197
  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>`.
198
+
199
+ # Making a release
200
+
201
+ 1. Make a PR with one commit that updates the version number in `pyproject.toml` and `maltoolbox/__init__.py`.
202
+ Follow [Semantic versioning](https://semver.org/).
203
+
204
+ 2. Get the PR reviewed and merged to `main`.
205
+
206
+ 3. Tag the latest commit on `main` with the new version number.
207
+
208
+ 4. Push the tag.
@@ -0,0 +1,32 @@
1
+ mal_toolbox-1.1.3.dist-info/licenses/AUTHORS,sha256=zxLrLe8EY39WtRKlAY4Oorx4Z2_LHV2ApRvDGZgY7xY,127
2
+ mal_toolbox-1.1.3.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
3
+ maltoolbox/__init__.py,sha256=XPlaa-uM8YDeYpOQ0BhxBvXUt3kZGeoYdboiIV9moig,2132
4
+ maltoolbox/__main__.py,sha256=aAm6NcZ-HtPmY9hfFlGNnTs5rydoI6NAc88RgXt1G9U,3515
5
+ maltoolbox/exceptions.py,sha256=4rwqzu8Cgj0ShjUoCXP2yik-bJaqYqj6Y-0tqxHy4vs,1316
6
+ maltoolbox/file_utils.py,sha256=IXA0cvyopjRFGGKqRPkRQ0RJOtKzq_XF13aHgcz-TFc,1911
7
+ maltoolbox/model.py,sha256=bqYPYNW8MxuS2wUef51z6yjaA5F13YXbeicM2qaYUd4,18138
8
+ maltoolbox/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ maltoolbox/attackgraph/__init__.py,sha256=l7dJ7jOqpcj7PdsOKZt1NuXlPyjd6vZYvcXlj8Kq09w,297
10
+ maltoolbox/attackgraph/attackgraph.py,sha256=OH5GP5v8_RPeHIxzwy2qlctAvMQ_8YgfIKtJwE6Pqqc,26309
11
+ maltoolbox/attackgraph/node.py,sha256=7NAdEl40w6KMt_gKK1mP4SRAmmyCQGSTMaD-GHMNXHk,4186
12
+ maltoolbox/attackgraph/analyzers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ maltoolbox/language/__init__.py,sha256=RTTfhnCYa5PRGJCgDAWLpLLAzNCvNMn91UHNiOXszbg,490
14
+ maltoolbox/language/languagegraph.py,sha256=Tjqk5zv_37ghmepx8KBHPTH8tRlboaYcW836MiUS1d8,65140
15
+ maltoolbox/language/compiler/__init__.py,sha256=Rbdeco6SWHyFw-VJfpxLRSZO3UMjJxPGenMR8OujVpA,15846
16
+ maltoolbox/language/compiler/mal_lexer.py,sha256=TQvzEW7yCN0iY6Js5O6wCDFxSAE0_LAX4JVy96TnLro,14808
17
+ maltoolbox/language/compiler/mal_parser.py,sha256=bVfYWRZyyhU-s2tJI-D_YwbVQkl3AHzdrD6LWM0BQbI,116108
18
+ maltoolbox/patternfinder/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
+ maltoolbox/patternfinder/attackgraph_patterns.py,sha256=jw6BlQHXLmiWm9xajLHbUZUWVQGM2qAgMHOs0Yo2YsE,5168
20
+ maltoolbox/translators/__init__.py,sha256=7qbhjeu--s2A-O_031a7xzSq794iQlrrUxM8gE1LxH4,201
21
+ maltoolbox/translators/networkx.py,sha256=v1JQAqO7st6-ktx5P3oy93DsL2SEUPly_3zcALv08o8,1352
22
+ maltoolbox/translators/updater.py,sha256=mFmTT2GHCw6nsoHe_ChnvAHd5j6UxKnvAqLFDSziqC4,8566
23
+ maltoolbox/visualization/__init__.py,sha256=7rrGclkGdP6LrxpfSh1esYFG_MnvnVruuEdUJI-DX-g,350
24
+ maltoolbox/visualization/draw_io_utils.py,sha256=CgsD0HEFpxZ6ZIWtUZtMekdPB2Irtmvhz0TNEm7x1ig,14378
25
+ maltoolbox/visualization/graphviz_utils.py,sha256=PENKhcpeQkxczzoRwOIVFe_olMhGBeuZg1d8JSqXUQQ,3909
26
+ maltoolbox/visualization/neo4j_utils.py,sha256=R2Qm2gC5GDpfiPhhB3oymuBI2W580SRXGVtQuFRYiIA,3496
27
+ maltoolbox/visualization/utils.py,sha256=EZWsxukO5hbRwGFW9GM9ZemKT-nYg-VMCup-SsntaQM,1480
28
+ mal_toolbox-1.1.3.dist-info/METADATA,sha256=vNtJhGzNG2bu5iRntbL_5ZKAPruvhuJAo-XSlzceT00,6298
29
+ mal_toolbox-1.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
30
+ mal_toolbox-1.1.3.dist-info/entry_points.txt,sha256=oqby5O6cUP_OHCm70k_iYPA6UlbTBf7se1i3XwdK3uU,56
31
+ mal_toolbox-1.1.3.dist-info/top_level.txt,sha256=phqRVLRKGdSUgRY03mcpi2cmbbDo5YGjkV4gkqHFFcM,11
32
+ mal_toolbox-1.1.3.dist-info/RECORD,,
maltoolbox/__init__.py CHANGED
@@ -1,5 +1,4 @@
1
- # -*- encoding: utf-8 -*-
2
- # MAL Toolbox v1.1.1
1
+ # MAL Toolbox v1.1.3
3
2
  # Copyright 2025, Andrei Buhaiu.
4
3
  #
5
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,12 +15,11 @@
16
15
  #
17
16
 
18
17
 
19
- """
20
- MAL-Toolbox Framework
18
+ """MAL-Toolbox Framework
21
19
  """
22
20
 
23
21
  __title__ = "maltoolbox"
24
- __version__ = "1.1.1"
22
+ __version__ = "1.1.3"
25
23
  __authors__ = [
26
24
  "Andrei Buhaiu",
27
25
  "Giuseppe Nebbione",
@@ -34,11 +32,12 @@ __docformat__ = "restructuredtext en"
34
32
 
35
33
  __all__ = ()
36
34
 
37
- import os
38
- import yaml
39
35
  import logging
36
+ import os
40
37
  from typing import Any
41
38
 
39
+ import yaml
40
+
42
41
  config: dict[str, Any] = {
43
42
  "logging": {
44
43
  "log_level": logging.INFO,
maltoolbox/__main__.py CHANGED
@@ -1,5 +1,4 @@
1
- """
2
- Command-line interface for MAL toolbox operations
1
+ """Command-line interface for MAL toolbox operations
3
2
 
4
3
  Usage:
5
4
  maltoolbox compile <lang_file> <output_file>
@@ -8,6 +7,7 @@ Usage:
8
7
  maltoolbox visualize-model [--neo4j] [--graphviz] [-drawio] <model_file> <lang_file>
9
8
 
10
9
  Arguments:
10
+ ---------
11
11
  <model_file> Path to JSON instance model file.
12
12
  <lang_file> Path to .mar or .mal file containing MAL spec.
13
13
  <output_file> Path to write the result of the compilation (yml/json).
@@ -19,30 +19,34 @@ Options:
19
19
  -d --drawio Export draw.io file
20
20
 
21
21
  Notes:
22
+ -----
22
23
  - <lang_file> can be either a .mar file (generated by the older MAL
23
24
  compiler) or a .mal file containing the DSL written in MAL.
25
+
24
26
  """
25
27
 
26
- import logging
27
28
  import json
29
+ import logging
30
+
28
31
  import docopt
29
32
 
30
33
  from . import log_configs, neo4j_configs
31
- from .attackgraph import create_attack_graph, AttackGraph
34
+ from .attackgraph import AttackGraph, create_attack_graph
32
35
  from .language.compiler import MalCompiler
33
36
  from .language.languagegraph import LanguageGraph
37
+ from .model import Model
34
38
  from .translators.updater import load_model_from_older_version
35
39
  from .visualization import (
36
- render_model,
37
- render_attack_graph,
38
- ingest_model_neo4j,
40
+ create_drawio_file_with_images,
39
41
  ingest_attack_graph_neo4j,
40
- create_drawio_file_with_images
42
+ ingest_model_neo4j,
43
+ render_attack_graph,
44
+ render_model,
41
45
  )
42
- from .model import Model
43
46
 
44
47
  logger = logging.getLogger(__name__)
45
48
 
49
+
46
50
  def generate_attack_graph(
47
51
  model_file: str,
48
52
  lang_file: str
@@ -50,8 +54,10 @@ def generate_attack_graph(
50
54
  """Create an attack graph
51
55
 
52
56
  Args:
57
+ ----
53
58
  model_file - path to the model file
54
59
  lang_file - path to the language file
60
+
55
61
  """
56
62
  attack_graph = create_attack_graph(lang_file, model_file)
57
63
  if log_configs['attackgraph_file']:
@@ -60,6 +66,7 @@ def generate_attack_graph(
60
66
  )
61
67
  return attack_graph
62
68
 
69
+
63
70
  def compile(lang_file: str, output_file: str) -> None:
64
71
  """Compile language and dump into output file"""
65
72
  compiler = MalCompiler()
@@ -107,5 +114,6 @@ def main():
107
114
  if args['--drawio']:
108
115
  create_drawio_file_with_images(model)
109
116
 
117
+
110
118
  if __name__ == "__main__":
111
119
  main()
@@ -1,5 +1,4 @@
1
- """
2
- Contains tools used to generate attack graphs from MAL instance
1
+ """Contains tools used to generate attack graphs from MAL instance
3
2
  models and analyze attack graphs.
4
3
  """
5
4
 
@@ -7,8 +6,8 @@ from .attackgraph import AttackGraph, create_attack_graph
7
6
  from .node import AttackGraphNode
8
7
 
9
8
  __all__ = [
10
- "Attacker",
11
9
  "AttackGraph",
12
10
  "AttackGraphNode",
11
+ "Attacker",
13
12
  "create_attack_graph"
14
13
  ]