Skip to content

fix: make the guest-text regexes linear and stop logging a token prefix - #2

Merged
aidev1-technext merged 1 commit into
mainfrom
fix/codeql-redos
Sep 30, 2026
Merged

aidev1-technext merged 1 commit into
mainfrom
fix/codeql-redos

Conversation

@aidev1-technext

Copy link
Copy Markdown
Collaborator

What changed

This fixes the 10 CodeQL alerts that were already open on main and reappeared on #1 because the files moved. It also stops a script from printing part of a live WhatsApp token.

Alert File Fix
polynomial-redos ai/src/application/normalize.ts (log mask) Cap the email local part at 64 chars (the RFC 5321 limit)
polynomial-redos ×2 ai/src/application/synthesis.ts (price gate, room-type gate) The price branch starts only at the start of a digit run; \s*:?\s* becomes \s*(?::\s*)?
polynomial-redos ai/src/domain/counts.ts No two \s* next to each other around just/only
polynomial-redos ×2 quotation/src/application/quotationTool.ts (split-day dives) (?<!\d) before the count
bad-tag-filter ×2 bff/test/renderedPages.test.ts, studioScript.test.ts Match </script >, case-insensitive
clear-text-logging ×2 bff/scripts/whatsapp-check.mjs Print a SHA-256 fingerprint instead of the token's first 6 characters

Why it is a separate PR

These regexes are the log mask and the fact gate on messages sent to guests. A change here can change guest-facing behaviour, so it is kept apart from the structural move in #1. This PR is based on #1 and retargets to main once #1 merges.

How it was tested

  • npm run verify: boundaries ok, typecheck ok, 951 tests pass. New regexSafety tests in ai/ and quotation/ check both halves: a 100k-character hostile input finishes in under 500 ms, and the matches guests actually produce are unchanged (prices written three ways, back-to-back emails, room type: standard, just 4, split-day dives).
  • Differential fuzz of 150k random strings through the real old and new functions: 0 differences in verifyGuestFacingText, maskForLogging and corroborateCount.
  • The fuzz caught one bad first attempt. A lookbehind on EMAIL_RE stopped masking the second of two addresses written back to back, so it was replaced by the 64-character cap. The only behaviour difference left: a local part longer than 64 characters, which a real address cannot have, is masked from its last 64 characters.
  • Measured on the old regexes: 100k / took 4.5 s; 9 followed by 30k 0 took 1.2 s in the price gate. Both now take near 0 ms.

Not fixable in code

Analyze (python) fails because the repo's CodeQL default setup still scans Python, and there is no Python code left in the repo (the only .py files were under .agents/, now untracked). Remove Python under Settings → Code security → CodeQL default setup.

🤖 Generated with Claude Code

Clears the CodeQL alerts that were open on main before the restructure and
reappeared on its moved paths.

- normalize.ts EMAIL_RE: cap the local part at 64 chars (RFC 5321). A
  lookbehind anchor was tried first and rejected: fuzzing showed it stopped
  masking the second of two back-to-back addresses.
- synthesis.ts price gate: the digit branch starts at the beginning of a
  digit/separator run, at its first digit. Same verdict, linear.
- synthesis.ts room-type check, counts.ts bare-number read: no two adjacent
  \s* around an optional token.
- quotationTool.ts split-day parser: the count starts where the digit run
  starts.
- whatsapp-check.mjs printed the first 6 characters of the live access
  token; it now prints a 10-hex SHA-256 fingerprint.
- Test-page script extractors match </script > and are case-insensitive.

Checked by differential fuzzing (150k random strings through the real old
and new functions: 0 differences in the fact gate, the log mask and count
corroboration) and by regexSafety tests in ai/ and quotation/ that pin both
the hostile input (100k chars, < 500 ms) and the matches guests produce.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
technext-edge-casa-bff Ready Ready Preview Sep 30, 2026 7:38am UTC

@aidev1-technext
aidev1-technext changed the base branch from chore/restructure-layout to main September 30, 2026 08:00
@aidev1-technext
aidev1-technext merged commit 33b3251 into main Sep 30, 2026
3 checks passed
@aidev1-technext
aidev1-technext deleted the fix/codeql-redos branch September 30, 2026 08:04
aidev1-technext added a commit that referenced this pull request Oct 1, 2026
…on notes, index the folders

- docs/demo -> docs/archive/demo-2026-09; phase1/phase2 implementation notes and the extractor-duplication note (solved by
  mirroring ai/, with a pointer to port-to-team-repo.md) -> docs/archive/notes.
- The archify example traces (example-trace-*) are not this project's; removed.
- anthony-decisions: no 'Anthropic by default' policy any more (flexible model, Q-021), PR #5 replaces #2/#4, 'the team
  estimator' for the customer's tool.
- docs/README indexes adr, guides, specs, notes, diagrams, site and archive; todo-before-demo marks rounds 1 and 2.

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

This branch was successfully deployed

1 active deployment
Preview — c3f0fb4f Deployed Sep 30, 2026 by vercel[bot]
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