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 the password display problem when passing the chart link #1281

Merged
merged 6 commits into from
Jan 24, 2024

Conversation

NavesEdu
Copy link
Contributor

I had a problem passing a chart's credentials through a helmfile.yaml.
When I ran the following commands:

$ go build
$ ./helmfile sync <name>

I could see in the output table, the credentials passed within the helmfile.yaml. So, I did a treatment under the DisplayAffectedReleases function to make sure the credentials woudn't be exposed.

@yxxhero
Copy link
Member

yxxhero commented Jan 11, 2024

@NavesEdu please move the logic into a single func and add some unit tests. Thanks So much.

@NavesEdu
Copy link
Contributor Author

@yxxhero I made the changes that you asked me!

@@ -3192,6 +3192,15 @@ func renderValsSecrets(e vals.Evaluator, input ...string) ([]string, error) {
return output, nil
}

func hideChartCredentials(chartCredentials string) string {
httpIndex := strings.Index(chartCredentials, "http")
Copy link
Member

Choose a reason for hiding this comment

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

why did only have http? thanks. @NavesEdu

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only the charts that were passed the links through the helmfile presented this credentials exposure problem. So I throught it would be better to hide everything from "http" to "@".

Copy link
Member

Choose a reason for hiding this comment

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

The result looks a bit strange. http://*@example.com or https://@example will be better. @NavesEdu

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed @yxxhero, thank you!

Copy link
Member

Choose a reason for hiding this comment

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

The result looks a bit strange. sorry for the error display.

http://***@example.com or https://***@example will be better. 

@NavesEdu

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left the output at the default you asked for above, is there still anything I need to change @yxxhero?

Copy link
Member

Choose a reason for hiding this comment

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

No more. Please add more test cases. @NavesEdu

input string
expected string
}{
{"http://example.com@user", "http*****@user"},
Copy link
Member

Choose a reason for hiding this comment

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

Normal url style should like this: http://username:password@example.com/. right? thanks so much. @NavesEdu

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I already change this in the test.

@NavesEdu NavesEdu force-pushed the fix_chart_display branch 3 times, most recently from 5b2ae8e to f3422ec Compare January 15, 2024 13:58
expected string
}{
{"http://username:password@example.com/", "http@example.com/"},
{"http://example.com@", "http@"},
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! Also made a improvement to the function I created, thanks @yxxhero!

chart link

Signed-off-by: Eduardo Naves <eduardonaves41@gmail.com>
{"https://username::password@example.com/", "http@example.com/"},
{"https://username:httpd@example.com/", "http@example.com/"},
{"https://username:httpsd@example.com/", "http@example.com/"},
}
Copy link
Member

Choose a reason for hiding this comment

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

expected result:

http://***@example.com or https://***@example.com

thanks so much. @NavesEdu

@@ -3192,6 +3192,15 @@ func renderValsSecrets(e vals.Evaluator, input ...string) ([]string, error) {
return output, nil
}

func hideChartCredentials(chartCredentials string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

url.Parse is better?
doc: https://gobyexample.com/url-parsing

Copy link
Member

Choose a reason for hiding this comment

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

@NavesEdu I think so.

@yxxhero
Copy link
Member

yxxhero commented Jan 19, 2024

@NavesEdu any updates? I wish this can be contained in v0.161.0. I will release v0.161.0 in ths weekend.

NavesEdu and others added 2 commits January 23, 2024 15:47
chart link

Signed-off-by: Eduardo Naves <eduardonaves41@gmail.com>
@NavesEdu
Copy link
Contributor Author

@NavesEdu any updates? I wish this can be contained in v0.161.0. I will release v0.161.0 in ths weekend.

Sorry for the delay, I had some problems making changes to the function and the test but everything is ok now @yxxhero, thank you!

pkg/state/state.go Outdated Show resolved Hide resolved
yxxhero and others added 2 commits January 24, 2024 07:12
Signed-off-by: yxxhero <aiopsclub@163.com>
@yxxhero
Copy link
Member

yxxhero commented Jan 24, 2024

@NavesEdu WDYT of the new code?

@yxxhero yxxhero merged commit 430677d into helmfile:main Jan 24, 2024
14 checks passed
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.

None yet

3 participants