From f09741582c0bdcf386f06a498d88f8fc94be9e50 Mon Sep 17 00:00:00 2001 From: jc0b Date: Fri, 8 Nov 2024 13:36:57 +0100 Subject: [PATCH] Fixed a bug where an empty CVE dataset could be returned --- nudge-auto-updater.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nudge-auto-updater.py b/nudge-auto-updater.py index a256dd0..9166652 100755 --- a/nudge-auto-updater.py +++ b/nudge-auto-updater.py @@ -305,7 +305,9 @@ def get_CVE_scores(s:str, b:bool, api_key): except Exception as e: logging.error(f"Unable to load CVE data for {s}.") sys.exit(1) - if "cvssMetricV31" in result["data"][0]["metrics"]: + if result["_meta"]["total_documents"] < 1: + return None + elif "cvssMetricV31" in result["data"][0]["metrics"]: return read_CVE_scores(result["data"][0]["metrics"]["cvssMetricV31"][0], b) else: return None