Skip to content

Commit

Permalink
Fix sbom scanning code (#360)
Browse files Browse the repository at this point in the history
Bug in sbom scanning code to quit immediately after successfully parsing
but not finding any packages, rather than trying all formats.
  • Loading branch information
another-rex authored Apr 26, 2023
1 parent 10f7408 commit c6d02d1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/osvscanner/osvscanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,17 @@ func scanSBOMFile(r reporter.Reporter, query *osv.BatchedQuery, path string, fro
return nil
})
if err == nil {
// Found the right format.
// Found a parsable format.
if count == 0 {
return sbom.InvalidFormatError{
// But no entries found, so maybe not the correct format
errs = append(errs, sbom.InvalidFormatError{
Msg: "no Package URLs found",
Errs: []error{
fmt.Errorf("scanned %s as %s SBOM, but failed to find any package URLs, this is required to scan SBOMs", path, provider.Name()),
},
}
})

continue
}
r.PrintText(fmt.Sprintf("Scanned %s as %s SBOM and found %d packages\n", path, provider.Name(), count))
if ignoredCount > 0 {
Expand Down

0 comments on commit c6d02d1

Please sign in to comment.