Skip to content

fix(performance): redactSqlLiterals reads [..], q'..' and triple-quoted bodies; redacts glued numbers - #156

Merged
krassx merged 3 commits into
mainfrom
fix/issue-148
Oct 29, 2026
Merged

krassx merged 3 commits into
mainfrom
fix/issue-148

Conversation

@krassx

@krassx krassx commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #148

Adds three dialect readings to the fail-closed tokenizer (SQL Server [..], Oracle q'..'/nq'..', BigQuery triple quotes); a quote inside them now makes the readings disagree and the tail is cut instead of shifting the pairing. The numeric rule no longer needs a trailing word boundary, so 123456789AND is redacted.

Accepted shape losses (fail-closed, pinned by a test): ARRAY['a'] / data['k'] cut at the bracket, a string starting with '' + quote reads as a triple quote, hex-digit keyword letters / digit-led words are eaten by the number rule.

Verification: mutator loop on every changed branch (one equivalent survivor: backslash handling in the triple scan is unobservable because the MySQL/standard readings cut first); randomised well-formed-statement fuzz across all dialect constructs (mulberry32); 100% line coverage, 98.9% branch on the file; one fresh Opus review round (all findings addressed or pinned).

🤖 Generated with Claude Code

krassx and others added 2 commits October 29, 2026 18:20
…bodies; redacts glued numbers

Fixes #148

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…hape losses

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 43 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d737b8f2-6276-4adb-919d-6cbc0c602b53
Commits

Reviewing files that changed from the base of the PR and between 4d3cb27 and 8005a00.

Files selected for processing: 2
  • packages/performance/src/span-sanitizer.test.ts
  • packages/performance/src/span-sanitizer.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@claude

claude Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Claude finished @krassx's task in 1m 24s —— View job


Review of PR #156: redactSqlLiterals dialect readings and glued numbers

  • Read the PR diff, the full span-sanitizer.ts tokenizer and the new tests
  • Probed edge cases by hand (see below)
  • Posted findings

Not done: I could not run the repo's test suite. pnpm and node_modules are not installed in this environment. Instead I ran the changed redactSqlLiterals code directly with Node 22, with the @bugsee/* imports stubbed out. The coverage and mutation-testing claims in the PR description are unverified by me.

Findings

Sev Location Summary
P3 span-sanitizer.ts:243-254 (inline) The [..] reading uses SQL Server's ]] escape, so Postgres a[b[1]] and ARRAY[[1,2],[3,4]] cut the tail. This is not listed with the other accepted shape losses.

I found no leaks. Both probes above fail closed, as the PR intends. A [..] run holding a quote, a q-quote or triple-quote body with an embedded quote, an unterminated run, a \-delimited q-quote, a raw triple string ending in \''', and 123-45-6789AND all came out with the secret redacted or the tail cut. Positional params ($1 → $?) and IN (1,2,3) LIMIT 10 are unchanged.

I also checked the trailing-\b removal in the number regex. Leading \b still protects col12, _3 and t.c4. The 1..2 change (?..? → ?.?) is only cosmetic, and the test is updated for it.

Summary

  1. Overall risk: Low
  2. Merge recommendation: Approve once the P3 note is addressed. Either document the nested-]] loss or fix it. It isn't blocking, because it fails on the safe side.
  3. Most important issue: the nested-bracket shape loss above. Postgres users of @opentelemetry/instrumentation-pg may see truncated statements for a[b[1]] and ARRAY[[..],[..]].
  4. Positives:
    • The new dialects are readings that must agree or the tail is cut, which fits the existing fail-closed design.
    • The accepted losses are pinned in a test.
    • The randomised statement fuzz uses a properly distributed PRNG.
    • Making the glued-number rule greedy closes a real leak (123456789AND).
      · Branch: fix/issue-148

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@krassx

krassx commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the P3 nested-bracket note by documenting and pinning the loss (accepted fail-closed shape loss, now in the shape-loss test). Depth counting was rejected: it would need a rule for [a]]b and risks reopening the leak.

@claude

claude Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Claude finished @krassx's task in 1m 0s —— View job


Re-review of PR #156 after the latest push (8005a000)

  • Read the new commits and the full diff of span-sanitizer.ts / span-sanitizer.test.ts
  • Checked whether my earlier P3 was resolved
  • Probed more edge cases by hand

Not done: I did not run the repo's test suite, because node_modules is not installed here. Instead I ran redactSqlLiterals directly with Node 22, with the @bugsee/* imports stubbed out. The coverage (100% line / 98.9% branch) and mutation-loop claims in the PR description are unverified by me.

Earlier finding

  • P3, nested ]] cuts the tail (a[b[1]], ARRAY[[1,2],[3,4]]): addressed. 8005a000 pins both shapes in the "accepted shape losses" test (span-sanitizer.test.ts:462-466) with the exact fail-closed outputs. That is what I suggested as the cheaper option. The PR description still lists only the older losses, so it would be worth adding the nested-bracket shape there too.

New findings

None. I tried to build a leak or a regression and could not. Cases I ran:

  • Comments with apostrophes: a = 'x' /* it's */ AND b = 'secret' redacts both literals and drops the comment.
  • Oracle q-quotes:
    • q'[abc]' , 'secret' is read correctly and 'secret' is redacted.
    • 'a' || q'!it's!' || 'secret' and nq'[sec'ret]' cut the tail.
  • Triple quotes: r'''abc\''' , 'secret' fails closed.
  • SQL Server brackets:
    • [dbo].[t] is kept intact.
    • [a'b]=1 cuts.
  • Glued numbers: 1_000AND, 0b101AND and 12abc are redacted. x'DEADBEEF' stays a string.
  • Performance: the added scans are linear and each one stops at an unterminated run. There is no new backtracking regex, so I see no ReDoS or latency concern from going from 3 to 6 readings.
  • Number rule: with the trailing \b removed, the leading \b still protects a1b2, _3, t.c4, col12. The remaining losses are the pinned ones: 0x1FAND becomes ?ND, and 1abc becomes ?abc.
  • Fail-closed property: the new readings can only add disagreements, which cut the tail. Nothing here makes a reading agree where it previously disagreed.

Summary

  1. Overall risk: Low
  2. Merge recommendation: Approve. My only earlier finding is resolved, and I have nothing new to raise.
  3. Most important issues: none blocking. Optionally, add the nested-bracket shape loss to the PR description's list of accepted losses.
  4. Positives:
    • The new dialect readings fit the existing "readings must agree or the tail is cut" design.
    • Every accepted loss is pinned by an exact-output test.
    • The mulberry32 fuzz covers each new construct, including the glued-number tail and a trailing 'zqend' literal.
    • The test pins the one cosmetic change, 1..2 now giving ?.?.
      · Branch: fix/issue-148

@krassx
krassx merged commit a6dcef7 into main Oct 29, 2026
8 checks passed
@krassx
krassx deleted the fix/issue-148 branch October 29, 2026 16:11
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.

redactSqlLiterals: SQL Server [..] identifiers, Oracle q'..' quoting and number-glued-to-keyword still leak

1 participant