Skip to content

Commit 42b5a45

Browse files
zpavlinovicFiloSottile
authored andcommitted
report: fixes a nil dereference when accessing vuln cve metadata.
Some vulnerabilities, such as GO-2020-0002.toml, do not have CVE metadata. Accessing CVEMetadata.ID without checking if CVEMetadata is nil can lead to a nil dereference. Change-Id: I06a24a7d80a0e8be768af198a1b6254f15de98d3 Reviewed-on: https://team-review.git.corp.google.com/c/golang/vulndb/+/1026682 Reviewed-by: Roland Shoemaker <bracewell@google.com>
1 parent abe7a41 commit 42b5a45

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

report/report.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func (vuln *Report) Lint() error {
105105
return fmt.Errorf("unknown severity %q", vuln.Severity)
106106
}
107107

108-
if vuln.CVE != "" && vuln.CVEMetadata.ID != "" {
108+
if vuln.CVE != "" && vuln.CVEMetadata != nil && vuln.CVEMetadata.ID != "" {
109109
// TODO: may just want to use one of these? :shrug:
110110
return errors.New("only one of cve and cve_metadata.id should be present")
111111
}

0 commit comments

Comments
 (0)