Skip to content

Commit 3077d37

Browse files
committed
Update sploitscan.py
Fix for #21
1 parent 9fc5ed6 commit 3077d37

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

sploitscan/sploitscan.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ def template(data):
184184
metrics = cve_item.get("metrics", [])
185185
baseScore, baseSeverity, vectorString = "N/A", "N/A", "N/A"
186186
for metric in metrics:
187-
if "cvssV3_1" in metric:
188-
cvss_data = metric["cvssV3_1"]
187+
cvss_data = metric.get("cvssV3_1") or metric.get("cvssV3")
188+
if cvss_data:
189189
baseScore = cvss_data.get("baseScore", "N/A")
190190
baseSeverity = cvss_data.get("baseSeverity", "N/A")
191191
vectorString = cvss_data.get("vectorString", "N/A")
@@ -505,7 +505,7 @@ def display_ai_risk_assessment(cve_details, cve_data):
505505
print(wrapped_content)
506506
print("|")
507507

508-
print("└────────────────────────────────────────")
508+
print("└────────────────────────────────────────\n")
509509

510510

511511
def import_vulnerability_data(file_path, file_type):
@@ -625,27 +625,35 @@ def template(data):
625625
env = Environment(loader=FileSystemLoader(path))
626626
break
627627
else:
628-
print(
629-
"❌ HTML template 'report_template.html' not found in any checked locations."
630-
)
628+
print("❌ HTML template 'report_template.html' not found in any checked locations.")
631629
return ["❌ Error exporting to HTML: template not found"]
632630

633631
env.filters["datetimeformat"] = datetimeformat
634632
template = env.get_template("report_template.html")
635633
filename = generate_filename(cve_ids, "html")
636-
output = template.render(cve_data=data)
634+
output = template.render(cve_data=handle_cvss(data))
637635

638636
with open(filename, "w", encoding="utf-8") as file:
639637
file.write(output)
640638

641639
return [f"└ Data exported to file: {filename}"]
642640

641+
def handle_cvss(data):
642+
for result in data:
643+
metrics = result.get("CVE Data", {}).get("containers", {}).get("cna", {}).get("metrics", [])
644+
for metric in metrics:
645+
if "cvssV3_1" not in metric and "cvssV3" not in metric:
646+
metric["cvssV3_1"] = {"baseScore": "N/A", "baseSeverity": "N/A", "vectorString": "N/A"}
647+
return data
648+
643649
try:
644650
display_data("📁 HTML Export", all_results, template)
645651
except Exception as e:
646652
print(f"❌ Error exporting to HTML: {e}")
647653

648654

655+
656+
649657
def export_to_json(all_results, cve_ids):
650658
def template(data):
651659
filename = generate_filename(cve_ids, "json")

0 commit comments

Comments
 (0)