Skip to content

Commit

Permalink
fix(sbom): add check for CreationInfo to nil when detecting SPDX cr…
Browse files Browse the repository at this point in the history
…eated using Trivy (#6346)
  • Loading branch information
DmitriyLewen committed Mar 24, 2024
1 parent 1870f28 commit e866bd5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/sbom/spdx/unmarshal.go
Expand Up @@ -255,6 +255,10 @@ func (s *SPDX) parseExternalReferences(refs []*spdx.PackageExternalReference) (*
}

func (s *SPDX) isTrivySBOM(spdxDocument *spdx.Document) bool {
if spdxDocument == nil || spdxDocument.CreationInfo == nil || spdxDocument.CreationInfo.Creators == nil {
return false
}

for _, c := range spdxDocument.CreationInfo.Creators {
if c.CreatorType == "Tool" && strings.HasPrefix(c.Creator, "trivy") {
return true
Expand Down

0 comments on commit e866bd5

Please sign in to comment.