Skip to content

Raise NotImplementedError in ScoringSystem.get and compute - #2553

Open
sc-lacanlale wants to merge 1 commit into
aboutcode-org:mainfrom
sc-lacanlale:fix/raise-not-implemented-scoring-system
Open

sc-lacanlale wants to merge 1 commit into
aboutcode-org:mainfrom
sc-lacanlale:fix/raise-not-implemented-scoring-system

Conversation

@sc-lacanlale

Copy link
Copy Markdown

Fixes #2552

ScoringSystem.compute(), ScoringSystem.get(), and EPSSScoringSystem.compute() used return NotImplementedError instead of raise NotImplementedError, so callers catching NotImplementedError received the truthy exception class instead of skipping unsupported scoring systems.

Changes:

  • Change return NotImplementedError to raise NotImplementedError in vulnerabilities/severity_systems.py.
  • Add unit tests in vulnerabilities/tests/test_get_serverity.py for unimplemented ScoringSystem, EPSS, and SSVC methods.

Fixes aboutcode-org#2552

Signed-off-by: Shanley Clarence <115960237+sc-lacanlale@users.noreply.github.com>

@Jean-Regis-M Jean-Regis-M left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through every caller of compute() and get() on main, to see whether a real raise could surprise anyone.

  • api.py, models.py and both loops in views.py already catch NotImplementedError. That only makes sense if the methods raise, so this matches what they expected.
  • osv.py, osv_v2.py and compute_advisory_todo.py only call compute() on the CVSS systems. The last one also wraps it in try/except Exception.
  • Migration 0032 calls it only for names ending in _vector.

I found no caller that depended on getting the class back. I read the code and didn't run the new tests.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ScoringSystem.get() and compute() return NotImplementedError instead of raising it

2 participants