Repository navigation
fix(5): quarantine workflow — Actions-expression + YAML + shell safe test identifiers (v2) - #472
Conversation
… Actions-expression, YAML, and shell layers CodeQL js/incomplete-sanitization #5 remediation (flakyTestService.js:220), v2 with two corrections from the REQUEST_CHANGES review (ai_reviews 1442): v1: testFilter escaped only double quotes. A test name containing a backslash defeats that escaping in the generated Actions command; dollar signs and backticks also expand inside double quotes; newlines escape the YAML block scalar and comment lines. Boundary sanitizer introduced (C0+DEL to space; backslash-first, then quote/dollar/backtick), uniform at both interpolation sites. v2 corrections: - CRITICAL, GitHub Actions expression injection: the workflow parser evaluates the ${{ ... }} sequence anywhere in the file at parse time — YAML quoting and shell escaping do not stop it (an escaped dollar sign still leaves the literal ${{ intact). The sanitizer now breaks the opener FIRST (${{ becomes "${ {"), so no ${{ sequence survives into the generated document. Regressions assert the literal is absent from the whole YAML and the payload remains data (secrets/fromJSON/github.actor/env payloads). - MEDIUM, YAML 1.1 line breaks: NEL U+0085, LS U+2028, PS U+2029 and the full C1 range are now stripped alongside C0+DEL (the characters that cannot appear in JS regex/string literals here are constructed via fromCharCode in tests). LOW finding (testNamePattern remains regex-interpreted by Jest — sanitized names can alter matching semantics) is PRE-EXISTING behavior, unchanged by this remediation and out of scope; noted in the PR. Regressions: 16 tests — real js-yaml document parse with structure pins, POSIX double-quote decoder proving the closing quote is the intended one (rest === 2>&1), expression-injection absence, YAML-1.1-break stripping, newline/CR structure injection, benign-name byte identity. 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. |
There was a problem hiding this comment.
🤖 AI Code Review — ✅ Approved
Confidence: high · Findings: 2
AI judgment: APPROVE · Evidence: COMPLETE · Authority: advisory
Evidence complete · 2/2 changed files accounted for
Other findings (2)
- [low] Test-file header comment says identifiers are interpolated at "two layers", omitting the Actions-expression layer the suite tests
- [medium] Escaping tests verify injection-safety, not matching semantics of quoted identifiers used as regex/pattern arguments
⚠️ unverified
🔮 Devil's Advocate (2 turns): 1 missed risk found · 1 upheld
GitWire AI Review Gate (bundle-driven v2) · Structured schema · Scope-validated · Devil's Advocate · AI recommendation — maintainers and repository policy retain authority
Finding details (not annotatable inline)
-
[MEDIUM] Escaping tests verify injection-safety, not matching semantics of quoted identifiers used as regex/pattern arguments
Quarantine workflows typically locate the flaky test by matching its identifier in a shell pattern (grep, pytest -k, jest -t). Proper quoting/escaping prevents injection (all three layers the review focused on), but if the identifier is still consumed as a regex, metacharacters appearing in legitimate test names — e.g. 'foo (bar)', 'a+b', 'x.y' — silently change matching behavior: the workflow can fail to match the intended flaky test (quarantine is a no-op and the flaky test keeps running in CI) or match unrelated tests (over-quarantine, masking healthy tests). This equivalence property is orthogonal to injection-safety and is easy to miss when the test suite is organized around escape layers. The review should verify the workflow consumes identifiers as fixed strings (-F / --fixed-strings / exact-name filters) and/or that the suite includes a round-trip assertion that the escaped identifier matches its original and only its original.
| @@ -0,0 +1,201 @@ | |||
| // tests/unit/flaky-quarantine-escaping.test.js | |||
| // CodeQL #5 remediation regressions: untrusted test identifiers (suite and | |||
| // test names parsed from repository CI output) are interpolated into the | |||
There was a problem hiding this comment.
[LOW] Test-file header comment says identifiers are interpolated at "two layers", omitting the Actions-expression layer the suite tests
The header comment in flaky-quarantine-escaping.test.js states the identifiers are interpolated "at two layers and must remain DATA at both", enumerating only YAML and shell. However, the suite contains dedicated ACTIONS EXPRESSION INJECTION tests asserting the ${{ sequence never survives, and the service-file comment (and the PR description) correctly describe THREE layers, with the Actions-expression layer flagged as the critical one. The stale/incomplete header could mislead a future maintainer into believing the expression layer is untested or unaddressed here. Fix: update the header to list all three layers (Actions expressions, YAML, shell), matching the sanitizer's documentation.
Review adjudication — APPROVED unit; both findings evidence-closed, neither blockingLOW — test-file header comment says "two layers" but the suite now tests three. Valid — the header predates the v2 expression layer. Non-substantive (comment-only), head preserved per the execution boundary; recorded in the post-merge cleanup batch. MEDIUM — escaping tests verify injection-safety, not matching semantics of Why it is not corrected in this head: the authorized scope for this unit was the sanitization boundary with existing valid-input behavior preserved; changing matching semantics (regex-escaping the name before shell-escaping, or switching the generated command to a fixed-string filter — note Jest's Proposed follow-up (parked, needs authorization): regex-escape each identifier before the existing sanitizer chain (order: regex-escape → expression-break → control-strip → shell-escape), plus a round-trip regression asserting the generated pattern matches its original test name and only it (jest State: head |
Summary
v2 of the #5 remediation unit — replaces #465. The re-run review of #465 (REQUEST_CHANGES, high confidence,
ai_reviews1442) found a critical gap in v1 plus a medium; both are corrected here. Single commit on master89d5e51. Merge authority reserved; returned at exact head for clearance.The v1 review's findings and their corrections
CRITICAL — GitHub Actions expression injection (
${{ … }}). The workflow parser evaluates${{ … }}anywhere in the file, at parse time, regardless of YAML quoting and regardless of shell escaping — v1's$→\$escape leaves the literal${{sequence intact through the backslash, so a test name like${{ secrets.GITHUB_TOKEN }}would still evaluate. Correction: the sanitizer now breaks the opener first (${{→${ {) before any other escaping, so no${{sequence survives into the generated document at any interpolation site. Regressions assert (a) the literal sequence is absent from the entire generated YAML, (b) the payload survives as flattened data through the POSIX decoder (secrets /fromJSON/github.actor/envpayloads), and (c) the document still parses with intact structure via js-yaml.MEDIUM — YAML 1.1 line breaks. NEL (U+0085), LS (U+2028), PS (U+2029) and the C1 range (U+0080–U+009F) are YAML 1.1 break/control characters that v1 did not strip. Correction: the control-character class now covers C0 + DEL + full C1 + LS/PS. Regression constructs them via
String.fromCharCode(they cannot appear as raw characters in JS source — U+2028/U+2029 are line terminators) and asserts stripping plus document-parse integrity.LOW —
testNamePatternremains regex-interpreted by Jest. Sanitized names containing regex metacharacters can alter matching semantics. This is pre-existing behavior (v0 escaping did not address it either), unchanged by this remediation, and out of scope; recorded here per the review.The sanitizer (three layers, one function, every interpolation site)
${{→${ {(opener broken; nothing else in the file can re-form it — the join separators are ours).command: |block scalar or a#comment line into structure).",$,`— the complete expansion/substitution surface of POSIX double quotes.Regressions (16 tests, all green alongside the existing flaky suite)
Real js-yaml document parses with structure pins (one job, four steps, injected
runs-on:/on:/jobs:keys survive only as data — via\n,\r\n, and now NEL); POSIX double-quote decoder proving the closing quote is the intended one (post-close remainder is exactly2>&1) for\",$(), backtick,${IFS}, and multi-candidate|joins; expression-injection absence at unit and document level; benign names byte-identical.