mal-toolbox 1.0.3__py3-none-any.whl → 1.0.4__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.4
2
2
  Name: mal-toolbox
3
- Version: 1.0.3
3
+ Version: 1.0.4
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>
6
6
  License: Apache Software License
@@ -1,6 +1,6 @@
1
- mal_toolbox-1.0.3.dist-info/licenses/AUTHORS,sha256=zxLrLe8EY39WtRKlAY4Oorx4Z2_LHV2ApRvDGZgY7xY,127
2
- mal_toolbox-1.0.3.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
3
- maltoolbox/__init__.py,sha256=ThfOuukbgjz1agfeDM8wvVb0jSZmy1OlTc2oVBB5JaM,2043
1
+ mal_toolbox-1.0.4.dist-info/licenses/AUTHORS,sha256=zxLrLe8EY39WtRKlAY4Oorx4Z2_LHV2ApRvDGZgY7xY,127
2
+ mal_toolbox-1.0.4.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
3
+ maltoolbox/__init__.py,sha256=Rw4utlzsR268vbMpZlmp3bDGJ80U0CWHiEXKOePe3jU,2043
4
4
  maltoolbox/__main__.py,sha256=A9jsYy94l1grHeSR3G3Ddn8Xg_nOihMSj1zZtVnYPSI,2974
5
5
  maltoolbox/exceptions.py,sha256=0YjPx2v1yYumZ2o7pVZ1s_jS-GAb3Ng979KEFhROSNY,1399
6
6
  maltoolbox/file_utils.py,sha256=fYG3UsvPQcU0ES_WI3nLfuzSZgc0jtE4IAxdMGgs9aA,1876
@@ -11,7 +11,7 @@ maltoolbox/attackgraph/attackgraph.py,sha256=I2jms_X1rRLkmvkmc0z3zQAa_TnO4xA7ulP
11
11
  maltoolbox/attackgraph/node.py,sha256=Z2sdzXhPel9h7ySxP9fjgd1exVmpRbvRySVtLpI1_BM,3904
12
12
  maltoolbox/attackgraph/analyzers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  maltoolbox/language/__init__.py,sha256=TsTTryEyjChwHN1o5F2BSUlFsAss2N6J0H0-nzvXiD8,489
14
- maltoolbox/language/languagegraph.py,sha256=1GMLYov2alHRLl4w9-o3-4Fe4d2FPRLr4qyXTot6mys,74428
14
+ maltoolbox/language/languagegraph.py,sha256=XWqVzHlf7EMWSkN3fQ-b6zA0pf_ysi_74YseAXAvSbs,71274
15
15
  maltoolbox/language/compiler/__init__.py,sha256=JQyAgDwJh1pU7AmuOhd1-d2b2PYXpgMVPtxnav8QHVc,15872
16
16
  maltoolbox/language/compiler/mal_lexer.py,sha256=BeifykDAt4PloRASOaLzBgWF35ev_zgD8lXMIsSHykc,12063
17
17
  maltoolbox/language/compiler/mal_parser.py,sha256=sUoaE43l2VKg-Dou30mk2wlVS1FvdOREwHNIyFe4IkY,114699
@@ -22,8 +22,8 @@ maltoolbox/translators/securicad.py,sha256=F_rndv2JyKxfHAXPwf2RrdiFPnemJVArYUpVs
22
22
  maltoolbox/translators/updater.py,sha256=UZPnx22udROiocCcSmtrgUJUupkjktkxl-M7rhBxUPc,8660
23
23
  maltoolbox/visualization/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
24
  maltoolbox/visualization/graphviz_utils.py,sha256=dfQhPL6Z2hvlMFpThsDr-5tm4Pa22SGHEiXw5ym9JJc,3906
25
- mal_toolbox-1.0.3.dist-info/METADATA,sha256=fIwAnRYoYzKPvs7zJF0UOzmuJtUQBXh974N-zAR3BTY,5382
26
- mal_toolbox-1.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
- mal_toolbox-1.0.3.dist-info/entry_points.txt,sha256=oqby5O6cUP_OHCm70k_iYPA6UlbTBf7se1i3XwdK3uU,56
28
- mal_toolbox-1.0.3.dist-info/top_level.txt,sha256=phqRVLRKGdSUgRY03mcpi2cmbbDo5YGjkV4gkqHFFcM,11
29
- mal_toolbox-1.0.3.dist-info/RECORD,,
25
+ mal_toolbox-1.0.4.dist-info/METADATA,sha256=SbesLITkX_biOanT4o22POBe74UNEjZWBLOJY1P2xS0,5382
26
+ mal_toolbox-1.0.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
+ mal_toolbox-1.0.4.dist-info/entry_points.txt,sha256=oqby5O6cUP_OHCm70k_iYPA6UlbTBf7se1i3XwdK3uU,56
28
+ mal_toolbox-1.0.4.dist-info/top_level.txt,sha256=phqRVLRKGdSUgRY03mcpi2cmbbDo5YGjkV4gkqHFFcM,11
29
+ mal_toolbox-1.0.4.dist-info/RECORD,,
maltoolbox/__init__.py CHANGED
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # MAL Toolbox v1.0.3
2
+ # MAL Toolbox v1.0.4
3
3
  # Copyright 2025, 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__ = "1.0.3"
