Repository navigation
Conversation
… YAML and shell layers CodeQL js/incomplete-sanitization #5 remediation (flakyTestService.js:220): testFilter escaped only double quotes. A test name containing a backslash (specifically \") defeats that escaping in the generated Actions command — the doubled backslash collapses and the quote closes the shell argument early, executing the remainder as shell syntax in the runner. Dollar signs and backticks also expand inside double quotes. New boundary sanitizer sanitizeTestIdentifier(), applied uniformly at both interpolation sites (filter and comments): - YAML layer: all C0 controls + DEL become spaces — the only characters that can escape a command:| block scalar or a trailing comment line and inject workflow structure - shell layer: backslash FIRST, then double quote, dollar sign, backtick buildQuarantineWorkflow now exported for testing. Regressions (flaky-quarantine-escaping.test.js, 13 tests): real js-yaml parse of the generated document with structure assertions (one job, four steps, injected runs-on/on: keys survive only as data); POSIX double-quote decoder proving the closing quote is the intended one (rest === 2>&1) for crafted \", $(), backtick, ${IFS}, newline and CR payloads; benign names byte-identical (equivalent quarantine behavior). Signed-off-by: Alajmah <55954113+Alajmah@users.noreply.github.com>
…nce regexes CodeQL js/polynomial-redos #1/#2 remediation (reviewSchema.js:273/284). The fence regex pair's greedy \s* (matches newlines) interacting with the following \n? made the whitespace bridge ambiguous: O(n^2) per fence occurrence on unclosed-fence + long-whitespace inputs, multiplied by matchAll per fence. Input is the review LLM completion (max_tokens 32768) — reachable via prompt-injection echo — and extraction runs on the shared worker event loop, so pathological output blocked all 14 workers plus /health. Replacement: scanFencedBlocks() — monotonic indexOf pairing of opening and closing fences, linear worst case regardless of whitespace shape. Semantics preserved from the regex pair: sequential pairing (matchAll continuation), immediate-json label stripping (the (?:json)? branch; JSON never starts with the letters json), unclosed trailing fence yields no block, caller-side trim unchanged, strategy identifiers fenced/fenced_multi unchanged. Regressions (review-schema-fence-scanner.test.js, 22 tests): - EQUIVALENCE: old regexes reproduced verbatim in-tree; 13-member corpus (labels, label-not-immediate, multi-fence, adjacency, unclosed, mid-line) asserts identical strategy+json outcomes - BOUNDEDNESS (maintainer-specified shapes, all under 500ms): unclosed fence + 200k spaces (the maintainer's reproduced 2.06s case, scaled), + 200k newlines (CodeQL's stated shape), 30k repeated opening fences, 5k-fence valid multi-fence response, 150k-space run inside a valid fence - Pre-existing reviewSchema suite (60 tests) unchanged and green; full rules suite 328/328. Signed-off-by: Alajmah <55954113+Alajmah@users.noreply.github.com>
CodeQL js/polynomial-redos #3 remediation (reviewSchema.js:324-325). The strategy-5 regex retried its literal prefix at every index and rescanned the remaining suffix per candidate via the lazy body — quadratic on inputs repeating {"findings":[ without completion, on the shared worker event loop. Replacement: findFindingsPatternStart() — two monotonic indexOf passes with O(1) shape checks: (1) every literal "overall_correctness" occurrence is walked LEFT to collect valid ]-closes (ws* , ws* ], no suffix rescans); (2) every {"findings" occurrence gets the deterministic \s*:\s*\[ shape check and an existence test against the sorted close list. Linear total work. First-match-start semantics preserved (incl. empty-array [] closes — the lazy body may be zero-length; pinned by regression); the old indexOf(matchText) was provably redundant (an earlier occurrence of the full match text would itself be an earlier match, contradicting first-match selection) — noted in the scanner doc. Strategy 5's downstream flow (slice from match start, findMatchingBrace, JSON.parse, pattern_match identifier) unchanged. Regressions (review-schema-findings-pattern.test.js, 11 tests): - EQUIVALENCE: old regex + old strategy-5 flow reproduced verbatim (findMatchingBrace replicated); 7-member corpus (firing shapes, first candidate completing via later text, invalid-JSON tails, no-array candidates, later-partial candidates) asserts fire/no-fire agreement; tab-spread whitespace tolerance; first-candidate precedence - BOUNDEDNESS (<500ms): 30k repeated prefixes no completion (linear, falls through); 30k prefixes + one completion (shape completes, brace balance cannot close 30k opens — old flow identical terminal result); 1k-member single-candidate scale-up resolving pattern_match Full rules suite 342/342 (fence-scanner + pre-existing suites unchanged). Signed-off-by: Alajmah <55954113+Alajmah@users.noreply.github.com>
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Unit 3 of the authorized #425 remediation sequence (#5 → #1+#2 → #3 → #4). Remediation of CodeQL
js/polynomial-redos#3 (reviewSchema.js:324–325) under the corrected acceptance criterion: a monotonic scan that does not repeatedly rescan suffixes — not an anchored regex. Merge authority reserved; returned at exact head for clearance.The defect
Strategy 5's regex
/\{"findings"\s*:\s*\[[\s\S]*?\]\s*,\s*"overall_correctness"/retried its literal prefix at every index, and per candidate the lazy body rescanned the remaining suffix hunting for a completing]— quadratic on inputs that repeat{"findings":[without ever completing the pattern (each of the ~n/14 occurrences starts a fresh suffix expansion). Same shared-event-loop blast radius as #1/#2.The correction (per the corrected criterion)
New
findFindingsPatternStart()— two monotonicindexOfpasses, no suffix ever rescanned:"overall_correctness"once; for each occurrence walk left over the two whitespace runs to validate the] , "shape, collecting valid]positions. Each character is visited a constant number of times.{"findings"in order; per candidate, the deterministic\s*:\s*\[shape check (whitespace runs have exactly one viable split — the first non-whitespace character either is the required token or the candidate fails, no backtracking alternatives), then an existence test against the sorted close list.Total work linear in the input. First-match-start semantics preserved exactly, including the empty-array case (
[]— the lazy body may be zero-length, so a valid close exactly at the body start completes; caught and fixed during this unit's development as a strict->vs>=off-by-one my first scanner version had). The old code's extratrimmed.indexOf(matchText)was provably redundant and is noted in the scanner's documentation: an earlier occurrence of the full matched text would itself have been an earlier pattern match, contradicting first-match selection.Strategy 5's downstream flow — slice from the match start,
findMatchingBrace,JSON.parse,pattern_matchidentifier — is byte-unchanged.Regressions (
packages/rules/tests/review-schema-findings-pattern.test.js, 11 tests)Equivalence — the old regex and the old strategy-5 flow (match → slice → brace balance → parse, with
findMatchingBracereplicated verbatim) are reproduced in-tree; a 7-member corpus asserts fire/no-fire agreement: firing shapes (defeating strategies 1–4 by construction), first-candidate-completes-via-later-text (lazy-body reach), shape-completes-but-JSON-invalid,:-then-no-[candidates, later-partial candidates. Plus tab-spread whitespace tolerance and first-candidate precedence.Boundedness (all < 500 ms):
{"findings":[prefixes, no completion — linear, falls through.pattern_match.Verification
@gitwire/rulessuite 342/342 (fence-scanner and pre-existing suites unchanged).masterat 89d5e51) — both touchreviewSchema.jsbut disjoint regions (fence strategies vs strategy 5). Merge order fix(1/2): deterministic fenced-JSON extraction — linear worst case (CodeQL #1/#2) #466 → this PR is conflict-free; the reverse order needs a rebase.