Skip to content

Commit

Permalink
Update convert_library.py
Browse files Browse the repository at this point in the history
ruff + simpler messages
  • Loading branch information
eric-intuitem committed May 4, 2024
1 parent 8887ff6 commit fe86867
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions tools/convert_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
- description: description of the object
- grid: several columns describing the matrix with colors.
The grid shall be aligned with the probability objects, the columns being the impact in order of id, and the content of each cell being the id of the risk.
This is a topological representation. The display on the screen (transposition, direction of axes) will be managed in the frontend, not in the data model.
This is a topological representation. The display on the screen (transposition, direction of axes) will be managed in the frontend, not in the data model.
A library has a single locale. Translated libraries have the same urns, they are merged during import.
Dependencies are given as a comma or blank separated list of urns.
"""
Expand Down Expand Up @@ -109,9 +109,10 @@


parser = argparse.ArgumentParser(
prog='convert-library.py',
description='convert an Excel file in a library for CISO Assistant')
parser.add_argument('input_file_name')
prog="convert-library.py",
description="convert an Excel file in a library for CISO Assistant",
)
parser.add_argument("input_file_name")
args = parser.parse_args()

ref_name = re.sub(r"\.\w+$", "", args.input_file_name).lower()
Expand Down Expand Up @@ -253,7 +254,7 @@ def get_color(wb, cell):
print("parsing tab", tab.title)
title = tab.title
if title.lower() == "library_content":
print("...processing content")
print("processing library content")
for row in tab:
if any([r.value for r in row]):
(v1, v2, v3) = (r.value for r in row[0:3])
Expand All @@ -266,7 +267,7 @@ def get_color(wb, cell):
elif title not in library_vars_dict["tab"]:
print(f"Ignored tab: {title}")
elif library_vars_dict["tab"][title] == "requirements":
print("...processing requirements")
print("processing requirements")
root_nodes_urn = re.sub("framework", "req_node", library_vars["framework_urn"])
current_node_urn = None
current_depth = 0
Expand Down Expand Up @@ -379,7 +380,7 @@ def get_color(wb, cell):
pass
# print("empty row")
elif library_vars_dict["tab"][title] == "reference_controls":
print("...processing reference controls")
print("processing reference controls")
current_function = {}
is_header = True
reference_controls_base_urn = library_vars["reference_control_base_urn"]
Expand Down Expand Up @@ -420,7 +421,7 @@ def get_color(wb, cell):
current_function["annotation"] = annotation
reference_controls.append(current_function)
elif library_vars_dict["tab"][title] == "threats":
print("...processing threats")
print("processing threats")
current_threat = {}
is_header = True
threat_base_urn = library_vars["threat_base_urn"]
Expand Down Expand Up @@ -457,7 +458,7 @@ def get_color(wb, cell):
current_threat["annotation"] = annotation
threats.append(current_threat)
elif library_vars_dict["tab"][title] == "scores":
print("...processing scores")
print("processing scores")
is_header = True
for row in tab:
if is_header:
Expand All @@ -474,7 +475,7 @@ def get_color(wb, cell):
{"score": score, "name": name, "description": description}
)
elif library_vars_dict["tab"][title] == "implementation_groups":
print("...processing implementation groups")
print("processing implementation groups")
is_header = True
for row in tab:
if is_header:
Expand All @@ -491,7 +492,7 @@ def get_color(wb, cell):
{"ref_id": ref_id, "name": name, "description": description}
)
elif library_vars_dict["tab"][title] == "risk_matrix":
print("...processing risk matrix")
print("processing risk matrix")
risk_matrix["urn"] = library_vars["risk_matrix_urn"]
risk_matrix["ref_id"] = library_vars["risk_matrix_ref_id"]
risk_matrix["name"] = library_vars["risk_matrix_name"]
Expand Down

0 comments on commit fe86867

Please sign in to comment.