From 39866cdaf162700b77ab3ae9b9fcb7b9cd6eb3b6 Mon Sep 17 00:00:00 2001 From: sudesh0sudesh Date: Wed, 10 Apr 2024 12:48:55 +0100 Subject: [PATCH] testing modification of CPE --- opencve/commands/imports/cve.py | 6 ++++-- opencve/utils.py | 15 ++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/opencve/commands/imports/cve.py b/opencve/commands/imports/cve.py index ad24ccf..ad34075 100644 --- a/opencve/commands/imports/cve.py +++ b/opencve/commands/imports/cve.py @@ -97,8 +97,10 @@ def run(): ] summary = descriptions[0]["value"] cpe_info=cve_data.get("configurations", {}) - info(cpe_info) + #info(cpe_info) if len(cpe_info) == 0: + info(cpe_info) + info(summary) try: prompt= f"CVE SUMMARY:{summary}" @@ -129,7 +131,7 @@ def run(): ]}] cpe_info=cve_data.get("configurations", {}) - info(cpe_info) + except Exception as e: cpe=None diff --git a/opencve/utils.py b/opencve/utils.py index a5be749..6c94fdb 100644 --- a/opencve/utils.py +++ b/opencve/utils.py @@ -17,17 +17,22 @@ def convert_cpes(conf): if not uris: uris = nested_lookup("cpe23Uri", conf) - info(uris) + # Create a list of tuple (vendor, product) cpes_t = list(set([tuple(uri.split(":")[3:5]) for uri in uris])) # Transform it into nested dictionnary cpes = {} - for vendor, product in cpes_t: - if vendor not in cpes: - cpes[vendor] = [] - cpes[vendor].append(product) + try: + for vendor, product in cpes_t: + if vendor not in cpes: + cpes[vendor] = [] + cpes[vendor].append(product) + except Exception as e: + + cpes = {} + return cpes