From c79b45e12be08bff28ee6fd25d99df4641a73892 Mon Sep 17 00:00:00 2001 From: jc0b Date: Thu, 8 Aug 2024 10:28:56 +0200 Subject: [PATCH] Fix ZeroDivisionError when using fraction_actively_exploited_CVEs (#10) --- nudge-auto-updater.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/nudge-auto-updater.py b/nudge-auto-updater.py index 33f74c4..4ece6f5 100755 --- a/nudge-auto-updater.py +++ b/nudge-auto-updater.py @@ -558,12 +558,15 @@ def check_cve_numbers(conditions, cves, name, days, conjunction, found=False): else: conj = False if "fraction_actively_exploited_CVEs" in conditions: - if (sum(cves.values()) / len(cves)) >= conditions["fraction_actively_exploited_CVEs"]: - s = f'Fraction of actively exploited CVEs ({(sum(cves.values()) / len(cves))}) is greater than or equal to threshold {conditions["fraction_actively_exploited_CVEs"]}.' - met_cve_conditions.append(s) - disj = True - else: + if len(cves) < 1: conj = False + else: + if (sum(cves.values()) / len(cves)) >= conditions["fraction_actively_exploited_CVEs"]: + s = f'Fraction of actively exploited CVEs ({(sum(cves.values()) / len(cves))}) is greater than or equal to threshold {conditions["fraction_actively_exploited_CVEs"]}.' + met_cve_conditions.append(s) + disj = True + else: + conj = False if conjunction: return conj, met_cve_conditions return disj, met_cve_conditions