Repository navigation
fix(native-build): quote helm deploy values and escape dollar signs for Kubernetes - #274
Draft
vigneshrajsb wants to merge 2 commits into
Draft
vigneshrajsb wants to merge 2 commits into
vigneshrajsb wants to merge 2 commits into
Conversation
…or Kubernetes The native Helm deploy script built its helm command by string concatenation inside double quotes, so env values with shell metacharacters were evaluated by sh. Git clone scripts interpolated branch and revision the same way. Single-quote every helm --set/--set-file value and the other user-derived tokens, log commands with printf instead of echo, and quote clone refs. Kubernetes also expands $(VAR) and collapses $$ in container args and env values, so double every user-controlled $ in build, deploy and clone job manifests. Move shell quoting helpers into a shared module.
…values Config values and the env serializer relied on sh stripping wrapping double quotes and the backslash in \\, \" , \$ and \` inside double quotes. Reproduce those effects without any expansion, escape bare commas in wrapped values for Helm, and add a differential test against the old shell evaluation.
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
Follow-up to the buildkit build-job quoting fix. The native Helm deploy job and the git clone init containers had the same class of bug: user-controlled strings were interpolated into
sh -cscripts, so values with shell metacharacters broke the job or ran as shell code (for example$(cmd)in a service env value was executed, and an unbalanced quote caused a shell syntax error). Kubernetes additionally expands$(VAR)and collapses$$in containerargsand env values, which silently altered values containing$.Changes
--set/--set-filevalue is single-quoted; chart, release, namespace, version, repo and values-file tokens use quote-if-needed; the executed command is logged withprintfinstead of anechoin double quotes.$is doubled for Kubernetes in the build script, kaniko args, container env values, helm deploy script and clone scripts, so the container receives the original text.shellQuotemodule (shellQuote,quoteIfNeeded,escapeK8sDollar);engines.tsstill re-exportsshellQuote.Behavior changes
--setvalues keep the two effects the old double-quoted shell evaluation had and configs rely on: a value wrapped in double quotes loses them (k="x",k="", and the quotes the env serializer adds), and\\,\",\$, ``` lose their backslash. No expansion happens.\,so Helm accepts them (Helm rejectsa=b,cwithkey "c" has no value).$$or$(NAME)are now passed literally instead of being expanded by Kubernetes.Not changed
Raw
args/defaultArgshelm flags and webhook command scripts remain intentional shell text.escapeHelmValuestill does not escape a literal backslash (Helm-layer behavior).Validation
pnpm test:coverage(Node 22),pnpm lint,pnpm buildpass.helm/gitin a realsh, after simulating Kubernetes$$/$(VAR)expansion, and assert each hostile value arrives as one literal argument with nothing executed. Reverting the quoting or the$escaping makes them fail.