mal-toolbox 0.1.5__py3-none-any.whl → 0.1.7__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.
@@ -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,13 +1,13 @@
1
- maltoolbox/__init__.py,sha256=rUX4r-INojlNiyot2JO3JG3x1xKFg6I5rBJp48kjj5A,2776
1
+ maltoolbox/__init__.py,sha256=m8DwUE52qPDjN3XgWBjVF4b807NROYD3yQ-NdHmXNGg,2776
2
2
  maltoolbox/__main__.py,sha256=1lOOOme_y56VWrEE1jkarTt-WoUo9yilCo8sUrivyns,2680
3
3
  maltoolbox/default.conf,sha256=YLGBSJh2q8hn3RzRRBbib9F6E6pcvquoHeALMRtA0wU,295
4
4
  maltoolbox/exceptions.py,sha256=0YjPx2v1yYumZ2o7pVZ1s_jS-GAb3Ng979KEFhROSNY,1399
5
5
  maltoolbox/file_utils.py,sha256=6KFEEZvf9x8yfNAq7hadF7lUGlLimNFMJ0W_DK2rh6Q,2024
6
- maltoolbox/model.py,sha256=V-tvAxdfypj3kHY1XFHd0yrAZi5cXGg1N-Bz8z_K_FU,26608
6
+ maltoolbox/model.py,sha256=3x4RF8aYc2bupjpUvEtPhzhIxNWlKRtA2bVsPyDAAQA,29501
7
7
  maltoolbox/wrappers.py,sha256=BYYNcIdTlyumADQCPcy1xmPEabfmi0P1l9RcbdVWm9w,2002
8
8
  maltoolbox/attackgraph/__init__.py,sha256=F6maWV2PYSH5xtbqozeM3IolalWQqs-tdaCG2ywbqKI,102
9
9
  maltoolbox/attackgraph/attacker.py,sha256=hmJtgcwtQgz0r9J_0Pgm7ktfKpFE3dp-HJ2TOz1NiWw,2880
10
- maltoolbox/attackgraph/attackgraph.py,sha256=cFtNiZN17g0mlOJWFfavlmAnSsUtNQNCC5qVdTkabMA,28254
10
+ maltoolbox/attackgraph/attackgraph.py,sha256=lIn7_k7T6DL4AovNtBTdamsJ5j5080HCk0OWNqUExj8,28254
11
11
  maltoolbox/attackgraph/node.py,sha256=XSjMPqCGtnMeTXJDS2QluLcK5sLlsxpFIFpy2twJ2PQ,4603
12
12
  maltoolbox/attackgraph/query.py,sha256=ukMfkSnixBenfeg5H1SokoSftGo-V4xPL5qpgSaeMN4,5232
13
13
  maltoolbox/attackgraph/analyzers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -24,9 +24,9 @@ maltoolbox/language/compiler/mal_visitor.py,sha256=9gG06D7GZKlBY-62SmbIkRYkGBUBI
24
24
  maltoolbox/translators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
25
  maltoolbox/translators/securicad.py,sha256=FAIHnoqFTmNYbCGxLsK6pX5g1oiNFfPTqkT_3qq3GG8,6692
26
26
  maltoolbox/translators/updater.py,sha256=Ap08-AsU_7or5ESQvZL2i4nWz3B5pvgfftZyc_-Gd8M,4766
27
- mal_toolbox-0.1.5.dist-info/AUTHORS,sha256=zxLrLe8EY39WtRKlAY4Oorx4Z2_LHV2ApRvDGZgY7xY,127
28
- mal_toolbox-0.1.5.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
29
- mal_toolbox-0.1.5.dist-info/METADATA,sha256=nxeTdGyeJKiHyb4cOU51aCD_-mXpNBkI727fu8tOGJk,5873
30
- mal_toolbox-0.1.5.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
31
- mal_toolbox-0.1.5.dist-info/top_level.txt,sha256=phqRVLRKGdSUgRY03mcpi2cmbbDo5YGjkV4gkqHFFcM,11
32
- mal_toolbox-0.1.5.dist-info/RECORD,,
27
+ mal_toolbox-0.1.7.dist-info/AUTHORS,sha256=zxLrLe8EY39WtRKlAY4Oorx4Z2_LHV2ApRvDGZgY7xY,127
28
+ mal_toolbox-0.1.7.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
29
+ mal_toolbox-0.1.7.dist-info/METADATA,sha256=4cQueA0Qk8bgty_GTnZ__kv__xEm4hUZHxwyq0F1hNA,5953
30
+ mal_toolbox-0.1.7.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
31
+ mal_toolbox-0.1.7.dist-info/top_level.txt,sha256=phqRVLRKGdSUgRY03mcpi2cmbbDo5YGjkV4gkqHFFcM,11
32
+ mal_toolbox-0.1.7.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (71.1.0)
2
+ Generator: setuptools (73.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
maltoolbox/__init__.py CHANGED
@@ -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'])
maltoolbox/model.py CHANGED
@@ -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"""