mysql/gcpmysql: redact password from connection error - #3753
Merged
Conversation
lazyCredsOpener.OpenMySQLURL formats the raw *url.URL into the returned error with %v when Application Default Credentials fail to load. Since url.URL's default String() includes the userinfo password in plain text, any password supplied in the gcpmysql:// URL ends up in the returned error. Use url.URL.Redacted() instead, matching the same fix in postgres/gcppostgres.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3753 +/- ##
=========================================
Coverage ? 75.32%
=========================================
Files ? 104
Lines ? 14202
Branches ? 0
=========================================
Hits ? 10698
Misses ? 2767
Partials ? 737 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
lazyCredsOpener.OpenMySQLURL formats the raw *url.URL with %v when Application Default Credentials fail to load:
https://github.com/google/go-cloud/blob/master/mysql/gcpmysql/gcpmysql.go#L80
url.URL's default String() method includes the userinfo password in plain text, so any password supplied in the gcpmysql:// URL ends up in the returned error.
This switches the call site to url.URL.Redacted(), which masks the password with "xxxxx" while keeping the rest of the URL for debugging. Same fix as the companion PR for postgres/gcppostgres (#3752). Added a test for the negative-credentials path.
go test ./mysql/... passes.