Skip to content

Commit b56718c

Browse files
committed
[IMP] adjusted all files and functions to the new registry pattern
1 parent 5642c5f commit b56718c

File tree

6 files changed

+4603
-26
lines changed

6 files changed

+4603
-26
lines changed

prospector/evaluation/analyse.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,16 @@
6060

6161

6262
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+
"""
6470
file = INPUT_DATA_PATH + filename + ".csv"
6571
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+
6873
if selected_cves != "all" and len(selected_cves) != 0:
6974
dataset = [c for c in dataset if c[0] in selected_cves]
7075

@@ -312,7 +317,8 @@ def _save_summary_execution_details(
312317

313318

314319
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."""
316322
file = INPUT_DATA_PATH + data_filepath + ".csv"
317323
dataset = load_dataset(file)
318324

@@ -347,13 +353,13 @@ def analyse_category_flows():
347353
"""
348354
summary_execution_file = (
349355
ANALYSIS_RESULTS_PATH
350-
+ "summary_execution/"
356+
+ "summary_execution_"
351357
+ PROSPECTOR_REPORTS_PATH_HOST.split("/")[-2]
352358
+ ".json"
353359
)
354360
summary_execution_comparison_file = (
355361
ANALYSIS_RESULTS_PATH
356-
+ "summary_execution/"
362+
+ "summary_execution_"
357363
+ COMPARISON_DIRECTORY.split("/")[-2]
358364
+ ".json"
359365
)
@@ -378,7 +384,7 @@ def analyse_category_flows():
378384

379385
save_dict_to_json(
380386
output_data,
381-
f"{ANALYSIS_RESULTS_PATH}summary_execution/flow-analysis.json",
387+
f"{ANALYSIS_RESULTS_PATH}summary_execution_flow-analysis.json",
382388
)
383389

384390

@@ -548,7 +554,7 @@ def generate_checkmarks_table(input_dataset: str, selected_cves):
548554
file = INPUT_DATA_PATH + input_dataset + ".csv"
549555
dataset = load_dataset(file)
550556

551-
if len(selected_cves) != 0:
557+
if selected_cves != "all" and len(selected_cves) != 0:
552558
dataset = [c for c in dataset if c[0] in selected_cves]
553559

554560
for record in tqdm(dataset, total=len(dataset), desc="Analysing Records"):
@@ -627,7 +633,7 @@ def generate_checkmarks_table(input_dataset: str, selected_cves):
627633

628634
# Write the content to the output file
629635
with open(
630-
ANALYSIS_RESULTS_PATH + "summary_execution/checkmarks_table.tex", "w"
636+
ANALYSIS_RESULTS_PATH + "summary_execution_checkmarks_table.tex", "w"
631637
) as file:
632638
file.writelines(latex_content)
633639

@@ -639,13 +645,13 @@ def _calculate_total_relevance(commit):
639645
def generate_sankey_diagram(file1: str, file2: str, file3: str):
640646
# Load JSON data
641647
summary_execution_file_1 = (
642-
ANALYSIS_RESULTS_PATH + "summary_execution/" + file1 + ".json"
648+
ANALYSIS_RESULTS_PATH + "summary_execution_" + file1 + ".json"
643649
)
644650
summary_execution_file_2 = (
645-
ANALYSIS_RESULTS_PATH + "summary_execution/" + file2 + ".json"
651+
ANALYSIS_RESULTS_PATH + "summary_execution_" + file2 + ".json"
646652
)
647653
summary_execution_file_3 = (
648-
ANALYSIS_RESULTS_PATH + "summary_execution/" + file3 + ".json"
654+
ANALYSIS_RESULTS_PATH + "summary_execution_" + file3 + ".json"
649655
)
650656

651657
summary1 = load_json_file(summary_execution_file_1)
@@ -780,7 +786,7 @@ def generate_sankey_diagram(file1: str, file2: str, file3: str):
780786
)
781787

782788
output_file = (
783-
ANALYSIS_RESULTS_PATH + "plots/" + f"sankey-{file1}-{file2}-{file3}.png"
789+
ANALYSIS_RESULTS_PATH + f"sankey-{file1}-{file2}-{file3}.png"
784790
)
785791
# Save as PNG
786792
write_image(fig, output_file)

0 commit comments

Comments
 (0)