|
43 | 43 | if file_record["filepath"].startswith(".github"):
|
44 | 44 | continue
|
45 | 45 |
|
46 |
| - # Filter the updated control files |
| 46 | + # Filter the updated control files for syncing OSCAL catalog |
47 | 47 | 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) |
49 | 50 |
|
50 | 51 | try:
|
51 | 52 | diff_structure = diff_analysis.analyse_file(file_record)
|
|
62 | 63 | list_of_tests = connect_to_labels.get_labels(tests, options.output)
|
63 | 64 | if options.output == "json":
|
64 | 65 | 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) |
65 | 70 | else:
|
66 | 71 | 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}") |
77 | 72 | logger.debug("Finished")
|
0 commit comments