Skip to content

Commit cafcf9d

Browse files
Reformat python with black (#671)
update should be good.
2 parents 4e4e3f9 + 51439d0 commit cafcf9d

25 files changed

+261
-99
lines changed

src/SSVC_csv-to-latex.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ def print_forest_options(
238238
"""
239239
)
240240
location.write(pri5string)
241-
location.write("}\n") # close the last tikzset; forestset is already closed
241+
location.write(
242+
"}\n"
243+
) # close the last tikzset; forestset is already closed
242244

243245

244246
def begin_forest(location):
@@ -348,7 +350,9 @@ def main():
348350
if path[i] not in dpoint_values[i]:
349351
dpoint_values[i].append(path[i])
350352
for i in range(depth):
351-
dpoint_values[i].sort(key=lambda j: sort_order[i].index(j), reverse=True)
353+
dpoint_values[i].sort(
354+
key=lambda j: sort_order[i].index(j), reverse=True
355+
)
352356
# reverse because the latex will flip it again
353357
# loop twice so we don't sort every time we check a new path
354358

@@ -380,7 +384,9 @@ def main():
380384
del tmp_path[-1]
381385
i = i - 1
382386
ofile.write(latex_brace_close) # close each latex brace
383-
del tmp_path[-1] # every time we close a brace, update the path to reflect
387+
del tmp_path[
388+
-1
389+
] # every time we close a brace, update the path to reflect
384390
else: # "Normal" case
385391
if counts[i] == len(dpoint_values[i]):
386392
try:

src/ssvc/csv_analyzer.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ def _imp_df(column_names: list, importances: list) -> pd.DataFrame:
9595
a dataframe of feature importances
9696
"""
9797
df = (
98-
pd.DataFrame({"feature": column_names, "feature_importance": importances})
98+
pd.DataFrame(
99+
{"feature": column_names, "feature_importance": importances}
100+
)
99101
.sort_values("feature_importance", ascending=False)
100102
.reset_index(drop=True)
101103
)
@@ -184,7 +186,9 @@ def _perm_feat_imp(model, x, y):
184186

185187
def _parse_args(args) -> argparse.Namespace:
186188
# parse command line
187-
parser = argparse.ArgumentParser(description="Analyze an SSVC tree csv file")
189+
parser = argparse.ArgumentParser(
190+
description="Analyze an SSVC tree csv file"
191+
)
188192
parser.add_argument(
189193
"csvfile", metavar="csvfile", type=str, help="the csv file to analyze"
190194
)
@@ -371,8 +375,12 @@ def check_topological_order(df, target):
371375
for u in H.nodes:
372376
H.nodes[u]["outcome"] = G.nodes[u]["outcome"]
373377

374-
logger.debug(f"Original graph: {len(G.nodes)} nodes with {len(G.edges)} edges")
375-
logger.debug(f"Reduced graph: {len(H.nodes)} nodes with {len(H.edges)} edges")
378+
logger.debug(
379+
f"Original graph: {len(G.nodes)} nodes with {len(G.edges)} edges"
380+
)
381+
logger.debug(
382+
f"Reduced graph: {len(H.nodes)} nodes with {len(H.edges)} edges"
383+
)
376384

377385
problems = []
378386
# check if the outcome is topologically sorted

src/ssvc/decision_points/cvss/attack_vector.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,12 @@
194194
),
195195
)
196196

197-
versions = [ACCESS_VECTOR_1, ACCESS_VECTOR_2, ATTACK_VECTOR_3, ATTACK_VECTOR_3_0_1]
197+
versions = [
198+
ACCESS_VECTOR_1,
199+
ACCESS_VECTOR_2,
200+
ATTACK_VECTOR_3,
201+
ATTACK_VECTOR_3_0_1,
202+
]
198203

199204

200205
def main():

src/ssvc/decision_points/cvss/availability_impact.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@
127127
),
128128
)
129129

130-
versions = [AVAILABILITY_IMPACT_1, AVAILABILITY_IMPACT_2, AVAILABILITY_IMPACT_2_0_1]
130+
versions = [
131+
AVAILABILITY_IMPACT_1,
132+
AVAILABILITY_IMPACT_2,
133+
AVAILABILITY_IMPACT_2_0_1,
134+
]
131135

132136

133137
def main():

src/ssvc/decision_points/cvss/availability_requirement.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
# U.S. Patent and Trademark Office by Carnegie Mellon University
1818

1919
from ssvc.decision_points.base import SsvcDecisionPointValue
20-
from ssvc.decision_points.cvss._not_defined import NOT_DEFINED_ND, NOT_DEFINED_X
20+
from ssvc.decision_points.cvss._not_defined import (
21+
NOT_DEFINED_ND,
22+
NOT_DEFINED_X,
23+
)
2124
from ssvc.decision_points.cvss.base import CvssDecisionPoint
2225
from ssvc.decision_points.helpers import print_versions_and_diffs
2326

