You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This intends to fix a potential security issue introduced via #458 before cutting the next helm-diff release.
Since #458 (unreleased), we had forced helm-diff to use `helm template --dry-run=server` for Helm 3.13 or greater.
I think this can create an unintended security hole, where any users, who can run helm-diff via CI or any automation with an arbitrary chart and values, is able to view cluster resources via helm template's `lookup` functions.
Previously this was impossible because `helm template` run by `helm diff` had no access to the `lookup` function. To fix this, we need to make `--dry-run=server` optional. And we do so by changing helm-diff's `--dry-run` flag to accept only only booleans but also `client` and `server`. The updated flag usage is `--dry-run[=[|true|false|client|server]]`.
See the updated README and the updated helm-diff help message for more details.
// Or what's the relationoship between helm-diff's --dry-run flag,
202
+
// HELM_DIFF_UPGRADE_DRY_RUN env var and the helm upgrade --dry-run flag?
203
+
//
204
+
// Read on to find out.
198
205
ifd.useUpgradeDryRun {
199
-
ifd.dryRun {
200
-
returnnil, fmt.Errorf("`diff upgrade --dry-run` conflicts with HELM_DIFF_USE_UPGRADE_DRY_RUN_AS_TEMPLATE. Either remove --dry-run to enable cluster access, or unset HELM_DIFF_USE_UPGRADE_DRY_RUN_AS_TEMPLATE to make cluster access unnecessary")
201
-
}
202
-
203
206
ifd.isAllowUnreleased() {
204
207
// Otherwise you get the following error when this is a diff for a new install
205
208
// Error: UPGRADE FAILED: "$RELEASE_NAME" has no deployed releases
206
209
flags=append(flags, "--install")
207
210
}
208
211
212
+
// If the program reaches here,
213
+
// we are sure that the user wants to user the `helm upgrade --dry-run` command
214
+
// for generating the manifests to be diffed.
215
+
//
216
+
// So the question is only whether to use `--dry-run=client` or `--dry-run=server`.
217
+
//
218
+
// As HELM_DIFF_UPGRADE_DRY_RUN is there for producing more complete and correct diff results,
219
+
// we use --dry-run=server if the version of helm supports it.
220
+
// Otherwise, we use --dry-run=client, as that's the best we can do.
// Note that we can't just move this block to PersistentPreRunE,
156
+
// because cmd.SetArgs(args) does not persist between PersistentPreRunE and RunE.
157
+
// The choice is between:
158
+
// 1. Doing this in RunE
159
+
// 2. Doing this in PersistentPreRunE, saving args somewhere, and calling cmd.SetArgs(args) again in RunE
160
+
// 2 is more complicated without much benefit, so we choose 1.
161
+
{
162
+
const (
163
+
dryRunUsage="--dry-run, --dry-run=client, or --dry-run=true disables cluster access and show diff as if it was install. Implies --install, --reset-values, and --disable-validation."+
164
+
" --dry-run=server enables the cluster access with helm-get and the lookup template function."
f.BoolVar(&diff.devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.")
196
289
f.BoolVar(&diff.disableValidation, "disable-validation", false, "disables rendered templates validation against the Kubernetes cluster you are currently pointing to. This is the same validation performed on an install")
197
290
f.BoolVar(&diff.disableOpenAPIValidation, "disable-openapi-validation", false, "disables rendered templates validation against the Kubernetes OpenAPI Schema")
198
-
f.BoolVar(&diff.dryRun, "dry-run", false, "disables cluster access and show diff as if it was install. Implies --install, --reset-values, and --disable-validation")
199
291
f.StringVar(&diff.postRenderer, "post-renderer", "", "the path to an executable to be used for post rendering. If it exists in $PATH, the binary will be used, otherwise it will try to look for the executable at the given path")
200
292
f.StringArrayVar(&diff.postRendererArgs, "post-renderer-args", []string{}, "an argument to the post-renderer (can specify multiple)")
201
293
f.BoolVar(&diff.insecureSkipTLSVerify, "insecure-skip-tls-verify", false, "skip tls certificate checks for the chart download")
0 commit comments