From fe86867f8c2f7b4b8ae58901d63d65e5084085f8 Mon Sep 17 00:00:00 2001 From: eric-intuitem <71850047+eric-intuitem@users.noreply.github.com> Date: Sat, 4 May 2024 14:12:04 +0200 Subject: [PATCH] Update convert_library.py ruff + simpler messages --- tools/convert_library.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tools/convert_library.py b/tools/convert_library.py index 755445fd4..ba4397129 100644 --- a/tools/convert_library.py +++ b/tools/convert_library.py @@ -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. """ @@ -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() @@ -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]) @@ -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 @@ -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"] @@ -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"] @@ -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: @@ -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: @@ -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"]