Repository navigation
ci: fix Docker build context broken by cbomkit-action leftovers - #344
Merged
Merged
Conversation
The cbomkit-action step runs as a root Docker action and unpacks its Go scanner helper into a 0700 scratch directory inside the workspace, e.g. 3d209dd94f134bfabcf39448cfbe63d5/11064971341617993163/sonar-go-to-slang-* docker/build-push-action then sends the whole repository as build context as the unprivileged runner user, cannot read that directory, and fails: ERROR: failed to solve: error from sender: open <dir>: permission denied Add a .dockerignore that whitelists only what Dockerfile.jvm consumes (target/quarkus-app and the BouncyCastle scan jars), so unrelated files in the workspace can never break or bloat the build context, and move the CBOM steps after the image build so that step cannot pollute the context at all. Signed-off-by: Nicklas Körtge <[email protected]>
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
mainhas been red since c13e48a (#313, cbomkit-action 2.1.1 → 2.1.2). Every backend run now fails at Build and push:Root cause
The action tag doesn't pin an image. Both tags'
DockerfileisFROM …/cbomkit-action:edge— a mutable tag — but v2.1.1 pointed atghcr.io/pqca/…(old org, frozen since the org rename) while v2.1.2 points atghcr.io/cbomkit/…:edge(live). The bump therefore swapped a stale 2025 image for today'sedge, which includes the Go integration.Running that image against a scratch workspace reproduces it — it leaves behind:
The Go scanner unpacks its helper binary via
createTempDirectoryrooted at the CWD (/github/workspace) rather thanjava.io.tmpdir. The action is a Docker action runningUSER 0:0, so on the runner that tree is root-owned and0700.docker/build-push-actionsendscontext: .as therunneruser, walks into it, and dies. TheCreate CBOMstep itself still reports success — it just leaves droppings the next step trips over.Fix
There was no
.dockerignore, so the entire tree (.git,frontend/node_modules, these leftovers) was shipped as build context — whileDockerfile.jvmonly readstarget/quarkus-app/**andsrc/main/resources/java/scan/*.jar. This PR whitelists exactly those, and moves the CBOM steps after the image build as defense in depth.Verified locally against this repo with a simulated leftover directory: only the 2 whitelisted paths enter the context; the
0700directory,.gitandfrontend/are never opened.Sizeable build speedup as a side effect.
Follow-ups for
cbomkit/cbomkit-action(not fixed here)java.io.tmpdir, not CWD.:edge— right nowv2.1.2means "whatever edge is today", so the action's behaviour changes under a fixed tag.