feat(sbom): read build secrets in packages env values - #317
Merged
alexey-igrychev merged 1 commit intoSep 11, 2026
Merged
alexey-igrychev merged 1 commit into
alexey-igrychev merged 1 commit into
Conversation
Collaborator
Author
Verification
Review focus
Follow-up
|
Passing a mounted secret to a package manager required shell in the value, which no longer runs. A `packages[].env` value can now reference a declared secret with `%secret:<id>%` for its contents or `%secret_path:<id>%` for its mount path, following the `%image%` family of werf placeholders; any other `%...%` sequence stays literal. References are resolved while the package manager runs, so the secret stays out of the build instructions, the stage digest and the image. An undeclared or malformed secret id fails during configuration parsing. Signed-off-by: Aleksei Igrychev <aleksei.igrychev@palark.com>
alexey-igrychev
force-pushed
the
fix/sbom/packages-env-reaches-pm
branch
from
September 10, 2026 21:45
550011c to
437de24
Compare
alexey-igrychev
force-pushed
the
feat/sbom/packages-env-secret-refs
branch
from
September 10, 2026 21:45
6ec5de1 to
35c5be4
Compare
reyreavman
approved these changes
Sep 11, 2026
alexey-igrychev
marked this pull request as ready for review
September 11, 2026 10:16
alexey-igrychev
merged commit Sep 11, 2026
c06779c
into
fix/sbom/packages-env-reaches-pm
27 of 29 checks passed
alexey-igrychev
added a commit
that referenced
this pull request
Sep 11, 2026
* fix(sbom): make packages env variables reach the package manager For every file-based packages type the install command was generated as `ENV=value cd "/app" && <tool>`, where the assignment prefix applies only to `cd`: the package manager itself ran without the variables, so proxy, index and credential settings declared in `packages[].env` had no effect. Only `os-pm` worked, because there the prefix directly precedes `pm`. The prefix now sits between `cd` and the tool, through a single helper shared by all ecosystems. Signed-off-by: Aleksei Igrychev <aleksei.igrychev@palark.com> * feat(sbom): read build secrets in packages env values (#317) Passing a mounted secret to a package manager required shell in the value, which no longer runs. A `packages[].env` value can now reference a declared secret with `%secret:<id>%` for its contents or `%secret_path:<id>%` for its mount path, following the `%image%` family of werf placeholders; any other `%...%` sequence stays literal. References are resolved while the package manager runs, so the secret stays out of the build instructions, the stage digest and the image. An undeclared or malformed secret id fails during configuration parsing. Signed-off-by: Aleksei Igrychev <aleksei.igrychev@palark.com> --------- Signed-off-by: Aleksei Igrychev <aleksei.igrychev@palark.com>
alexey-igrychev
added a commit
that referenced
this pull request
Sep 11, 2026
* fix(sbom): make packages env variables reach the package manager For every file-based packages type the install command was generated as `ENV=value cd "/app" && <tool>`, where the assignment prefix applies only to `cd`: the package manager itself ran without the variables, so proxy, index and credential settings declared in `packages[].env` had no effect. Only `os-pm` worked, because there the prefix directly precedes `pm`. The prefix now sits between `cd` and the tool, through a single helper shared by all ecosystems. Signed-off-by: Aleksei Igrychev <aleksei.igrychev@palark.com> * feat(sbom): read build secrets in packages env values (#317) Passing a mounted secret to a package manager required shell in the value, which no longer runs. A `packages[].env` value can now reference a declared secret with `%secret:<id>%` for its contents or `%secret_path:<id>%` for its mount path, following the `%image%` family of werf placeholders; any other `%...%` sequence stays literal. References are resolved while the package manager runs, so the secret stays out of the build instructions, the stage digest and the image. An undeclared or malformed secret id fails during configuration parsing. Signed-off-by: Aleksei Igrychev <aleksei.igrychev@palark.com> --------- Signed-off-by: Aleksei Igrychev <aleksei.igrychev@palark.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.
Summary
There is no way to pass a mounted build secret to a package manager:
packages[].envvalues are literal text, and the packages stage is deliberately declarative, so a shell substitution is not an option. A value can now reference a secret declared in thesecretssection, and the reference is resolved while the package manager runs.What
packages[].envvalue that literally contains%secret:<id>%or%secret_path:<id>%is now expanded instead of passed through. Any other%...%sequence —%2F,%H:%M,%image%— stays literal, so no other value changes.%secret:<id>%in apackages[].envvalue expands to the secret's contents, without trailing newlines, and may sit inside a larger value.%secret_path:<id>%expands to/run/secrets/<id>, for tools that take a path (DOCKER_CONFIG,AWS_SHARED_CREDENTIALS_FILE).secretssection fails the build withpackages[0].env["GOPROXY"] references secret "MISSING", which is not declared in thesecretssection, and a malformed id withinvalid secret id "my token"— both during configuration parsing, before any stage runs. VERIFIED: real build, see the comment.packages[].envkey or a build-container variable.werf.yamlis rendered as a Go template, so composing ordinary values is already possible without a runtime mechanism.Why
The declarative
packagessection is the only stapel stage with network access, which is exactly why it must not accept shell. Reading a secret is the one capability that a template cannot provide, because the value does not exist at render time — so it needs a syntax of its own rather than a hole in the escaping.The
%name%form is the placeholder syntax werf already has:%image%,%image_slug%,%image_safe_slug%,%image_content_based_tag%and%project%in--add-custom-tag,--use-custom-tag,werf export --tagandimageSpeclabels. Only the two known prefixes expand and everything else stays literal, exactly as those placeholders behave, so no escape mechanism is needed and existing values keep working.${...}and$(...)forms were rejected: they read as shell in a place where shell does not run, and a value that resembles a mounted path (/run/secrets/<id>treated as a reference) cannot express "pass this path as text", which%secret_path:<id>%does explicitly.