mal-toolbox 0.1.5__tar.gz → 0.1.7__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.
Files changed (39) hide show
  1. {mal_toolbox-0.1.5/mal_toolbox.egg-info → mal_toolbox-0.1.7}/PKG-INFO +3 -1
  2. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/README.md +3 -1
  3. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7/mal_toolbox.egg-info}/PKG-INFO +3 -1
  4. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/__init__.py +2 -2
  5. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/attackgraph/attackgraph.py +1 -1
  6. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/model.py +73 -1
  7. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/pyproject.toml +1 -1
  8. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/tests/test_model.py +88 -0
  9. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/AUTHORS +0 -0
  10. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/LICENSE +0 -0
  11. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/mal_toolbox.egg-info/SOURCES.txt +0 -0
  12. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/mal_toolbox.egg-info/dependency_links.txt +0 -0
  13. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/mal_toolbox.egg-info/requires.txt +0 -0
  14. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/mal_toolbox.egg-info/top_level.txt +0 -0
  15. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/__main__.py +0 -0
  16. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/attackgraph/__init__.py +0 -0
  17. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/attackgraph/analyzers/__init__.py +0 -0
  18. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/attackgraph/analyzers/apriori.py +0 -0
  19. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/attackgraph/attacker.py +0 -0
  20. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/attackgraph/node.py +0 -0
  21. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/attackgraph/query.py +0 -0
  22. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/default.conf +0 -0
  23. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/exceptions.py +0 -0
  24. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/file_utils.py +0 -0
  25. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/ingestors/__init__.py +0 -0
  26. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/ingestors/neo4j.py +0 -0
  27. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/language/__init__.py +0 -0
  28. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/language/classes_factory.py +0 -0
  29. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/language/compiler/__init__.py +0 -0
  30. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/language/compiler/mal_lexer.py +0 -0
  31. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/language/compiler/mal_parser.py +0 -0
  32. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/language/compiler/mal_visitor.py +0 -0
  33. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/language/languagegraph.py +0 -0
  34. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/translators/__init__.py +0 -0
  35. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/translators/securicad.py +0 -0
  36. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/translators/updater.py +0 -0
  37. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/maltoolbox/wrappers.py +0 -0
  38. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/setup.cfg +0 -0
  39. {mal_toolbox-0.1.5 → mal_toolbox-0.1.7}/tests/test_wrappers.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mal-toolbox
3
- Version: 0.1.5
3
+ Version: 0.1.7
4
4
  Summary: A collection of tools used to create MAL models and attack graphs.
5
5
  Author-email: Andrei Buhaiu <buhaiu@kth.se>, Giuseppe Nebbione <nebbione@kth.se>, Nikolaos Kakouros <nkak@kth.se>, Jakob Nyberg <jaknyb@kth.se>, Joakim Loxdal <loxdal@kth.se>
6
6
  License: Apache Software License
