fix(config): use stapel coreutils in pm snapshot command#182
Open
reyreavman wants to merge 4 commits into
Open
fix(config): use stapel coreutils in pm snapshot command#182reyreavman wants to merge 4 commits into
reyreavman wants to merge 4 commits into
Conversation
The packages stage snapshot command resolved build secrets with plain cat and created the provenance dir with plain mkdir, both looked up via PATH. On scratch/distroless base images these tools do not exist, the cat failure was muted by || true, and the PACKAGES_VERSION guard failed even though the secret file was mounted and non-empty. Invoke cat and mkdir via the always-mounted /.werf/stapel/embedded/bin instead, the same way the stage script interpreter is already invoked. Signed-off-by: Radmir Khurum <radmir.khurum@flant.com>
nervgh
requested changes
Jul 17, 2026
|
|
||
| containerFactoryVersionSnapshotCmdTmpl = resolvePmEnvFromSecrets + | ||
| `; : "${PACKAGES_VERSION:?required by werf for pm SBOM provenance}" && mkdir -p %s && printf '%%s\n' "$PACKAGES_VERSION" > %s` | ||
| `; : "${PACKAGES_VERSION:?required by werf for pm SBOM provenance}" && ` + stapelEmbeddedBinDir + `/mkdir -p %s && printf '%%s\n' "$PACKAGES_VERSION" > %s` |
Collaborator
There was a problem hiding this comment.
Let's use pkg/stapel:
delivery-kit/pkg/stapel/stapel.go
Line 153 in bbc4d27
| Expect(cmd).To(ContainSubstring(`/.werf/stapel/embedded/bin/mkdir -p `)) | ||
| Expect(cmd).NotTo(MatchRegexp(`(^|[^/])\bcat /run/secrets/`)) | ||
| }) | ||
|
|
Collaborator
There was a problem hiding this comment.
I think we need e2e-tests with registry.werf.io/werf/scratch + secrets to cover this case
Replace the hardcoded stapel embedded bin dir in the snapshot command with stapel.CatBinPath and stapel.MkdirBinPath so the paths stay in one place alongside the other stapel tool path helpers. Signed-off-by: Radmir Khurum <radmir.khurum@flant.com>
Build an image from registry.werf.io/werf/scratch with pm and CA certs imported from a carrier image and PACKAGES_VERSION/REGISTRY provided only as build secrets. The scratch base has no coreutils and no baked pm env, so the test fails unless the snapshot command resolves secrets via stapel-embedded tools. The containerfactoryversion purl qualifier assertion proves the secret value reached the provenance file. Signed-off-by: Radmir Khurum <radmir.khurum@flant.com>
The os-pm SBOM collector read pm.lock and container-factory-version by running cat inside a throwaway container, which fails for scratch and distroless images that ship no coreutils. Replace RunCommandInImage with ReadFileFromImage: the docker backend creates a container without starting it and streams the file via the copy API, the buildah backend mounts the container root filesystem and reads the file directly. Signed-off-by: Radmir Khurum <radmir.khurum@flant.com>
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.
No description provided.