Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nvd-cve-osv): check for nil when logging VendorProduct #2706

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions vulnfeeds/cmd/nvd-cve-osv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,12 @@ func ReposFromReferences(CVE string, cache VendorProductToRepoMap, vp *VendorPro
repos = append(repos, repo)
maybeUpdateVPRepoCache(cache, vp, repo)
}
Logger.Infof("[%s]: Derived %q for %q %q using references", CVE, repos, vp.Vendor, vp.Product)
if vp != nil {
Logger.Infof("[%s]: Derived %q for %q %q using references", CVE, repos, vp.Vendor, vp.Product)
} else {
Logger.Infof("[%s]: Derived %q (no CPEs) using references", CVE, repos)
}

return repos
}

Expand Down Expand Up @@ -431,7 +436,7 @@ func loadCPEDictionary(ProductToRepo *VendorProductToRepoMap, f string) error {

// Adds the repo to the cache for the Vendor/Product combination if not already present.
func maybeUpdateVPRepoCache(cache VendorProductToRepoMap, vp *VendorProduct, repo string) {
if cache == nil {
if cache == nil || vp == nil {
return
}
if slices.Contains(cache[*vp], repo) {
Expand All @@ -445,7 +450,7 @@ func maybeUpdateVPRepoCache(cache VendorProductToRepoMap, vp *VendorProduct, rep

// Removes the repo from the cache for the Vendor/Product combination if already present.
func maybeRemoveFromVPRepoCache(cache VendorProductToRepoMap, vp *VendorProduct, repo string) {
if cache == nil {
if cache == nil || vp == nil {
return
}
cacheEntry, ok := cache[*vp]
Expand Down
2 changes: 1 addition & 1 deletion vulnfeeds/cmd/nvd-cve-osv/run_cve_to_osv_generation.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash -e

# Copyright 2023 Google LLC
#
Expand Down
Loading