Skip to content

Commit

Permalink
Fix ZeroDivisionError when using fraction_actively_exploited_CVEs (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
jc0b committed Aug 8, 2024
1 parent c0930cf commit c79b45e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions nudge-auto-updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c79b45e

Please sign in to comment.