-
Notifications
You must be signed in to change notification settings - Fork 1
fix(wfctl): use docker buildx build in hardened mode #425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,7 +99,13 @@ func buildWithDockerfile(ctr config.CIContainerTarget, tag string, dryRun bool, | |
| } | ||
|
|
||
| imageRef := imageRefForContainer(ctr, tag, registries) | ||
| args := []string{"build", "--file", dockerfile, "--tag", imageRef} | ||
| // hardened mode uses buildx for provenance/SBOM attestation support. | ||
| var args []string | ||
| if hardened { | ||
| args = []string{"buildx", "build", "--file", dockerfile, "--tag", imageRef} | ||
| } else { | ||
| args = []string{"build", "--file", dockerfile, "--tag", imageRef} | ||
| } | ||
|
|
||
| // Platforms (BuildKit multi-arch). | ||
| if len(ctr.Platforms) > 0 { | ||
|
|
@@ -157,6 +163,15 @@ func buildWithDockerfile(ctr config.CIContainerTarget, tag string, dryRun bool, | |
| return nil | ||
| } | ||
|
|
||
| if hardened { | ||
| // buildx with the docker-container driver is required for attestation flags. | ||
| // Verify a non-default builder is active; the default "docker" driver rejects --provenance. | ||
| if err := exec.Command("docker", "buildx", "inspect", "--bootstrap").Run(); err != nil { | ||
| return fmt.Errorf("hardened build requires docker buildx: run 'docker buildx create --use' " + | ||
| "or add 'docker/setup-buildx-action@v3' to your CI workflow (%w)", err) | ||
| } | ||
|
Comment on lines
+166
to
+172
|
||
| } | ||
|
|
||
| //nolint:gosec // G204: docker command constructed from validated config fields | ||
| cmd := exec.Command("docker", args...) | ||
| cmd.Stdout = out | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In hardened mode this switches to
docker buildx build, but no output mode is specified. With the recommended docker-container driver,buildx builddoes not load the image into the local Docker image store by default, which will break subsequentwfctl build push/docker pushsteps that expect the tagged image to exist locally. Consider adding an explicit output mode (e.g., load for single-platform builds or push when appropriate) and adjusting tests accordingly.