[SqlClient] Sanitize login/user names#3663
Conversation
Sanitize `LOGIN` and `USER` values in SQL queries. Resolves open-telemetry#3661.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3663 +/- ##
==========================================
- Coverage 71.54% 71.52% -0.03%
==========================================
Files 455 455
Lines 17617 17631 +14
==========================================
+ Hits 12604 12610 +6
- Misses 5013 5021 +8 Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Add changes to CHANGELOGs.
There was a problem hiding this comment.
Pull request overview
This PR implements sanitization of LOGIN and USER names in SQL queries to prevent sensitive information from appearing in telemetry. The implementation adds a new Login keyword, introduces a sanitization mechanism, and updates both the query text (replaces names with ?) and query summaries (excludes names entirely) for CREATE, ALTER, and DROP operations involving LOGIN or USER keywords.
Key Changes
- Added
Loginkeyword support with associated initialization and configuration in the SQL keyword system - Implemented
SanitizeNextTokenmethod andSanitizeNextNonKeywordTokenstate flag to replace LOGIN/USER names with placeholders - Updated
CaptureNextTokenInSummaryto exclude LOGIN/USER names from query summaries
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Shared/SqlProcessor.cs | Core implementation: adds Login keyword, sanitization logic, and summary exclusion for LOGIN/USER names |
| test/OpenTelemetry.Contrib.Shared.Tests/SqlProcessorAdditionalTestCases.json | Test cases covering CREATE/ALTER/DROP operations for both USER and LOGIN keywords |
| src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md | Documents the sanitization feature for SQL Client instrumentation |
| src/OpenTelemetry.Instrumentation.EntityFrameworkCore/CHANGELOG.md | Documents the sanitization feature for EF Core instrumentation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b8afc38
Fixes #3661
Changes
Sanitize
LOGINandUSERvalues in SQL queries.Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial changesChanges in public API reviewed (if applicable)