24
+ __version__ = "1.0.4"
25
25
  __authors__ = [
26
26
  "Andrei Buhaiu",
27
27
  "Giuseppe Nebbione",
@@ -26,131 +26,6 @@ from ..exceptions import (
26
26
 
27
27
  logger = logging.getLogger(__name__)
28
28
 
29
- predef_ttcs: dict[str, dict] = {
30
- 'EasyAndUncertain':
31
- {
32
- 'arguments': [0.5],
33
- 'name': 'Bernoulli',
34
- 'type': 'function'
35
- },
36
- 'HardAndUncertain':
37
- {
38
- 'lhs':
39
- {
40
- 'arguments': [0.1],
41
- 'name': 'Exponential',
42
- 'type': 'function'
43
- },
44
- 'rhs':
45
- {
46
- 'arguments': [0.5],
47
- 'name': 'Bernoulli',
48
- 'type': 'function'
49
- },
50
- 'type': 'multiplication'
51
- },
52
- 'VeryHardAndUncertain':
53
- {
54
- 'lhs':
55
- {
56
- 'arguments': [0.01],
57
- 'name': 'Exponential',
58
- 'type': 'function'
59
- },
60
- 'rhs':
61
- {
62
- 'arguments': [0.5],
63
- 'name': 'Bernoulli',
64
- 'type': 'function'
65
- },
66
- 'type': 'multiplication'
67
- },
68
- 'EasyAndCertain':
69
- {
70
- 'arguments': [1.0],
71
- 'name': 'Exponential',
72
- 'type': 'function'
73
- },
74
- 'HardAndCertain':
75
- {
76
- 'arguments': [0.1],
77
- 'name': 'Exponential',
78
- 'type': 'function'
79
- },
80
- 'VeryHardAndCertain':
81
- {
82
- 'arguments': [0.01],
83
- 'name': 'Exponential',
84
- 'type': 'function'
85
- },
86
- 'Enabled':
87
- {
88
- 'arguments': [1.0],
89
- 'name': 'Bernoulli',
90
- 'type': 'function'
91
- },
92
- 'Instant':
93
- {
94
- 'arguments': [1.0],
95
- 'name': 'Bernoulli',
96
- 'type': 'function'
97
- },
98
- 'Disabled':
99
- {
100
- 'arguments': [0.0],
101
- 'name': 'Bernoulli',
102
- 'type': 'function'
103
- },
104
- }
105
-
106
- def get_ttc_distribution(
107
- step_dict: dict,
108
- defense_default_ttc = None,
109
- attack_default_ttc = None
110
- ) -> Optional[dict]:
111
- """Convert step TTC to a TTC distribution if needed
112
-
113
- - If no TTC is set, set return default TTC.
114
- - If the TTC provided is a predefined name replace it with the
115
- probability distribution it corresponds to.
116
- - Otherwise return the TTC distribution as is.
117
-
118
- Arguments:
119
- step_dict - A dict with the attack step data
120
- defense_default_ttc - the value to give a defense ttc if none is set
121
- attack_default_ttc - the value to give an attack ttc if none is set
122
-
123
- Returns:
124
- A dict with the steps TTC distribution, or None if the step is not
125
- a defense or attack step
126
- """
127
-
128
- if defense_default_ttc is None:
129
- defense_default_ttc = predef_ttcs['Disabled'].copy()
130
- if attack_default_ttc is None:
131
- attack_default_ttc = predef_ttcs['Instant'].copy()
132
-
133
- step_ttc = step_dict['ttc']
134
-
135
- if step_dict['type'] == 'defense':
136
- if step_ttc is None:
137
- # No step ttc set in language for defense
138
- step_ttc = defense_default_ttc
139
- elif step_dict['type'] in ('or', 'and'):
140
- if step_ttc is None:
141
- # No step ttc set in language for attack
142
- step_ttc = attack_default_ttc
143
- else:
144
- # No TTC for other step types
145
- return None
146
-
147
- if 'name' in step_ttc and step_ttc['name'] in predef_ttcs:
148
- # Predefined step ttc set in language, fetch from dict
149
- step_ttc = predef_ttcs[step_ttc['name']].copy()
150
-
151
- return step_ttc
152
-
153
-
154
29
 
155
30
  def disaggregate_attack_step_full_name(
156
31
  attack_step_full_name: str) -> list[str]:
@@ -998,7 +873,7 @@ class LanguageGraph():
998
873
  name = attack_step_dict['name'],
999
874
  type = attack_step_dict['type'],
1000
875
  asset = asset,
1001
- ttc = get_ttc_distribution(attack_step_dict),
876
+ ttc = attack_step_dict['ttc'],
1002
877
  overrides = attack_step_dict['overrides'],
1003
878
  own_children = {},
1004
879
  own_parents = {},
@@ -1716,7 +1591,7 @@ class LanguageGraph():
1716
1591
  name = attack_step_attribs['name'],
1717
1592
  type = attack_step_attribs['type'],
1718
1593
  asset = asset,
1719
- ttc = get_ttc_distribution(attack_step_attribs),
1594
+ ttc = attack_step_attribs['ttc'],
1720
1595
  overrides = (
1721
1596
  attack_step_attribs['reaches']['overrides']
1722
1597
  if attack_step_attribs['reaches'] else False