Skip to content
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

fix: Make dry-run=server optional #499

Merged
merged 2 commits into from
Jan 9, 2024
Merged

fix: Make dry-run=server optional #499

merged 2 commits into from
Jan 9, 2024

Conversation

mumoshu
Copy link
Collaborator

@mumoshu mumoshu commented Oct 11, 2023

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.

@mumoshu mumoshu mentioned this pull request Oct 11, 2023
cmd/upgrade.go Outdated
@@ -67,6 +69,11 @@ func (d *diffCmd) isAllowUnreleased() bool {
return d.allowUnreleased || d.install
}

func (d *diffCmd) isRemoteAccessAllowed() bool {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding some unit tests will be better.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yxxhero Are you saying we should have a unit test for checking all the combinations of variables involved in L73?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah.

@jBouyoud
Copy link

Any ETA for this PR? and new release ? 🥺 🙏

@gdubicki
Copy link

Related to #449

@yxxhero
Copy link
Collaborator

yxxhero commented Dec 22, 2023

@mumoshu

@cavedon
Copy link

cavedon commented Dec 29, 2023

It looks like the -f flag stopped working with this patch:

 % helm diff upgrade -f secrets.yaml -n map map .        
args after legacy dry-run parsing: [-f secrets.yaml map .]
Error: Failed to get release -f in namespace map: exit status 1: Error: unknown shorthand flag: 'f' in -f

Error: plugin "diff" exited with error

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 introducing a new flag `--dry-run=[|client|server]` to helm-diff.

See the updated README and the updated helm-diff help message for more details.
@mumoshu
Copy link
Collaborator Author

mumoshu commented Jan 4, 2024

@cavedon Thank you very much for testing! I fixed it and added some tests to verify flag parsing is working.

@mumoshu mumoshu merged commit cd57381 into master Jan 9, 2024
10 checks passed
@mumoshu mumoshu deleted the make-dry-run-sever-opt branch January 9, 2024 00:03
@jBouyoud
Copy link

jBouyoud commented Jan 9, 2024

@mumoshu @yxxhero Thanks very much for this PR. Have you now any ETA for a new release ?
There are some incredible new features that I'd like to use (server dry-run, --suppress-output-line-regex option , and beyond) ;-) . I'll also glad to help if I can, let me know

mumoshu added a commit that referenced this pull request Jan 27, 2024
This is a follow-up on #499 which redoes it without relying on DisableParsing. DisableParsing turned out to break far many things than I imagined!
mumoshu added a commit that referenced this pull request Jan 27, 2024
This is a follow-up on #499 which redoes it without relying on DisableParsing. DisableParsing turned out to break far many things than I imagined!
mumoshu added a commit that referenced this pull request Jan 27, 2024
This is a follow-up on #499 which redoes it without relying on DisableParsing. DisableParsing turned out to break far many things than I imagined!
mumoshu added a commit that referenced this pull request Jan 27, 2024
This is a follow-up on #499 which redoes it without relying on DisableParsing. DisableParsing turned out to break far many things than I imagined!
mumoshu added a commit that referenced this pull request Jan 27, 2024
This is a follow-up on #499 which redoes it without relying on DisableParsing. DisableParsing turned out to break far many things than I imagined!
yxxhero added a commit that referenced this pull request Jan 27, 2024
* Remake dry-run=server optional

This is a follow-up on #499 which redoes it without relying on DisableParsing. DisableParsing turned out to break far many things than I imagined!

* Remove redundant test case

* optimze little code

Signed-off-by: yxxhero <[email protected]>

---------

Signed-off-by: yxxhero <[email protected]>
Co-authored-by: yxxhero <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants