fix(ci): stop interpolating helm-diff output directly into a bash script - #21
Merged
Merged
Conversation
result="${{ steps.diff.outputs.result }}" splices the raw diff text into
the script body before bash ever runs it. Any rendered manifest
containing $(...) syntax - which cert-manager's own stock chart uses
legitimately in container args (--cluster-resource-namespace=$(POD_NAMESPACE))
- gets executed as a real command substitution once it lands in that
double-quoted string, breaking the step (command not found) the moment
such a chart shows up in a diff for the first time. Passing it through
env: instead means the value is set as-is with no re-parsing.
Helm template diffdiff -u --recursive --label base --label head base head
--- base
+++ head
@@ -218,7 +218,7 @@
app.kubernetes.io/managed-by: Helm
type: Opaque
data:
- SECRET_KEY_BASE: bWl0dW16RWZWM1d5ZHdDOEpWR0Q1TUdPbFMwdWE3UG1OOWZPUVppY1lySkRDY2xtcEF1RjNnV2NSb0JPdVNQQzNkV2xCUFBsM242UkdkN3hteDR3dUF3d0do
+ SECRET_KEY_BASE: SU4wWUVZVnJsZHZRTHYxTllSRzBIdlg1SnlUNzRkdjVkOHBXVkREQjZMNm1LeUlpUVFWY1o3U3UyRld3Q0g2bmVGVm5CM0QwQnFuNjIxTFJ2YUtxVW5kZjFo
TOTP_VAULT_KEY: ZHN4dmJuM2p4RGQxNmF6MlFwc1g1QjhPK2xseGpRMlNKRTJpNUJ6eDM4ST0=
DATABASE_URL: cG9zdGdyZXM6Ly9wb3N0Z3Jlczpwb3N0Z3Jlc0BwbGF1c2libGUtYW5hbHl0aWNzLXBvc3RncmVzcWw6NTQzMi9wbGF1c2libGVfZGI=
CLICKHOUSE_DATABASE_URL: aHR0cDovL2NsaWNraG91c2U6cGFzc3dvcmRAcGxhdXNpYmxlLWFuYWx5dGljcy1jbGlja2hvdXNlOjgxMjMvcGxhdXNpYmxlX2V2ZW50c19kYg== |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the CI workflow’s “Format diff comment” step by preventing helm-diff output from being interpolated into the bash script body (avoiding command-substitution/script-injection hazards when the diff contains $(...)-style text).
Changes:
- Pass
steps.diff.outputs.resultinto the step viaenv:(DIFF_RESULT) instead of assigning it inside therun:script. - Update the formatting logic to reference
$DIFF_RESULTfor both the “no changes” check and theprintfthat writes the PR comment body.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Found while debugging why PR #20's helm-diff check failed with
POD_NAMESPACE: command not found.The
Format diff commentstep doesresult="${{ steps.diff.outputs.result }}", which splices the raw diff text directly into the script body before bash runs it. Any rendered manifest containing$(...)syntax gets executed as a real command substitution once it lands in that double-quoted string. cert-manager's own stock chart legitimately uses this syntax in container args (--cluster-resource-namespace=$(POD_NAMESPACE)) - the step broke the moment cert-manager's rendered output first appeared in a diff (PR #20 touches its values.yaml for the first time).Fix: pass the value through
env:instead, so it's set as-is with no re-parsing - the standard mitigation for this class of GitHub Actions script-injection bug.Non-blocking today (the job already has
continue-on-error: trueand there's no branch protection onmain), but worth fixing since it'll keep tripping on any future diff containing this common Kubernetes env-var pattern.