fix: sanitize credentials from connection string parsing errors#319
Open
fix: sanitize credentials from connection string parsing errors#319
Conversation
Copilot
AI
changed the title
[WIP] Fix connection error to prevent credential leakage
fix: sanitize credentials from connection string parsing errors
Feb 2, 2026
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.
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 |
dlevy-msft-sql
approved these changes
Feb 2, 2026
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
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.
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.