Repository navigation
XSS preflight gate: only suggest the DOM-grep test route when it can apply - #105
Merged
Merged
Conversation
The fix hint in scripts/check-xss-sinks.sh always suggested "add a DOM-grep test in test*.js", but CI's --diff step never sets PREFLIGHT_TEST_FILES, so that route is dead in CI. The hint misled an agent and a reviewer into believing an existing test covered a sink (PR #99); CI then failed. The gate itself is unchanged (no detection or allowlist edits). The hint now: - mentions the test route only when PREFLIGHT_TEST_FILES is non-empty; - otherwise suggests escapeHtml/escapeAttr/esc, DOM construction with createElement + textContent / non-URL setAttribute, or the PR-body opt-out plus xss-optout label, and notes that tests do not count. The header comment documents the CI scope, and AGENTS.md gains a short note on what the CI gate accepts. test-preflight-xss-gate.js asserts the hint wording with and without PREFLIGHT_TEST_FILES. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Rd9Nh9Z2A9UgMupvLHCKUr
dborup
marked this pull request as ready for review
September 26, 2026 13:45
dborup
added a commit
that referenced
this pull request
Sep 26, 2026
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.
Problem
scripts/check-xss-sinks.shalways printed this fix hint: "or add a DOM-grep test in test*.js asserting the payload renders inert". CI's PR-only--diffstep in.github/workflows/deploy.ymlsets onlyPREFLIGHT_PR_BODYandPREFLIGHT_PR_LABELS. It never setsPREFLIGHT_TEST_FILES, so the test route can't work in CI.In dborup/CoreScope#99, the hint led an agent and a reviewer to believe an existing test covered a flagged sink. It didn't, and CI failed. The fix there was to build the dialog with the DOM API.
Why the gate is not weakened
This PR changes only the wording of the hint and the comments. Detection, the allowlist, the opt-out rules and the workflow are unchanged. The test route stays out of CI on purpose, because the sham-test check (basename plus a marker grep) is too weak to trust there. In CI a flagged line still passes only through one of these:
xss-optoutlabelChanges
scripts/check-xss-sinks.shPREFLIGHT_TEST_FILESis non-empty.escapeHtml/escapeAttr/esc,createElement+textContent(orsetAttributefor non-URL, non-on*attributes), or opt-out + label. It also adds a note that tests do not count in this run.AGENTS.md: a short "XSS preflight gate (CI)" note under Frontend Conventions. It says what CI accepts and that DOM construction is the preferred fix for false positives.test-preflight-xss-gate.js: new assertions on the hint wording:PREFLIGHT_TEST_FILESunset, empty and setThe existing exit-code table is unchanged.
Hint before and after (CI mode,
bad-1-template-literal.js)Before:
After:
Tests
node test-preflight-xss-gate.js: 14 new assertions failed before the script change and pass after it. All 31 checks pass, including the 17 existing fixture exit-code cases.node test-xss-escape-sinks.js: 34 passed.check-xss-sinks.sh --diff origin/masteron this branch: exit 0, because nopublic/files changed.dlg.innerHTML = helper(id, name)topublic/next to an existing test file that containsonerror=alert. In CI mode the old and new scripts both fail with exit 1; only the new script gives the correct hint. WithPREFLIGHT_TEST_FILESset locally, the sink is accepted, which is exactly the behaviour CI does not have.Perf
The only change is an extra string check when a finding is printed. The scanning path is not touched.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Rd9Nh9Z2A9UgMupvLHCKUr
Generated by Claude Code