Skip to content

Cherry pick #117429 to 26.9: Mask secrets in SHOW CREATE DATABASE of a Backup database - #121968

Merged
robot-ch-test-poll4 merged 3 commits into
backport/26.9/117429from
cherrypick/26.9/117429
Sep 25, 2026
Merged

robot-ch-test-poll4 merged 3 commits into
backport/26.9/117429from
cherrypick/26.9/117429

Conversation

@robot-ch-test-poll4

Copy link
Copy Markdown
Contributor

Original pull-request #117429

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Before you resolve anything

Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

groeneai and others added 2 commits September 21, 2026 06:17
`SHOW CREATE DATABASE` of a `Backup` database renders the locator as the function
it is since #118674, so the pre-existing nested-`S3` rule redacts it. What is left
are the shapes that rule does not model, and the messages that reject a locator:

- A `Backup` engine with an arity other than two, or with a first argument that is
  no literal, hides every argument: a locator can be written in either position,
  and the statement is formatted for logging before validation rejects it.
- A locator whose engine is not `S3` keeps its engine name and argument count and
  hides every argument, unless the engine reads exactly the literal arguments it
  accepts, which name a destination and no credential (`File`, `Disk`, `Memory`,
  `Null`).
- An `AzureBlobStorage` backup destination reads a different signature than the
  table engine of the same name: a shared access signature beside a two-argument
  url, an `account_key` in the longer forms, named-collection overrides. It gets
  its own rule, and both rules now fail closed on an argument that neither
  `maskAzureConnectionString` nor the plain-account-url check can read, instead of
  leaving it visible.
- `BackupInfo::fromAST`, `checkAndGetLiteralArgument` for `database_name`,
  `StorageS3Configuration::collectCredentials` and the two duplicate-definition
  checks of `BackupMetadataFinder` formatted the argument they reject into their
  messages, which reach the error log and `query_log.exception`. A nested map such
  as `headers(..)` is masked only by its enclosing formatter, so one formatted on
  its own prints its values: none of these echoes the argument now.

Rebased on #118674 and reduced to the above. The definition rendering, the
acceptance of a locator held in a string literal on the metadata-replay paths and
the preflight refusal of one elsewhere are that PR's, and its own tests cover them.
…-secret

Mask secrets in SHOW CREATE DATABASE of a Backup database
@robot-ch-test-poll4 robot-ch-test-poll4 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Sep 24, 2026
@groeneai

Copy link
Copy Markdown
Collaborator

These four conflict on a prerequisite that is missing from every release branch, and the backport cannot be green without it

The conflicts are not a bad cherry-pick. All four branches lack #118674 ("Keep a Backup database loadable after ALTER DATABASE ... MODIFY COMMENT", merged 2026-09-21), which #117429 was rebased on: allow_locator_in_string_literal occurs 4 times in src/Databases/DatabaseBackup.cpp on master and 0 times on 26.3, 26.7, 26.8 and 26.9. #118674 carries no pr-must-backport label, so it was never cherry-picked.

Resolving the merge is the smaller half of the problem. Two of #117429's own tests assert a display surface that only #118674 produces:

  • 05233_database_backup_locator_secret_mask.reference expects ENGINE = Backup('default_src', S3('http://localhost:11111/test/backups/default/locator_mask', 'test', '[HIDDEN]')), that is, the locator as a nested function with only secret_access_key replaced.
  • test_mask_sensitive_info.py::test_database_backup_engine_azure_display_surfaces asserts AzureBlobStorage('[HIDDEN]', '[HIDDEN]', '[HIDDEN]', '[HIDDEN]', '[HIDDEN]') appears in both surfaces.

Both surfaces are DatabaseBackup::getCreateDatabaseQueryImpl() (InterpreterShowCreateQuery.cpp:195 and StorageSystemDatabases.cpp:70, through IDatabase.h:455). On 26.9 that method still builds its definition with quoteString(config.backup_info.toString()), and dropping that quoteString is #118674's change. So on every release branch the second argument parses back as a string literal and the masker replaces the argument whole, which is what master's own pre-#118674 expectation records for that shape:

CREATE DATABASE db_04510_quoted ENGINE = Backup(\'\', \'[HIDDEN]\')

Backup('db', '[HIDDEN]') is not the text either test expects, so both fail however the conflict is resolved. #117429's commit message says the same in one line: "SHOW CREATE DATABASE of a Backup database renders the locator as the function it is since #118674".

That makes this a decision rather than a merge:

  1. Backport Keep a Backup database loadable after ALTER DATABASE ... MODIFY COMMENT #118674 first. Then nothing is needed from me on 26.8 and 26.9: the prerequisite is the only thing missing there, and _retry_cherrypick (ci/tools/cherry_pick.py:457) rebuilds both branches against the new release head and merges them itself. 26.3 and 26.7 additionally lack the BackupSourceAccess.h and ->clone() work in registerBackupEngineS3.cpp; its patch site does still exist on both, so that part is a small port I can provide on request.
  2. Keep Mask secrets in SHOW CREATE DATABASE of a Backup database #117429 on master only and close these four.

@jkartseva which of the two would you prefer? I have pushed nothing and opened no PR.

For the record, the masking machinery itself (FunctionSecretArgumentsFinder.cpp and .h, +285) merges cleanly on all four branches. Only DatabaseBackup.cpp, the 04510 pair, registerBackupEngineS3.cpp (26.3 and 26.7) and test_mask_sensitive_info/test.py (26.3) conflict, and every one of those conflicts is a region the release branch never had.

@robot-ch-test-poll4

Copy link
Copy Markdown
Contributor Author

The 26.9 branch moved since this cherry-pick was created (now at 8a0ea8b). Re-tried the merge against it and it applies cleanly, so the bot is proceeding without manual resolution.

@robot-ch-test-poll4
robot-ch-test-poll4 merged commit c08e81d into backport/26.9/117429 Sep 25, 2026
1 check passed
@robot-ch-test-poll4
robot-ch-test-poll4 deleted the cherrypick/26.9/117429 branch September 25, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants