Skip to content

The CI-checks clause is served and stored without its credentials - #198

Merged
zlareb1 merged 11 commits into
mainfrom
fix/tracker-checks-source-redacted
Nov 3, 2026
Merged

zlareb1 merged 11 commits into
mainfrom
fix/tracker-checks-source-redacted

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in a release)

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

tracker.test_signal's source, the source column of loom.qa_rollup_days and loom tracker-probe show the CI-checks clause without its credentials: a table name as is, a remote / remoteSecure call as its address and table (with ... for any arguments after it), and any other clause as its function name.

Why

Two leaks of the same credential, the password inside a checks FROM clause (LOOM_TRACKER_CHECKS_FROM or a source entry's checks.from):

  • Failing case 1: redact_table_function("remoteSecure('h:9440', default.checks, 'play', 'secret')") returned its input. The same held for bare db, table identifiers, for the view(...) form, and for a named collection's password = '...'. loom tracker-probe prints the clause through this function.
  • Failing case 2: tracker.test_signal (VIEWER) returned the raw clause in source, and the daily rollup worker stored it in loom.qa_rollup_days.source. Neither went through the redactor.

Pattern: credential masking keyed on the position of a quoted literal, and a credential-bearing setting served and stored without the masking that exists for it.

Fix: redact_table_function builds the label from parts that cannot hold a credential, so it fails closed instead of masking text it would have to parse. A table name comes back as is. A remote / remoteSecure call whose address and table match a strict pattern comes back as fn('address', table, ...). The table is db.table or db, table, quoted or bare, and every argument after it (the user, the password, a sharding key) reads .... Any other clause comes back as its function name, fn(...), or as (...). That covers a view(...) table argument, a named collection, another table function, a subquery and a malformed call. Masking by argument position missed each new piece of SQL syntax in turn (heredocs, quoted names, # and nested comments, bare key = value values), so this PR drops it. A new checks_source_label(org, namespace) returns the label, and both the op and the worker use it. The reads keep calling checks_config, which still returns the full clause because the statement needs it.

The two fixes are separate in code. They ship together because they close the same leak: an unmasked credential in a source string that Loom serves or stores.

Scope and risk

Touches only the label: what callers read and what the ledger stores. The FROM clause of the reads is unchanged. The label of a clause that is not a plain remote call is less detailed than before (view(...) and named-collection calls show only the function name). That is the cost of never printing text the code does not recognise. Two surfaces outside the tracker plane are left alone. The settings listing (loom settings, repr(settings)) still prints tracker_checks_from and tracker_sources_json as configured. Marking either one secret would also refuse it in a settings file, which is a separate change with its own compatibility break. The other is ClickHouse error text that tracker.test_signal serves when a checks read fails, which may quote part of a malformed clause. Both go to a follow-up.

Compatibility, rollout and rollback

  • Wire: tracker.test_signal.source keeps its type and now holds the label above. Its field description (and docs/reference/operations/tracker.md, regenerated) says so. No op or field is added or removed.
  • Operator steps: rows already in loom.qa_rollup_days keep the clause they were written with. A final day is never rolled again, so those rows are not rewritten. Replicas still on the previous build keep writing the unmasked clause during the rolling upgrade, and today's partial day is rewritten on every pass. A deployment whose checks clause carried a password should rotate it. To clear the stored copies, run this after every replica is on this build: ALTER TABLE loom.qa_rollup_days UPDATE source = '' WHERE rolled_at < '<when the last replica moved to this build>' AND position(source, '(') > 0. The time bound keeps this build's labels, including one cut at 200 characters. The statement names no secret, so system.query_log and system.mutations hold none.
  • Rollback: reverting brings back the unmasked label on new rows. Rows written by this build keep the label without credentials.

Tests

  • tests/unit/test_qa_intel_client.py::test_the_checks_clause_label_is_built_from_parts_without_a_credential: the exact label for twenty-one clauses. They include a table name, each remote form (quoted, bare, db.table, a sharding key, a heredoc credential, a # comment with an apostrophe, a trailing JOIN), a view(...) argument, a named collection with bare values, mysql, s3, an unterminated heredoc and a subquery. Before the fix, eleven of the seventeen clauses that are not table names leaked a user or a password. The other six carry no credential, or had it in the fourth quoted literal or later.
  • tests/unit/test_tracker_test_signal.py::test_the_served_source_carries_no_checks_password: the op's source with a password configured. Failed before the fix.
  • tests/unit/test_tracker_test_daily.py::test_the_ledger_stores_the_checks_source_without_its_password: the worker's ledger rows. Failed before the fix.
  • make format lint typecheck. The tracker unit tests pass. The full unit suite passes except test_document_extraction.py::test_the_wide_integer_check_is_linear_in_a_deep_table_of_long_keys, a wall-clock check that also fails on main.
  • CI: the red checks on this head are failures that main has too, namely that wall-clock unit test and the integration tests same_key/test_retirement_ch.py (two), test_memory_inspect.py::test_inspect_splits_own_from_others_and_changes_nothing and test_search_statements_pass_analyzer.py::test_patch_part_probe_and_reemit_reads_pass_the_analyzer.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code. Checked each failing case against the code before the fix and confirmed the tests failed for that reason.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • Generated files are regenerated in this PR, not by hand: none are affected.
  • A new migration is additive and numbered after the latest on main; no merged migration is edited. (none)
  • A behaviour change to any file a plugin ships bumps both plugin manifests' version. (none)
  • The frontend builds, if frontend/ changed. (unchanged)
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers.
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

zlareb1 and others added 6 commits November 3, 2026 09:55
…ssword masked

redact_table_function masked quoted literals from the fourth on, so the
db.table, bare-identifier, view(...) and named-collection forms of
remote/remoteSecure kept their password; it now masks by argument
position after the table. tracker.test_signal's source and
loom.qa_rollup_days.source read the clause through the same masking
(checks_source_label) instead of the raw checks_config value.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
A table function other than remote, a subquery and a malformed call
now have every quoted literal masked, including an unterminated one;
any call as remote's second argument is one table argument.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…table argument, is served masked

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…comments

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…all's address and table

Masking by argument position kept missing SQL syntax (comments, quoted
names, bare key = value values); the label now shows only parts that
cannot hold a credential and names any other clause by its function.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1 zlareb1 changed the title The CI-checks clause is served and stored with its remote user and password masked The CI-checks clause is served and stored without its credentials Nov 3, 2026
@zlareb1
zlareb1 merged commit 1c0dfc6 into main Nov 3, 2026
22 checks passed
@zlareb1
zlareb1 deleted the fix/tracker-checks-source-redacted branch November 3, 2026 17:36
@pufit pufit mentioned this pull request Nov 4, 2026
9 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant