Skip to content

fix: Correct parsing of Provider Urgency from CVSSv4 vector strings#101

Merged
jeremylong merged 2 commits intojeremylong:mainfrom
chadlwilson:fix-provider-urgency-type-vector-parsing
Mar 22, 2026
Merged

fix: Correct parsing of Provider Urgency from CVSSv4 vector strings#101
jeremylong merged 2 commits intojeremylong:mainfrom
chadlwilson:fix-provider-urgency-type-vector-parsing

Conversation

@chadlwilson
Copy link
Copy Markdown
Contributor

@chadlwilson chadlwilson commented Mar 19, 2026

As noted more fully at #100 (comment) the spec does not denote Provider Urgency shorthand representations for vector strings for anything except X -> NOT_DEFINED; and instead has title case values [X,Clear,Green,Amber,Red].

Since we do case-insensitive matches to the single char variants right now (which is not strictly in spec) and these methods seem intended to be helpful rather than strict, it seems OK and simplest to do a case-insensitive compare rather than normalizing to title case for comparison.

Copilot AI review requested due to automatic review settings March 19, 2026 15:52
@chadlwilson chadlwilson changed the title fix: Correct parsing of Provider urgency from CVSSv4 vector strings fix: Correct parsing of Provider Urgency from CVSSv4 vector strings Mar 19, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes CVSS v4 Provider Urgency parsing to correctly handle the spec’s vector-string tokens (e.g., Clear, Green, Amber, Red) while preserving X/x -> NOT_DEFINED handling, preventing IllegalArgumentException when encountering title-case inputs.

Changes:

  • Update ProviderUrgencyType.fromValue to map X/x to NOT_DEFINED directly.
  • Make Provider Urgency parsing lenient for vector strings by doing a case-insensitive lookup (via uppercasing) for Clear/Green/Amber/Red.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@marcelstoer
Copy link
Copy Markdown
Contributor

LGTM but I realized there are no unit tests for CvssV4Data.java. Maybe a good moment to start with one?

@chadlwilson
Copy link
Copy Markdown
Contributor Author

Yeah, there's very few tests for anything in the marshalling. I mean, I can, but testing 1 out of hundreds of fields isnt much of a start.

@marcelstoer
Copy link
Copy Markdown
Contributor

We gotta start somewhere 🤓 If I were asked to do that, I'd ask Claude for help as it's mostly mechanical and data-driven (→ parameterized tests). If you like, I could attach a proposal here.

@chadlwilson
Copy link
Copy Markdown
Contributor Author

chadlwilson commented Mar 22, 2026

Yeah, I was just being lazy when I discovered there were no existing tests since I tested directly with ODC's tests locally. Fair call out though.

I have a separate follow-up PR to consolidate the duplicated logic here that made the testing easier, but I'll pull something in here.

@chadlwilson chadlwilson force-pushed the fix-provider-urgency-type-vector-parsing branch from 6af6209 to f4ceccd Compare March 22, 2026 05:25
The spec does not denote shorthand representations for anything except X/NOT_DEFINED; and instead has title case values `[X,Clear,Green,Amber,Red]`.

Since we do case-insensitive matches to the single char variants right now (which is not strictly as in spec) and these methods seem intended to be helpful rather than strict, it seems OK and simplest to do a case-insensitive compare rather than normalizing to title case for comparison.
@chadlwilson chadlwilson force-pushed the fix-provider-urgency-type-vector-parsing branch from f4ceccd to 54ccb9d Compare March 22, 2026 05:30
@chadlwilson chadlwilson requested a review from Copilot March 22, 2026 05:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes parsing of the CVSSv4 Provider Urgency metric when vector strings provide title-cased values like Amber, aligning with the spec and addressing the downstream error reported in #100 / dependency-check#8376.

Changes:

  • Update ProviderUrgencyType.fromValue to accept case-insensitive (vector) inputs like Amber/amber while still mapping X/x to NOT_DEFINED.
  • Add parameterized test coverage for CVSS v2/v3/v4 enum fromValue mappings, including vector-string parsing and “not defined” handling.
  • Add shared enum test utilities to reduce duplication across CVSS test suites.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/main/java/io/github/jeremylong/openvulnerability/client/nvd/CvssV4Data.java Makes Provider Urgency parsing tolerant of title-cased / mixed-cased vector-string inputs.
src/test/java/io/github/jeremylong/openvulnerability/client/nvd/CvssV4DataTest.java Adds CVSSv4 enum mapping tests, including case-insensitive vector parsing coverage.
src/test/java/io/github/jeremylong/openvulnerability/client/nvd/CvssV3DataTest.java Adds CVSSv3 enum mapping tests for canonical, vector, not-defined, and invalid values.
src/test/java/io/github/jeremylong/openvulnerability/client/nvd/CvssV2DataTest.java Adds CVSSv2 enum mapping tests for canonical, vector, not-defined, and invalid values.
src/test/java/io/github/jeremylong/openvulnerability/client/nvd/CvssEnumTestSupport.java Introduces shared helper methods for enum mapping assertions across CVSS tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chadlwilson chadlwilson force-pushed the fix-provider-urgency-type-vector-parsing branch from 54ccb9d to 7818291 Compare March 22, 2026 07:09
Copy link
Copy Markdown
Contributor

@marcelstoer marcelstoer left a comment

Choose a reason for hiding this comment

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

LGTM

@chadlwilson chadlwilson force-pushed the fix-provider-urgency-type-vector-parsing branch from 7818291 to eee55f2 Compare March 22, 2026 08:46
Copy link
Copy Markdown
Owner

@jeremylong jeremylong left a comment

Choose a reason for hiding this comment

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

LGTM

@jeremylong jeremylong merged commit 1814567 into jeremylong:main Mar 22, 2026
1 check passed
@chadlwilson chadlwilson deleted the fix-provider-urgency-type-vector-parsing branch March 22, 2026 16:57
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.

fromValue methods in CvssV4Data are not case-insensitive

4 participants