Repository navigation
Mask URL passwords in the SQL query log, fix #1630 - #1631
Merged
Slach merged 2 commits intoOct 21, 2026
Merged
Conversation
With api.create_integration_tables and api.password set, every server start logged the system.backup_* DDL with the API password in the URL() engine argument. LogQuery now masks pass= / password= query string values and user:password@ userinfo in the logged message; the query sent to ClickHouse is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
|
could you ask your LLM how your fix affect performance? |
LogQuery built and masked the message even when the event level was disabled (log_sql_queries: false without debug logging), which became measurably more expensive once the URL credential regexps were added. Return early when the event is disabled, and run the regexps only when the message contains "://", since both masked forms are URL parts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Coverage Report for CI Build 39458900994Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Coverage decreased (-2.5%) to 67.829%Details
Uncovered Changes
Coverage Regressions828 previously-covered lines in 21 files lost coverage.
Coverage Stats
💛 - Coveralls |
Collaborator
|
@bt-macole thanks for contribution |
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.
Fix #1630
Problem
With
api.create_integration_tables: trueandapi.passwordset,CreateIntegrationTablesbuilds thesystem.backup_actions,system.backup_listandsystem.backup_versionDDL with the API credentials in theURL()engine argument (...?pass=<password>&user=<user>).LogQuerywrites every query as is, atinfolevel with the defaultclickhouse.log_sql_queries: true, so the API password reaches the logs on everyserverstart.Fix
LogQuerypasses the message through a newmaskURLCredentialshelper before logging:pass=/password=query string values become[MASKED](the integration tables usepass=;password=covers userURL()tables whose DDL is logged duringrestore)scheme://user:password@hostbecomes[MASKED]The query returned by
LogQuery, which is the one sent to ClickHouse, is unchanged. The[MASKED]marker matches the onepkg/configalready uses for sensitive env overrides. The existing helpers (maskSensitiveEnvValue,MaskEnvOverrideCommand,restoreCloudRedact) work on env names, command lines and known secret values, none of which fits query text insidepkg/clickhouse.ChangeLog: entry added under v2.8.2 BUG FIXES.
Tests
TestLogQueryMasksURLCredentialsinpkg/clickhouse/log_query_test.gocaptures the zerolog output ofLogQueryand checks the integration-table DDL built the same way asCreateIntegrationTables(url.Values.Encode()), apassword=parameter, userinfo, a query with args, and a query without credentials that must stay unchanged. It also asserts thatLogQueryreturns the original query.LogQuerychange fails 4 of 5 subtests; disabling only the query-parameter regex fails 3; disabling only the userinfo regex fails 1; narrowing the regex topass=fails thepassword=subtest.gofmt -l ./pkg ./cmdprinted nothing,go vet ./...passed,go test ./pkg/... ./cmd/...passed. The docker-based integration tests (test/integration, build tagintegration) were not run locally.🤖 Generated with Claude Code