Repository navigation
fix(cvss): reject a vector that repeats a metric with a conflicting value - #197
Merged
vsn411 merged 1 commit intoNov 26, 2026
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this change, and why?
parse_vector()says it raisesCvssErrorwhen a metric is "duplicated with conflicting values", but it never checked: each segment overwrote the previous one, so the last value won. A SAST finding whose vector came back asAV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H/AV:Pwas stored with a score of 6.8 (physical access) instead of being treated as a malformed vector, and the dashboard's "External" badge (cvss_network_reachable) read the same wrongAV. That is the "wrong, confidently-displayed score" the module'sCvssErrordocstring says it should never produce.Now a metric that appears twice with different values raises
CvssError, naming the metric and both values. A metric repeated with the same value is still accepted. Both callers (runner.pywhen storing SAST findings, andcvss_network_reachableinweb/templating.py) already catchCvssErrorand fall back to "no score" / not external, so no other code changes.How to reproduce on
main:Testing
pytest testspasses: 2262 passed, 10 failed. The same 10 fail onmainin my environment (Rich wrapping CLI tables at a narrow terminal width, mermaid not vendored for the architecture pages, and the Claude capture subprocess test); none touch CVSS.ruff check .passes on the changed files (ruff check src/secfoo/cvss.py tests/test_cvss.py); the repo-wide run reports the same 109 findings onmainas with this change.test_parse_vector_rejects_metric_repeated_with_a_conflicting_valuefails onmain(DID NOT RAISE) and passes here;test_parse_vector_accepts_metric_repeated_with_the_same_valuepins that an identical repeat still parses.