fix: clear the polynomial-redos class across main - #1546
Conversation
Three sites of the same CodeQL js/polynomial-redos family: - packages/replay-test session-test-artifacts/-discovery slugs trimmed edge dashes with /^-+|-+$/g, which backtracks polynomially on long dash runs built from caller-supplied paths (alerts #27/#28). Replaced with a shared linear trimEdgeDashes. - src/replay/target-identity.ts's target-v1 annotation line regex had the \s+(.*) ambiguity (the shape flagged as alert #29 on the #1536 copy). Anchored the payload group on \S so the split point is unique; the only caller matches against trimmed lines, so behavior is unchanged. Adversarial regression test on the slug path (100k-char dash run, sub-second); the annotation-regex adversarial case is covered on the #1536 package copy and the frozen replay-compat corpus passes here unchanged. Co-Authored-By: Claude <noreply@anthropic.com>
Size Report
Startup median (7 runs, lower is better):
Top changed chunks:
|
|
Re-reviewed One blocking test-validity issue remains: the claimed adversarial test uses dashes only at the edges, which the old |
The edge-run input matched the old /^-+|-+$/g in one pass; the quadratic case is an interior run (each dash restarts a -+$ attempt that fails at the trailing byte). The slug pipeline collapses runs before trimming, so the test targets trimEdgeDashes directly and asserts the input comes back byte-identical. Co-Authored-By: Claude <noreply@anthropic.com>
|
Fixed in Generated by Claude Code |
|
Re-reviewed exact head
Please rerun the exact-head gates after those changes. |
Co-Authored-By: Claude <noreply@anthropic.com>
|
Both blockers addressed at Errata on my own process, in the spirit of this review thread: the first push of this commit carried a red version of the new test (my initial artifact-slug input wasn't actually all-dash after slugging — it returned Generated by Claude Code |
Artifact slug falls back to 'test', invocation id to 'suite', and a session-name slug that trims to nothing is omitted without a dangling separator. Co-Authored-By: Claude <noreply@anthropic.com>
c1d16b7 to
2ae86d9
Compare
|
Re-review at |
|
* fix: clear the last polynomial-redos instance in swift-cache sanitizeCacheName used /^-+|-+$/g to trim edge dashes, the same js/polynomial-redos pattern PR #1546 retired everywhere else. Replace it with the linear-time trim used there, and add a counterfactual regression test that fails against the old regex on a long interior dash run. * fix: keep sanitizeCacheName private, drive redos/fallback pins through compileSwiftSourceText Addresses PR #1549 reviewer feedback: sanitizeCacheName was exported solely so the regression test could import it, which docs/agents/testing.md's test-interface rule forbids. Reverted the export and rewrote the test to exercise the sanitizer through compileSwiftSourceText, an existing production seam that already calls it. - Timing pin: a cache name with a 100k-char interior dash run still resolves in sub-second time (the call may reject once it reaches disk I/O due to the OS path-component length limit, but that happens only after the now-fast sanitize step, so timing the settle either way still proves no catastrophic backtracking). - Fallback pin: a cache name that sanitizes to nothing (e.g. '---') still produces the 'swift-helper' fallback, observed via the returned executable path. Counterfactuals (see PR comment for full output): - Restoring the retired `/^-+|-+$/g` regex trim made the timing pin fail: 3428ms >= 1000ms. - Removing the `|| 'swift-helper'` fallback made the fallback pin fail: basename did not start with 'swift-helper-'.
You flagged that the CodeQL finding on #1536 exists elsewhere already — correct, and this clears the whole class on main in one small PR:
packages/replay-testslug builders, from the merged refactor(replay-test): extract packages/replay-test (#1478 P3b) #1525):/^-+|-+$/gedge-trim backtracks polynomially on long dash runs derived from caller-supplied file paths/request ids. Replaced with a shared lineartrimEdgeDashes(no import cycle; discovery already sits above artifacts).src/replay/target-identity.ts:16) — the identical\s+(.*)ambiguity that alert fix: iOS snapshot not showing password fields #29 flagged on refactor: extract the .ad script codec into packages/ad-script (#1478) #1536's moved copy. Same fix as there: anchor the payload on\Sso the split point is unique. Behavior-preserving (the only caller matches trimmed lines); when refactor: extract the .ad script codec into packages/ad-script (#1478) #1536 rebases, its already-fixed package copy supersedes this file wholesale, so no conflict of substance.Gates: typecheck, lint, format,
check:replay-compat(frozen corpus unchanged), fallow zero at main scope; 45/45 in the touched suites plus a 100k-char adversarial slug test asserting sub-second completion.Refs #1478