Repository navigation
Core SQL test harness: do not write the password to the invocation log - #624
Merged
Merged
Conversation
The log of CLICKHOUSE_CLIENT_CLI_LOG had the command line with the value of --password in clear. CI uploads this log (upstream-run.log) as an artifact when a shard fails. The CI jobs use the passwordless default user, but a run against a server with a password would write the password to the artifact. RedactPassword (args.cpp) gives the command line with each --password value replaced by ***. It reads the options as ParseArgs does, so it finds the value also after an option that takes --password as its own value (-u --password --password X). The other records of the log (address, statements, errors) have no password. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Auto-approved by the AI review gate on 0143e68. Details in the approver's comment on this pull request.
AI review gate — auto-approved
History (latest 5 heads, newest first)
|
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.
Description
The core SQL test harness (
tests/clickhouse-test-runner/, merged in #621) appends a record of each invocation to the file ofCLICKHOUSE_CLIENT_CLI_LOG. The first record is the command line, so the value of--passwordwent into the file in clear. In CI the file isupstream-run.log, and the workflow uploads it as an artifact when a shard fails. GitHub masks secrets only in the console output, not in artifacts.Nothing leaks today: the CI jobs connect as the passwordless
defaultuser of a local container. The leak starts on the first run against a server with a password. ClickHouse Product Security found this in the ODBC harness: ClickHouse/clickhouse-odbc#624 (comment). The C++ shim has the same problem.The change is in the harness only. The library (
clickhouse/) and the CI workflow do not change.Changes
RedactPassword(args.cpp) returns the command line with each password value replaced by***:--password Xgives--password ***,--password=Xgives--password=***. A last--passwordwith no value stays as it is. It reads the options with the option table ofParseArgs, so it also finds the value after an option that takes--passwordas its own value: in-u --password --password X,-utakes the first--password, andXis the password. A setting (--max_threads) never takes an argument that starts with-, so its value needs no rule. UnlikeParseArgs, the function does not stop at--, so a password after--is also hidden.RunMain(shim.cpp) logs the result ofRedactPasswordin place of the raw arguments.address,statements,error) have no password. The live test checks the full log.CLICKHOUSE_CLIENT_CLI_LOGsays that the--passwordvalue is hidden.Tests
RedactPassword.HidesThePasswordOnly(unit):--user u --password secret --password=secret2 --query 'SELECT 1' --passwordgives--user u --password *** --password=*** --query 'SELECT 1' --password. The command lines in which an option takes--passwordas its value (-u,--host), or a setting comes before--password(--max_threads,--max_threads -1), are checked against the password thatParseArgsreads. Contrast: the value of another option stays (-u --password x,--host --password=x).Live.LogHidesPassword(live, shard 1 of CI): two runs, one with--password <value>and one with--password=<value>, against the server, withCLICKHOUSE_CLIENT_CLI_LOGset to a new temporary file. The log must not contain either value, and must contain--password ***and--password=***. The test checks only the log: the server 26.10 refuses a password for the passwordlessdefaultuser (AUTHENTICATION_FAILED), so theerrorrecord (the server's error text) is also in the checked log. The test restores the earlier value ofCLICKHOUSE_CLIENT_CLI_LOG. Without the fix, its four checks fail.-Werror).clang-format --dry-run --Werror(18.1.8) is clean. The real program logs--host localhost -u --password --password *** -q SELECT 1and--password=*** -q SELECT 1.Reference: the same fix in the C# harness (
InvocationLog.RedactPassword, ClickHouse/clickhouse-cs) and in the ODBC harness (ClickHouse/clickhouse-odbc#624, commit036de6e).🤖 Generated with Claude Code
Note
Low Risk
Test-harness logging change only; narrows secret exposure in CI artifacts without altering client connection behavior.
Overview
The SQL test shim (
tests/clickhouse-test-runner) no longer writes cleartext--passwordvalues intoCLICKHOUSE_CLIENT_CLI_LOG, which CI uploads as an artifact when shards fail.A new
RedactPasswordhelper mirrors the harness’s option parsing so both--password secretand--password=secretare logged as***, including edge cases where another flag consumes--passwordas its value.RunMainnow logs the redacted argv string instead of the raw command line, and the README documents the behavior.Coverage adds a unit test for redaction rules and a live test that asserts the log file never contains the password strings.
Reviewed by Cursor Bugbot for commit 0143e68. Bugbot is set up for automated code reviews on this repo. Configure here.