Skip to content

Commit 9006a8a

Browse files
committed
save the controls updates to the same output file
Signed-off-by: Sophia Wang <[email protected]>
1 parent cf1c9f3 commit 9006a8a

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

Diff for: content_test_filtering.py

+7-12
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@
4343
if file_record["filepath"].startswith(".github"):
4444
continue
4545

46-
# Filter the updated control files
46+
# Filter the updated control files for syncing OSCAL catalog
4747
if "controls/" in file_record["filepath"]:
48-
controls_files.append(file_record["filepath"])
48+
control_file = file_record["filepath"].split('/')[-1]
49+
controls_files.append(control_file)
4950

5051
try:
5152
diff_structure = diff_analysis.analyse_file(file_record)
@@ -62,16 +63,10 @@
6263
list_of_tests = connect_to_labels.get_labels(tests, options.output)
6364
if options.output == "json":
6465
logs.print_json(list_of_tests)
66+
logger.debug(f"The updated controls: {controls_files}")
67+
if controls_files:
68+
controls_updates = [{"controls": controls_files}]
69+
logs.print_json(controls_updates)
6570
else:
6671
logs.print_all_logs(list_of_tests, output_format=options.output_format)
67-
# Save the updated controls to a file for syncing OSCAL catalog
68-
logger.debug(f"The updated controls: {controls_files}")
69-
if options.output == "json":
70-
controls_updates = {"controls": controls_files}
71-
try:
72-
with open('controls_updates.json', 'w', encoding='utf-8') as file:
73-
json.dump(controls_updates, file, ensure_ascii=False, indent=4)
74-
logger.debug("Controls saved to controls_updates.json successfully.")
75-
except Exception as e:
76-
logger.error(f"Error saving controls updates: {e}")
7772
logger.debug("Finished")

0 commit comments

Comments
 (0)