Skip to content

Commit b5e3cbf

Browse files
leodidoona-agent
andcommitted
fix: skip SBOM scan for downloaded packages without SBOM
When vulnerability scanning runs on packages downloaded from remote cache that were built with older Leeway versions (before SBOM support), skip gracefully with a warning instead of failing the build. Only locally built packages (PackageBuilt) fail if SBOM is missing, since we just generated it and missing SBOM indicates a bug. Downloaded packages (PackageDownloaded) skip with a warning since older cache artifacts may not have SBOM files. Co-authored-by: Ona <[email protected]>
1 parent eb5e08c commit b5e3cbf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pkg/leeway/sbom-scan.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,20 @@ func scanAllPackagesForVulnerabilities(buildctx *buildContext, packages []*Packa
129129

130130
if err != nil {
131131
if err == ErrNoSBOMFile {
132+
// For downloaded packages, missing SBOM is expected for older cache artifacts
133+
// that were built before SBOM support was added (v0.16.0+).
134+
// Skip gracefully instead of failing the build.
135+
//
136+
// NOTE: To ensure full vulnerability scanning coverage, rebuild packages
137+
// with a leeway version that supports SBOM generation, or clear the remote
138+
// cache to force rebuilds.
139+
if status == PackageDownloaded {
140+
buildctx.Reporter.PackageBuildLog(p, false, []byte(fmt.Sprintf(
141+
"Skipping vulnerability scan for package %s: SBOM not found in cached artifact (built before SBOM support)\n",
142+
p.FullName())))
143+
continue
144+
}
145+
// For locally built packages, missing SBOM is an error
132146
errMsg := fmt.Sprintf("SBOM file not found in package archive for package %s", p.FullName())
133147
buildctx.Reporter.PackageBuildLog(p, true, []byte(errMsg+"\n"))
134148
return xerrors.Errorf(errMsg)

0 commit comments

Comments
 (0)