[8.18](backport #45857) [metricbeat] [sql] sanitizeError: replace sensitive info even if it is escaped, add pattern-based sanitization#46185
Merged
mykola-elastic merged 3 commits into8.18from Aug 22, 2025
Conversation
Contributor
Author
|
Cherry-pick of bf63860 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
4 tasks
mykola-elastic
approved these changes
Aug 22, 2025
Contributor
mykola-elastic
left a comment
There was a problem hiding this comment.
Manual testing - PASS
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.
Suggested fix for the connection string leak described in the issue: #45852
After this change not only
sensitivestring will be replaced in the error message, but the escaped and url-encoded representations of it will be replaced. (Escaped as infmt.Sprintf("%q", sensitive)). Additionally, this PR also improvessanitizeErrorby adding pattern-based sanitization.What triggered the original issue:
net/urllibrary (in case of the issue, invoked by mssql driver) has its own error type which uses%qwhen printing URLs:Additional refactoring:
SanitizeErrorto the"github.com/elastic/beats/v7/metricbeat/helper/sql"package as it is a generic helper function, which is also related targeted at errors returned by sql driver libssqlSanitizedErrorso thaterrors.Is()anderrors.As()still work with the errors returned bySanitizeError//nolint:errcheckcomments in"github.com/elastic/beats/v7/metricbeat/helper/sql"package, as changes there triggered more CI checksProposed commit message
See title.
Checklist
I have made corresponding changes to the documentationI have made corresponding change to the default configuration filesCHANGELOG.next.asciidocorCHANGELOG-developer.next.asciidoc.How to test this PR locally
sqlwith driver set todriver: mssqlhoststo some invalid string with symbols (",\, etc.)(redacted)in the place of itRelated issues
This is an automatic backport of pull request #45857 done by [Mergify](https://mergify.com).