60
60
61
61
62
62
def analyse_prospector_reports (filename : str , selected_cves : str ):
63
- """Analyses Prospector reports. Creates the summary_execution_results table."""
63
+ """Analyses Prospector reports and categorises them into high, medium,
64
+ low ... categories given a ground truth.
65
+
66
+ Creates the summary_execution_[mvi|nvi]_table.tex table.
67
+ Creates a JSON file with a list of CVE IDs for each category of the table. These files are used for the flow analysis (`analyse_category_flows()`).
68
+
69
+ """
64
70
file = INPUT_DATA_PATH + filename + ".csv"
65
71
dataset = load_dataset (file )
66
- # dataset = dataset[:100] # Actual line number in D53.csv -2
67
- # dataset = dataset[198:199] # Actual line number in D53.csv -2
72
+
68
73
if selected_cves != "all" and len (selected_cves ) != 0 :
69
74
dataset = [c for c in dataset if c [0 ] in selected_cves ]
70
75
@@ -312,7 +317,8 @@ def _save_summary_execution_details(
312
317
313
318
314
319
def count_existing_reports (data_filepath ):
315
- """Prints which CVEs reports are missing for to the console."""
320
+ """Prints which CVEs reports are missing for given the ground truth dataset
321
+ to the console."""
316
322
file = INPUT_DATA_PATH + data_filepath + ".csv"
317
323
dataset = load_dataset (file )
318
324
@@ -347,13 +353,13 @@ def analyse_category_flows():
347
353
"""
348
354
summary_execution_file = (
349
355
ANALYSIS_RESULTS_PATH
350
- + "summary_execution/ "
356
+ + "summary_execution_ "
351
357
+ PROSPECTOR_REPORTS_PATH_HOST .split ("/" )[- 2 ]
352
358
+ ".json"
353
359
)
354
360
summary_execution_comparison_file = (
355
361
ANALYSIS_RESULTS_PATH
356
- + "summary_execution/ "
362
+ + "summary_execution_ "
357
363
+ COMPARISON_DIRECTORY .split ("/" )[- 2 ]
358
364
+ ".json"
359
365
)
@@ -378,7 +384,7 @@ def analyse_category_flows():
378
384
379
385
save_dict_to_json (
380
386
output_data ,
381
- f"{ ANALYSIS_RESULTS_PATH } summary_execution/flow -analysis.json" ,
387
+ f"{ ANALYSIS_RESULTS_PATH } summary_execution_flow -analysis.json" ,
382
388
)
383
389
384
390
@@ -548,7 +554,7 @@ def generate_checkmarks_table(input_dataset: str, selected_cves):
548
554
file = INPUT_DATA_PATH + input_dataset + ".csv"
549
555
dataset = load_dataset (file )
550
556
551
- if len (selected_cves ) != 0 :
557
+ if selected_cves != "all" and len (selected_cves ) != 0 :
552
558
dataset = [c for c in dataset if c [0 ] in selected_cves ]
553
559
554
560
for record in tqdm (dataset , total = len (dataset ), desc = "Analysing Records" ):
@@ -627,7 +633,7 @@ def generate_checkmarks_table(input_dataset: str, selected_cves):
627
633
628
634
# Write the content to the output file
629
635
with open (
630
- ANALYSIS_RESULTS_PATH + "summary_execution/checkmarks_table .tex" , "w"
636
+ ANALYSIS_RESULTS_PATH + "summary_execution_checkmarks_table .tex" , "w"
631
637
) as file :
632
638
file .writelines (latex_content )
633
639
@@ -639,13 +645,13 @@ def _calculate_total_relevance(commit):
639
645
def generate_sankey_diagram (file1 : str , file2 : str , file3 : str ):
640
646
# Load JSON data
641
647
summary_execution_file_1 = (
642
- ANALYSIS_RESULTS_PATH + "summary_execution/ " + file1 + ".json"
648
+ ANALYSIS_RESULTS_PATH + "summary_execution_ " + file1 + ".json"
643
649
)
644
650
summary_execution_file_2 = (
645
- ANALYSIS_RESULTS_PATH + "summary_execution/ " + file2 + ".json"
651
+ ANALYSIS_RESULTS_PATH + "summary_execution_ " + file2 + ".json"
646
652
)
647
653
summary_execution_file_3 = (
648
- ANALYSIS_RESULTS_PATH + "summary_execution/ " + file3 + ".json"
654
+ ANALYSIS_RESULTS_PATH + "summary_execution_ " + file3 + ".json"
649
655
)
650
656
651
657
summary1 = load_json_file (summary_execution_file_1 )
@@ -780,7 +786,7 @@ def generate_sankey_diagram(file1: str, file2: str, file3: str):
780
786
)
781
787
782
788
output_file = (
783
- ANALYSIS_RESULTS_PATH + "plots/" + f"sankey-{ file1 } -{ file2 } -{ file3 } .png"
789
+ ANALYSIS_RESULTS_PATH + f"sankey-{ file1 } -{ file2 } -{ file3 } .png"
784
790
)
785
791
# Save as PNG
786
792
write_image (fig , output_file )
0 commit comments