Skip to content

Commit

Permalink
Merge pull request #525 from Progress1/cvss_seve
Browse files Browse the repository at this point in the history
Added baseSeverity attribute to "only CVSS number" compatibility mode
  • Loading branch information
Progress1 authored Feb 14, 2025
2 parents 3c27ea7 + 597c41f commit d53645d
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/presenters/presenters/base_presenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,26 @@ def calculate_cvss(self, cvss_vector):
else:
c = CVSS2(cvss_vector)
cvss_dict = c.as_json()
except Exception as error:
except Exception:
try:
cvss_dict = {"baseScore": float(cvss_vector)}
if cvss_vector == "":
cvss_dict = {}
else:
num = float(cvss_vector)
# based on CVSS 3.1
if num >= 9:
desc = "CRITICAL"
elif num >= 7:
desc = "HIGH"
elif num >= 4:
desc = "MEDIUM"
elif num >= 0.1:
desc = "LOW"
else:
desc = "NONE"
cvss_dict = {"baseScore": num, "baseSeverity": desc}
except ValueError:
logger.error(f"Error parsing CVSS - not valid vector or 0≤ number ≤10: {error}")
logger.error(f"CVSS parsing failed: '{cvss_vector}' is not a valid vector or number.")
cvss_dict = {}

return cvss_dict
Expand Down

0 comments on commit d53645d

Please sign in to comment.