@@ -33,6 +33,8 @@ MAL ([Meta Attack Language](https://mal-lang.org/)) models and attack graphs.
33
33
  Attack graphs can be used to run simulations (see MAL Simulator) or analysis.
34
34
  MAL Toolbox also gives the ability to view the AttackGraph/Model graphically in neo4j.
35
35
 
36
+ [Documentation](https://mal-lang.org/mal-toolbox/index.html)(Work in progress)
37
+
36
38
  ## The Language Module
37
39
 
38
40
  The language module provides various tools to process MAL languages.
@@ -6,6 +6,8 @@ MAL ([Meta Attack Language](https://mal-lang.org/)) models and attack graphs.
6
6
  Attack graphs can be used to run simulations (see MAL Simulator) or analysis.
7
7
  MAL Toolbox also gives the ability to view the AttackGraph/Model graphically in neo4j.
8
8
 
9
+ [Documentation](https://mal-lang.org/mal-toolbox/index.html)(Work in progress)
10
+
9
11
  ## The Language Module
10
12
 
11
13
  The language module provides various tools to process MAL languages.
@@ -99,4 +101,4 @@ To find code examples and tutorials, visit the
99
101
  There are unit tests inside of ./tests.
100
102
  Before running the tests, make sure to install the requirements in ./tests/requirements.txt with `python -m pip install -r ./tests/requirements.txt`.
101
103
 
102
- 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>`.
104
+ 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>`.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mal-toolbox
3
- Version: 0.1.5
3
+ Version: 0.1.7
4
4
  Summary: A collection of tools used to create MAL models and attack graphs.
5
5
  Author-email: Andrei Buhaiu <buhaiu@kth.se>, Giuseppe Nebbione <nebbione@kth.se>, Nikolaos Kakouros <nkak@kth.se>, Jakob Nyberg <jaknyb@kth.se>, Joakim Loxdal <loxdal@kth.se>
6
6
  License: Apache Software License
@@ -33,6 +33,8 @@ MAL ([Meta Attack Language](https://mal-lang.org/)) models and attack graphs.
33
33
  Attack graphs can be used to run simulations (see MAL Simulator) or analysis.
34
34
  MAL Toolbox also gives the ability to view the AttackGraph/Model graphically in neo4j.
35
35
 
36
+ [Documentation](https://mal-lang.org/mal-toolbox/index.html)(Work in progress)
37
+
36
38
  ## The Language Module
37
39
 
38
40
  The language module provides various tools to process MAL languages.
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # MAL Toolbox v0.1.5
2
+ # MAL Toolbox v0.1.7
3
3
  # Copyright 2024, Andrei Buhaiu.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,7 +21,7 @@ MAL-Toolbox Framework
21
21
  """
22
22
 
23
23
  __title__ = 'maltoolbox'
24
- __version__ = '0.1.5'
24
+ __version__ = '0.1.7'
25
25
  __authors__ = ['Andrei Buhaiu',
26
26
  'Giuseppe Nebbione',
27
27
  'Nikolaos Kakouros',
@@ -287,7 +287,7 @@ class AttackGraph():
287
287
  'mitre_info' in node_dict else None
288
288
  ag_node.tags = node_dict['tags'] if \
289
289
  'tags' in node_dict else []
290
- ag_node.extras = node_dict.get('extras', [])
290
+ ag_node.extras = node_dict.get('extras', {})
291
291
 
292
292
  # Add AttackGraphNode to AttackGraph
293
293
  attack_graph.add_node(ag_node, node_id=node_dict['id'])
@@ -31,7 +31,79 @@ class AttackerAttachment:
31
31
  """Used to attach attackers to attack step entrypoints of assets"""
32
32
  id: Optional[int] = None
33
33
  name: Optional[str] = None
34
- entry_points: list[tuple] = field(default_factory=lambda: [])
34
+ entry_points: list[tuple[SchemaGeneratedClass, list[str]]] = \
35
+ field(default_factory=lambda: [])
36
+
37
+
38
+ def add_entrypoint(
39
+ self, asset: SchemaGeneratedClass, attackstep_name: str):
40
+ """Add an entrypoint to an AttackerAttachment
41
+
42
+ self.entry_points contain tuples, first element of each tuple
43
+ is an asset, second element is a list of attack step names that
44
+ are entry points for the attacker.
45
+
46
+ Args:
47
+ asset - the asset to add entrypoint to
48
+ attackstep_name - the name of the attack step to add as an entrypoint
49
+ """
50
+
51
+ logger.debug(
52
+ f'Add entry point "{attackstep_name}" on asset "{asset.name}" '
53
+ f'to AttackerAttachment "{self.name}".'
54
+ )
55
+
56
+ # Get the entrypoint tuple for the asset if it already exists
57
+ entrypoint_tuple = next((ep_tuple for ep_tuple in self.entry_points
58
+ if ep_tuple[0] == asset), None)
59
+
60
+ if entrypoint_tuple:
61
+ if attackstep_name not in entrypoint_tuple[1]:
62
+ # If it exists and does not already have the attack step,
63
+ # add it
64
+ entrypoint_tuple[1].append(attackstep_name)
65
+ else:
66
+ logger.info(
67
+ f'Entry point "{attackstep_name}" on asset "{asset.name}"'
68
+ f' already existed for AttackerAttachment "{self.name}".'
69
+ )
70
+ else:
71
+ # Otherwise, create the entrypoint tuple and the initial entry
72
+ # point
73
+ self.entry_points.append((asset, [attackstep_name]))
74
+
75
+ def remove_entrypoint(
76
+ self, asset: SchemaGeneratedClass, attackstep_name: str):
77
+ """Remove an entrypoint from an AttackerAttachment if it exists"""
78
+
79
+ logger.debug(
80
+ f'Remove entry point "{attackstep_name}" on asset "{asset.name}" '
81
+ f'from AttackerAttachment "{self.name}".'
82
+ )
83
+
84
+ # Get the entrypoint tuple for the asset if it exists
85
+ entrypoint_tuple = next((ep_tuple for ep_tuple in self.entry_points
86
+ if ep_tuple[0] == asset), None)
87
+
88
+ if entrypoint_tuple:
89
+ if attackstep_name in entrypoint_tuple[1]:
90
+ # If it exists and not already has the attack step, add it
91
+ entrypoint_tuple[1].remove(attackstep_name)
92
+ else:
93
+ logger.warning(
94
+ f'Failed to find entry point "{attackstep_name}" on '
95
+ f'asset "{asset.name}" for AttackerAttachment '
96
+ f'"{self.name}". Nothing to remove.'
97
+ )
98
+
99
+ if not entrypoint_tuple[1]:
100
+ self.entry_points.remove(entrypoint_tuple)
101
+ else:
102
+ logger.warning(
103
+ f'Failed to find entry points on asset "{asset.name}" '
104
+ f'for AttackerAttachment "{self.name}". Nothing to remove.'
105
+ )
106
+
35
107
 
36
108
  class Model():
37
109
  """An implementation of a MAL language with assets and associations"""
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mal-toolbox"
3
- version = "0.1.5"
3
+ version = "0.1.7"
4
4
  authors = [
5
5
  { name="Andrei Buhaiu", email="buhaiu@kth.se" },
6
6
  { name="Giuseppe Nebbione", email="nebbione@kth.se" },
@@ -51,6 +51,94 @@ def create_association(
51
51
 
52
52
  ### Tests
53
53
 
54
+ def test_attacker_attachment_add_entrypoint(model: Model):
55
+ """"""
56
+
57
+ asset1 = create_application_asset(model, "Asset1")
58
+ asset2 = create_application_asset(model, "Asset2")
59
+ model.add_asset(asset1)
60
+ model.add_asset(asset2)
61
+
62
+ # Add attacker 1
63
+ attacker1 = AttackerAttachment()
64
+ model.add_attacker(attacker1)
65
+
66
+ attacker1.add_entrypoint(asset1, 'read')
67
+ assert len(attacker1.entry_points) == 1
68
+ assert attacker1.entry_points[0][0] == asset1
69
+ assert attacker1.entry_points[0][1] == ['read']
70
+
71
+ attacker1.add_entrypoint(asset1, 'access')
72
+ assert len(attacker1.entry_points) == 1
73
+ assert attacker1.entry_points[0][0] == asset1
74
+ assert attacker1.entry_points[0][1] == ['read', 'access']
75
+
76
+ # Try to add already existing entry point
77
+ attacker1.add_entrypoint(asset1, 'access')
78
+ assert len(attacker1.entry_points) == 1
79
+ assert attacker1.entry_points[0][0] == asset1
80
+ assert attacker1.entry_points[0][1] == ['read', 'access']
81
+
82
+ attacker1.add_entrypoint(asset2, 'access')
83
+ assert len(attacker1.entry_points) == 2
84
+ assert attacker1.entry_points[1][0] == asset2
85
+ assert attacker1.entry_points[1][1] == ['access']
86
+
87
+
88
+ def test_attacker_attachment_remove_entrypoint(model: Model):
89
+ """"""
90
+
91
+ asset1 = create_application_asset(model, "Asset1")
92
+ asset2 = create_application_asset(model, "Asset2")
93
+ model.add_asset(asset1)
94
+ model.add_asset(asset2)
95
+
96
+ # Add attacker 1
97
+ attacker1 = AttackerAttachment()
98
+ model.add_attacker(attacker1)
99
+
100
+ attacker1.add_entrypoint(asset1, 'read')
101
+ attacker1.add_entrypoint(asset1, 'access')
102
+ attacker1.add_entrypoint(asset2, 'access')
103
+
104
+ assert len(attacker1.entry_points) == 2
105
+ assert attacker1.entry_points[0][0] == asset1
106
+ assert attacker1.entry_points[0][1] == ['read', 'access']
107
+ assert attacker1.entry_points[1][0] == asset2
108
+ assert attacker1.entry_points[1][1] == ['access']
109
+
110
+ attacker1.remove_entrypoint(asset1, 'read')
111
+ assert len(attacker1.entry_points) == 2
112
+ assert attacker1.entry_points[0][0] == asset1
113
+ assert attacker1.entry_points[0][1] == ['access']
114
+ assert attacker1.entry_points[1][0] == asset2
115
+ assert attacker1.entry_points[1][1] == ['access']
116
+
117
+ # Try to remove inexistent entry point, but the asset is still present in
118
+ # the list of entry points
119
+ attacker1.remove_entrypoint(asset1, 'read')
120
+ assert len(attacker1.entry_points) == 2
121
+ assert attacker1.entry_points[0][0] == asset1
122
+ assert attacker1.entry_points[0][1] == ['access']
123
+ assert attacker1.entry_points[1][0] == asset2
124
+ assert attacker1.entry_points[1][1] == ['access']
125
+
126
+ attacker1.remove_entrypoint(asset1, 'access')
127
+ assert len(attacker1.entry_points) == 1
128
+ assert attacker1.entry_points[0][0] == asset2
129
+ assert attacker1.entry_points[0][1] == ['access']
130
+
131
+ # Try to remove inexistent entry point, where the asset is no longer in
132
+ # the list of entry points
133
+ attacker1.remove_entrypoint(asset1, 'access')
134
+ assert len(attacker1.entry_points) == 1
135
+ assert attacker1.entry_points[0][0] == asset2
136
+ assert attacker1.entry_points[0][1] == ['access']
137
+
138
+ attacker1.remove_entrypoint(asset2, 'access')
139
+ assert len(attacker1.entry_points) == 0
140
+
141
+
54
142
  def test_model_add_asset(model: Model):
55
143
  """Make sure assets are added correctly"""
56
144
 
File without changes
File without changes
File without changes