-
Notifications
You must be signed in to change notification settings - Fork 90
fix: sanitize credentials from connection string parsing errors #319
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #319 +/- ##
==========================================
+ Coverage 75.45% 79.00% +3.54%
==========================================
Files 34 34
Lines 6597 6648 +51
==========================================
+ Hits 4978 5252 +274
+ Misses 1333 1109 -224
- Partials 286 287 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request fixes a security issue where malformed connection URLs cause url.Parse to fail with error messages that include the full URL, potentially leaking usernames and passwords into application logs. The fix sanitizes these errors to return a generic message without sensitive information.
Changes:
- Sanitized error handling in
splitConnectionStringURLto prevent credential leakage when URL parsing fails - Added comprehensive test coverage to verify credentials are not exposed in error messages
- Minor whitespace formatting fix for consistency
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| msdsn/conn_str.go | Replaced direct error propagation from url.Parse with a sanitized generic error message; minor whitespace fix |
| msdsn/conn_str_test.go | Added test function TestCredentialNotLeakedInError with two test cases verifying credentials are not present in error messages |
Prevent leaking usernames and passwords in error messages when URL parsing fails. The original url.Parse error could include the full connection string with credentials. - Replace url.Parse error with generic message - Add tests using testify to verify credentials are not leaked
c86e503 to
236e400
Compare
When
url.Parsefails on malformed connection URLs, Go's standard library includes the full URL (including credentials) in the error message. This error was propagated directly to callers, leaking usernames and passwords into application logs.Changes
splitConnectionStringURLwhen URL parsing failsExample
Before:
After:
The error provides actionable context without exposing sensitive data.
Original prompt
conn.Query*might return error that contains connection credentials #219💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.