Skip to content

Commit 326925d

Browse files
leodidoona-agent
andcommitted
Fix SBOM generation for Docker packages without OCI export
When exportToCache is false, Docker images are built and loaded into the Docker daemon with their content hash as the tag. SBOM generation was failing because syft couldn't find these images - it was trying all providers (registry, podman, containerd, etc.) instead of looking in the local Docker daemon. The fix explicitly configures syft to use the 'docker' source provider, similar to how the OCI export path uses 'oci-archive'. This tells syft to look for the image in the local Docker daemon. Tested with integration test that covers both paths: - exportToCache=false (Docker daemon) - now works - exportToCache=true (OCI layout) - still works Co-authored-by: Ona <[email protected]>
1 parent 9a7c4df commit 326925d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/leeway/sbom.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,10 @@ func writeSBOM(buildctx *buildContext, p *Package, builddir string) (err error)
266266
return xerrors.Errorf("failed to get package version: %w", err)
267267
}
268268

269-
src, err = syft.GetSource(context.Background(), version, nil)
269+
// Use explicit source provider configuration to ensure docker daemon is used
270+
// The version is a content hash that exists as a tag in the local Docker daemon
271+
srcCfg := syft.DefaultGetSourceConfig().WithSources("docker")
272+
src, err = syft.GetSource(context.Background(), version, srcCfg)
270273
if err != nil {
271274
return xerrors.Errorf("failed to get Docker image source for SBOM generation: %w", err)
272275
}

0 commit comments

Comments
 (0)