Skip to content

Conversation

@jess-lowe
Copy link
Contributor

This should dramatically improve conversion time.

Also changes NVD conversion to write out ConversionMetrics in the same way that the CVE5 conversion does.

Should be merged after #4650

Confirmed writing out PackageInfo still works too.

@google google deleted a comment from gemini-code-assist bot Jan 27, 2026
@jess-lowe jess-lowe requested a review from another-rex January 27, 2026 05:07
var err error
switch *outFormat {
case "OSV":
err = nvd.CVEToOSV(cve, repos, RepoTagsCache, *outDir, metrics)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: RepoTagsCache and VPRepoCache should be passed in via arguments

if err != nil {
return err
}
var RepoTagsCache = &git.RepoTagsCache{}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these should be defined in the main function and passed through arguments.

// The RepoTags() call above will have cached the Tag map already
tagsMap := repoTagsCache[repoURL].Tag
repoTagsCache[repoURL] = RepoTagsMap{Tag: tagsMap, NormalizedTag: normalizedTags}
tagsMap, _ := repoTagsCache.Get(repoURL)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this probably shouldn't be called tagsMap, since it matches tagsMap on line 241, which is a completely different type, making it a bit confusing.

},
}
cache := make(RepoTagsCache)
cache := &RepoTagsCache{}
Copy link
Contributor

Choose a reason for hiding this comment

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

rename to repoTagsCache to keep it consistent.


// Adds the repo to the cache for the Vendor/Product combination if not already present.
func MaybeUpdateVPRepoCache(cache VendorProductToRepoMap, vp *VendorProduct, repo string) {
func MaybeUpdateVPRepoCache(cache *VPRepoCache, vp *VendorProduct, repo string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

These all should be methods on VPRepoCache I think.

Product string
}
type VendorProductToRepoMap map[VendorProduct][]string
type VPRepoCache struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add an init function as well, and use that instead of manually setting M, and make M private.

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.

2 participants