Skip to content

Commit

Permalink
fix: catch exception parsing CVSS scores on frontend (google#2726)
Browse files Browse the repository at this point in the history
The CVSS calculators throw exceptions when parsing fails, which were
uncaught and causing 500's on our website.
  • Loading branch information
michaelkedar authored Oct 9, 2024
1 parent fe8987d commit e2312da
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions gcp/appengine/frontend_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,14 @@ def calculate_severity_details(
if not (type_ and score):
return None, None

c = cvss_calculator[type_](score)
severity_rating = c.severities()[0]
try:
c = cvss_calculator[type_](score)
severity_rating = c.severities()[0]
except Exception as e:
logging.error('Exception raised when parsing "%s" severity "%s": %s', type_,
score, e)
return None, None

severity_score = c.base_score
return severity_score, severity_rating

Expand Down

0 comments on commit e2312da

Please sign in to comment.