Skip to content

Commit

Permalink
fix: fixes case when there are no aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
djschleen authored Sep 22, 2024
1 parent c1a5cf7 commit a4a2058
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions providers/osv/osv.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,24 @@ func (Provider) Scan(purls []string, credentials *m.Credentials) ([]m.Package, e
severity = "UNSPECIFIED"
}
vulnerability := m.Vulnerability{
ID: vuln.ID,
ID: func() string {
if vuln.ID == "" {
return "NOT PROVIDED"
}
return vuln.ID
}(),
Title: vuln.Summary,
Description: vuln.Details,
Severity: severity,
Cve: vuln.Aliases[0],
Cve: func() string {
if len(vuln.Aliases) > 0 {
return vuln.Aliases[0]
}
return "NOT PROVIDED"
}(),
CvssScore: func() float64 {
s, ok := vuln.DatabaseSpecific["cvss_score"].(string)
if !ok {
if ok {
score, _ := strconv.ParseFloat(s, 64)
return score
}
Expand All @@ -86,9 +96,6 @@ func (Provider) Scan(purls []string, credentials *m.Credentials) ([]m.Package, e
}
vulnerability.ID = strings.Join(cweIDs, ",")
}
if vulnerability.ID == "" {
vulnerability.ID = "NOT PROVIDED"
}
pkg.Vulnerabilities = append(pkg.Vulnerabilities, vulnerability)
}
packages = append(packages, pkg)
Expand Down

0 comments on commit a4a2058

Please sign in to comment.