Skip to content

Commit

Permalink
Fix nil pointer exception (#73)
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Jogeleit <[email protected]>
  • Loading branch information
fjogeleit authored Jan 20, 2025
1 parent f11f49d commit d93f254
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions plugins/trivy/pkg/vulnr/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,19 @@ func MapCVE(cve *cveawg.CVE, trivyCVE *types.Vulnerability) *Vulnerability {
}
}

if trivyCVE != nil {
if trivyCVE != nil && trivyCVE.PublishedDate != nil {
vulnr.Details = append(vulnr.Details, Details{Title: "Additional", Items: []Item{
{Title: "Assigner", Value: cve.CveMetadata.AssignerShortName},
{Title: "Published", Value: trivyCVE.PublishedDate.Format(time.RFC3339)},
}})
} else {
vulnr.Details = append(vulnr.Details, Details{Title: "Additional", Items: []Item{
{Title: "Assigner", Value: cve.CveMetadata.AssignerShortName},
{Title: "Published", Value: cve.CveMetadata.DatePublished},
}})
}

if trivyCVE != nil {
if len(trivyCVE.CweIDs) > 0 {
vulnr.Details[0].Items = append(vulnr.Details[0].Items, Item{Title: "CWE IDs", Value: strings.Join(trivyCVE.CweIDs, ", ")})
}
Expand Down Expand Up @@ -124,11 +131,6 @@ func MapCVE(cve *cveawg.CVE, trivyCVE *types.Vulnerability) *Vulnerability {
vulnr.Title = cve.CveMetadata.CveID
vulnr.Description = trivyCVE.Description
} else {
vulnr.Details = append(vulnr.Details, Details{Title: "Additional", Items: []Item{
{Title: "Assigner", Value: cve.CveMetadata.AssignerShortName},
{Title: "Published", Value: cve.CveMetadata.DatePublished},
}})

for _, ref := range cve.Containers.Cna.References {
vulnr.References = append(vulnr.References, ref.URL)
}
Expand Down

0 comments on commit d93f254

Please sign in to comment.