-
Notifications
You must be signed in to change notification settings - Fork 9
fix(build): re-include local bin overrides in the generated .dockerignore #374
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
Open
initializ-mk
wants to merge
2
commits into
main
Choose a base branch
from
fix/dockerignore-local-bins
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Oops, something went wrong.
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.
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.
Defense-in-depth (Low/Medium):
nameis written here unsanitized. It's fully user-controlled (bin_overrides.<name>in forge.yaml, or--local-bin name=…) and nothing validates its charset —parseLocalBinschecks only the path, andValidateForgeConfighas nobin_overridescheck. A newline in a name injects arbitrary.dockerignorelines here (e.g.!../secretsor!.re-including unintended build-context paths); a glob like*re-includes the whole.local-bins/stash you just excluded.This PR adds
.dockerignoreas a third sink alongside the pre-existing ones —copyLocalBins'sfilepath.Join(localBinsDir, name)(a../name traverses outside.local-bins/) and the DockerfileCOPY .local-bins/<name> /usr/local/bin/<name>. For local self-authored builds this is self-inflicted, but for a platform building untrusted BYOforge.yamlit's a real injection vector.Closing it at the source — validate the name against
^[a-zA-Z0-9_.-]{1,64}$inparseLocalBinsandValidateForgeConfig— fixes all three sinks at once. Pre-existing on main, so it needn't block this fix; worth a fast follow-up (abin_overridesname is a binary basename, so the strict pattern costs nothing).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.
Addressed in e793ad1 — took the recommendation and closed it at the source in both entry points:
validate.ValidBinOverrideName(exported from forge-core/validate) enforces^[a-zA-Z0-9_.-]{1,64}$inValidateForgeConfig(package.bin_overrides) andparseLocalBins(--local-bin).One addition beyond the suggested pattern: an explicit pure-dot rejection.
.and..pass the charset class (dots are in it), and..is exactly the traversal case the validation exists to stop — so the helper also requiresstrings.Trim(name, ".") != "".Tests cover both directions at both entry points: traversal (
../x,..), newline injection, glob*, dockerignore!metacharacter, whitespace, over-length; plus accepted realistic names (forge,jq,tool.v2,my-tool_2). Full forge-core + forge-cli suites green, lint clean.