mal-toolbox 0.1.7__py3-none-any.whl → 0.1.8__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.
- {mal_toolbox-0.1.7.dist-info → mal_toolbox-0.1.8.dist-info}/METADATA +1 -1
- {mal_toolbox-0.1.7.dist-info → mal_toolbox-0.1.8.dist-info}/RECORD +8 -8
- maltoolbox/__init__.py +2 -2
- maltoolbox/model.py +52 -23
- {mal_toolbox-0.1.7.dist-info → mal_toolbox-0.1.8.dist-info}/AUTHORS +0 -0
- {mal_toolbox-0.1.7.dist-info → mal_toolbox-0.1.8.dist-info}/LICENSE +0 -0
- {mal_toolbox-0.1.7.dist-info → mal_toolbox-0.1.8.dist-info}/WHEEL +0 -0
- {mal_toolbox-0.1.7.dist-info → mal_toolbox-0.1.8.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mal-toolbox
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.8
|
|
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
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
maltoolbox/__init__.py,sha256=
|
|
1
|
+
maltoolbox/__init__.py,sha256=c31l952N_1NVtHOSM-r2F5gL-RwHqye846B524iVwx4,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=
|
|
6
|
+
maltoolbox/model.py,sha256=1HuH58skm1StcKtvMFO-iXkpLOaauB9YSEv1XNdW_-Y,30406
|
|
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
|
|
@@ -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.
|
|
28
|
-
mal_toolbox-0.1.
|
|
29
|
-
mal_toolbox-0.1.
|
|
30
|
-
mal_toolbox-0.1.
|
|
31
|
-
mal_toolbox-0.1.
|
|
32
|
-
mal_toolbox-0.1.
|
|
27
|
+
mal_toolbox-0.1.8.dist-info/AUTHORS,sha256=zxLrLe8EY39WtRKlAY4Oorx4Z2_LHV2ApRvDGZgY7xY,127
|
|
28
|
+
mal_toolbox-0.1.8.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
29
|
+
mal_toolbox-0.1.8.dist-info/METADATA,sha256=qzQgXn7tofBgGq_HKWwqk7NFLcQnQobIVI8oYNqNRcY,5953
|
|
30
|
+
mal_toolbox-0.1.8.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
|
|
31
|
+
mal_toolbox-0.1.8.dist-info/top_level.txt,sha256=phqRVLRKGdSUgRY03mcpi2cmbbDo5YGjkV4gkqHFFcM,11
|
|
32
|
+
mal_toolbox-0.1.8.dist-info/RECORD,,
|
maltoolbox/__init__.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
# MAL Toolbox v0.1.
|
|
2
|
+
# MAL Toolbox v0.1.8
|
|
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.
|
|
24
|
+
__version__ = '0.1.8'
|
|
25
25
|
__authors__ = ['Andrei Buhaiu',
|
|
26
26
|
'Giuseppe Nebbione',
|
|
27
27
|
'Nikolaos Kakouros',
|
maltoolbox/model.py
CHANGED
|
@@ -28,24 +28,45 @@ logger = logging.getLogger(__name__)
|
|
|
28
28
|
|
|
29
29
|
@dataclass
|
|
30
30
|
class AttackerAttachment:
|
|
31
|
-
"""Used to attach attackers to attack step
|
|
31
|
+
"""Used to attach attackers to attack step entry points of assets"""
|
|
32
32
|
id: Optional[int] = None
|
|
33
33
|
name: Optional[str] = None
|
|
34
34
|
entry_points: list[tuple[SchemaGeneratedClass, list[str]]] = \
|
|
35
35
|
field(default_factory=lambda: [])
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
def
|
|
38
|
+
def get_entry_point_tuple(
|
|
39
|
+
self,
|
|
40
|
+
asset: SchemaGeneratedClass
|
|
41
|
+
) -> Optional[tuple[SchemaGeneratedClass, list[str]]]:
|
|
42
|
+
"""Return an entry point tuple of an AttackerAttachment matching the
|
|
43
|
+
asset provided.
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
Arguments:
|
|
47
|
+
asset - the asset to add entry point to
|
|
48
|
+
|
|
49
|
+
Return:
|
|
50
|
+
The entry point tuple containing the asset and the list of attack
|
|
51
|
+
steps if the asset has any entry points defined for this attacker
|
|
52
|
+
attachemnt.
|
|
53
|
+
None, otherwise.
|
|
54
|
+
"""
|
|
55
|
+
return next((ep_tuple for ep_tuple in self.entry_points
|
|
56
|
+
if ep_tuple[0] == asset), None)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def add_entry_point(
|
|
39
60
|
self, asset: SchemaGeneratedClass, attackstep_name: str):
|
|
40
|
-
"""Add an
|
|
61
|
+
"""Add an entry point to an AttackerAttachment
|
|
41
62
|
|
|
42
63
|
self.entry_points contain tuples, first element of each tuple
|
|
43
64
|
is an asset, second element is a list of attack step names that
|
|
44
65
|
are entry points for the attacker.
|
|
45
66
|
|
|
46
|
-
|
|
47
|
-
asset - the asset to add
|
|
48
|
-
attackstep_name - the name of the attack step to add as an
|
|
67
|
+
Arguments:
|
|
68
|
+
asset - the asset to add the entry point to
|
|
69
|
+
attackstep_name - the name of the attack step to add as an entry point
|
|
49
70
|
"""
|
|
50
71
|
|
|
51
72
|
logger.debug(
|
|
@@ -53,42 +74,44 @@ class AttackerAttachment:
|
|
|
53
74
|
f'to AttackerAttachment "{self.name}".'
|
|
54
75
|
)
|
|
55
76
|
|
|
56
|
-
# Get the
|
|
57
|
-
|
|
58
|
-
if ep_tuple[0] == asset), None)
|
|
77
|
+
# Get the entry point tuple for the asset if it already exists
|
|
78
|
+
entry_point_tuple = self.get_entry_point_tuple(asset)
|
|
59
79
|
|
|
60
|
-
if
|
|
61
|
-
if attackstep_name not in
|
|
80
|
+
if entry_point_tuple:
|
|
81
|
+
if attackstep_name not in entry_point_tuple[1]:
|
|
62
82
|
# If it exists and does not already have the attack step,
|
|
63
83
|
# add it
|
|
64
|
-
|
|
84
|
+
entry_point_tuple[1].append(attackstep_name)
|
|
65
85
|
else:
|
|
66
86
|
logger.info(
|
|
67
87
|
f'Entry point "{attackstep_name}" on asset "{asset.name}"'
|
|
68
88
|
f' already existed for AttackerAttachment "{self.name}".'
|
|
69
89
|
)
|
|
70
90
|
else:
|
|
71
|
-
# Otherwise, create the
|
|
91
|
+
# Otherwise, create the entry point tuple and the initial entry
|
|
72
92
|
# point
|
|
73
93
|
self.entry_points.append((asset, [attackstep_name]))
|
|
74
94
|
|
|
75
|
-
def
|
|
95
|
+
def remove_entry_point(
|
|
76
96
|
self, asset: SchemaGeneratedClass, attackstep_name: str):
|
|
77
|
-
"""Remove an
|
|
97
|
+
"""Remove an entry point from an AttackerAttachment if it exists
|
|
98
|
+
|
|
99
|
+
Arguments:
|
|
100
|
+
asset - the asset to remove the entry point from
|
|
101
|
+
"""
|
|
78
102
|
|
|
79
103
|
logger.debug(
|
|
80
104
|
f'Remove entry point "{attackstep_name}" on asset "{asset.name}" '
|
|
81
105
|
f'from AttackerAttachment "{self.name}".'
|
|
82
106
|
)
|
|
83
107
|
|
|
84
|
-
# Get the
|
|
85
|
-
|
|
86
|
-
if ep_tuple[0] == asset), None)
|
|
108
|
+
# Get the entry point tuple for the asset if it exists
|
|
109
|
+
entry_point_tuple = self.get_entry_point_tuple(asset)
|
|
87
110
|
|
|
88
|
-
if
|
|
89
|
-
if attackstep_name in
|
|
111
|
+
if entry_point_tuple:
|
|
112
|
+
if attackstep_name in entry_point_tuple[1]:
|
|
90
113
|
# If it exists and not already has the attack step, add it
|
|
91
|
-
|
|
114
|
+
entry_point_tuple[1].remove(attackstep_name)
|
|
92
115
|
else:
|
|
93
116
|
logger.warning(
|
|
94
117
|
f'Failed to find entry point "{attackstep_name}" on '
|
|
@@ -96,8 +119,8 @@ class AttackerAttachment:
|
|
|
96
119
|
f'"{self.name}". Nothing to remove.'
|
|
97
120
|
)
|
|
98
121
|
|
|
99
|
-
if not
|
|
100
|
-
self.entry_points.remove(
|
|
122
|
+
if not entry_point_tuple[1]:
|
|
123
|
+
self.entry_points.remove(entry_point_tuple)
|
|
101
124
|
else:
|
|
102
125
|
logger.warning(
|
|
103
126
|
f'Failed to find entry points on asset "{asset.name}" '
|
|
@@ -205,6 +228,12 @@ class Model():
|
|
|
205
228
|
for association in asset.associations:
|
|
206
229
|
self.remove_asset_from_association(asset, association)
|
|
207
230
|
|
|
231
|
+
# Also remove all of the entry points
|
|
232
|
+
for attacker in self.attackers:
|
|
233
|
+
entry_point_tuple = attacker.get_entry_point_tuple(asset)
|
|
234
|
+
if entry_point_tuple:
|
|
235
|
+
attacker.entry_points.remove(entry_point_tuple)
|
|
236
|
+
|
|
208
237
|
self.assets.remove(asset)
|
|
209
238
|
|
|
210
239
|
def remove_asset_from_association(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|