Skip to content

feat(nvd): improve ranges to include metadata in db_specific of CPE used to extract it#5103

Merged
jess-lowe merged 42 commits intogoogle:masterfrom
jess-lowe:feat/nvd/rebasing-db
Apr 9, 2026
Merged

feat(nvd): improve ranges to include metadata in db_specific of CPE used to extract it#5103
jess-lowe merged 42 commits intogoogle:masterfrom
jess-lowe:feat/nvd/rebasing-db

Conversation

@jess-lowe
Copy link
Copy Markdown
Contributor

@jess-lowe jess-lowe commented Mar 22, 2026

This PR introduces various updates for handling NVD and CVE databases, specifically related to the location of range metadata in database_specific, and parsing and cache improvements.

Range & Affected Parsing (NVD & CVE5):

  • Fix logic for nested unresolved ranges and duplicate unresolved ranges.
  • Handle edge cases where introduced version equals lessThanOrEqual (meaning it’s a specific version, not a range).
  • Address how unresolved signatures are handled during processing.
  • Extracted and moved MergeRangesAndCreateAffected logic to a common package for reuse.
  • Introduced a new RangeWithMetadata struct to hold unresolved ranges and where they were extracted from, so they can be put in the database_specific.
  • Created a new function for explicitly building Git osvschema ranges, so they always have the type value attached.
  • unresolved ranges are grouped by CPE for easier understanding and use.

CVE5 Interoperability:

  • Changed CVE5 logic to also use RangeWithMetadata to be consistent across records.

References & Links:

  • Implemented caching for canonicalizing links to improve processing performance and avoid 429s.

@jess-lowe jess-lowe requested a review from another-rex March 22, 2026 23:31
@jess-lowe jess-lowe force-pushed the feat/nvd/rebasing-db branch from a808360 to 7d30cdf Compare March 23, 2026 03:48
@jess-lowe jess-lowe requested a review from another-rex March 24, 2026 23:11
another-rex
another-rex previously approved these changes Mar 25, 2026
Copy link
Copy Markdown
Contributor

@another-rex another-rex left a comment

Choose a reason for hiding this comment

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

Nice! There's a lot of logic here, I tried my best.


// Check if the repo URL has changed (e.g. via redirect)
canonicalRepo, err := ValidateAndCanonicalizeLink(repo, httpClient)
canonicalRepo, err := git.FindCanonicalLink(repo, httpClient, repoTagsCache)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here you are passing in repoTagsCache directly (and FindCanonicalLink doesn't check if it's nil or not), but below you are checking whether repoTagsCache is nil. If it cannot be nil here, please remove the nil checks below.

if err != nil {
return "", err
}
cache.SetCanonicalLink(link, canonicalLink)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this be caching errors as well to avoid retrying links that error?

// If the reference is a commit URL, the repo is inherently useful (but only if the repo still ultimately works).
_, err = Commit(ref.URL)
// Check if it was previously found to be bad:
if repoTagsCache != nil && repoTagsCache.IsInvalid(repo) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we want to also call this before the FindCanonicalLink so that we can skip a network request if we know it's bad?

Also, this is checking if repoTagsCache is nil again, when would this happen?

@ksealmalaysia41-lang

This comment was marked as spam.

@jess-lowe jess-lowe merged commit 1de3595 into google:master Apr 9, 2026
21 checks passed
@jess-lowe jess-lowe deleted the feat/nvd/rebasing-db branch April 9, 2026 04:36
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.

3 participants