src/ssvc/decision_points/cvss/confidentiality_requirement.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
# U.S. Patent and Trademark Office by Carnegie Mellon University
1818

1919
from ssvc.decision_points.base import SsvcDecisionPointValue
20-
from ssvc.decision_points.cvss._not_defined import NOT_DEFINED_ND, NOT_DEFINED_X
20+
from ssvc.decision_points.cvss._not_defined import (
21+
NOT_DEFINED_ND,
22+
NOT_DEFINED_X,
23+
)
2124
from ssvc.decision_points.cvss.base import CvssDecisionPoint
2225
from ssvc.decision_points.helpers import print_versions_and_diffs
2326

src/ssvc/decision_points/cvss/exploitability.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
# U.S. Patent and Trademark Office by Carnegie Mellon University
1818

1919
from ssvc.decision_points.base import SsvcDecisionPointValue
20-
from ssvc.decision_points.cvss._not_defined import NOT_DEFINED_ND, NOT_DEFINED_X
20+
from ssvc.decision_points.cvss._not_defined import (
21+
NOT_DEFINED_ND,
22+
NOT_DEFINED_X,
23+
)
2124
from ssvc.decision_points.cvss.base import CvssDecisionPoint
2225
from ssvc.decision_points.helpers import print_versions_and_diffs
2326

src/ssvc/decision_points/cvss/integrity_requirement.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
# U.S. Patent and Trademark Office by Carnegie Mellon University
1818

1919
from ssvc.decision_points.base import SsvcDecisionPointValue
20-
from ssvc.decision_points.cvss._not_defined import NOT_DEFINED_ND, NOT_DEFINED_X
20+
from ssvc.decision_points.cvss._not_defined import (
21+
NOT_DEFINED_ND,
22+
NOT_DEFINED_X,
23+
)
2124
from ssvc.decision_points.cvss.base import CvssDecisionPoint
2225
from ssvc.decision_points.helpers import print_versions_and_diffs
2326

src/ssvc/decision_points/cvss/report_confidence.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
# U.S. Patent and Trademark Office by Carnegie Mellon University
1818

1919
from ssvc.decision_points.base import SsvcDecisionPointValue
20-
from ssvc.decision_points.cvss._not_defined import NOT_DEFINED_ND, NOT_DEFINED_X
20+
from ssvc.decision_points.cvss._not_defined import (
21+
NOT_DEFINED_ND,
22+
NOT_DEFINED_X,
23+
)
2124
from ssvc.decision_points.cvss.base import CvssDecisionPoint
2225
from ssvc.decision_points.helpers import print_versions_and_diffs
2326

src/ssvc/decision_points/helpers.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ def dp_diff(dp1: SsvcDecisionPoint, dp2: SsvcDecisionPoint) -> list[str]:
126126
major = True
127127

128128
for name in dp2_names.difference(dp1_names):
129-
diffs.append(f"(major or minor) {dp2.name} v{dp2.version} adds value {name}")
129+
diffs.append(
130+
f"(major or minor) {dp2.name} v{dp2.version} adds value {name}"
131+
)
130132
maybe_major = True
131133
maybe_minor = True
132134

@@ -139,17 +141,27 @@ def dp_diff(dp1: SsvcDecisionPoint, dp2: SsvcDecisionPoint) -> list[str]:
139141
v2 = v2[name]
140142

141143
if v1 != v2:
142-
diffs.append(f"(minor) {dp2.name} v{dp2.version} value {name} key changed")
144+
diffs.append(
145+
f"(minor) {dp2.name} v{dp2.version} value {name} key changed"
146+
)
143147
minor = True
144148
else:
145-
diffs.append(f"{dp2.name} v{dp2.version} value {name} key did not change")
149+
diffs.append(
150+
f"{dp2.name} v{dp2.version} value {name} key did not change"
151+
)
146152

147153
# did the value descriptions change?
148154
for name in intersection:
149-
v1 = {value["name"]: value["description"] for value in dp1.to_dict()["values"]}
155+
v1 = {
156+
value["name"]: value["description"]
157+
for value in dp1.to_dict()["values"]
158+
}
150159
v1 = v1[name]
151160

152-
v2 = {value["name"]: value["description"] for value in dp2.to_dict()["values"]}
161+
v2 = {
162+
value["name"]: value["description"]
163+
for value in dp2.to_dict()["values"]
164+
}
153165
v2 = v2[name]
154166

155167
if v1 != v2:

0 commit comments

Comments
 (0)