Loading...

AI Guardrails — CodeQL Clean On First Push

RULES.md

A PR must pass the CodeQL check on its first push; do not leave security alerts for the reviewer to send back. Before pushing, run CodeQL locally on what you changed with the same query suite and `paths-ignore` the repo's CodeQL workflow uses. In `webcomponents` this is part of `yarn precheck` (`yarn codeql` on its own); install the CLI once per session with `yarn codeql:install`, and the Claude Code push hook blocks `git push` and `gh pr create` until the scan is clean. In a repo without that script, download the official CodeQL bundle (<https://github.com/github/codeql-action/releases>), create a JavaScript database scoped to the changed folders using the repo's `.github/codeql/codeql-config.yml`, analyze with `codeql/javascript-queries:codeql-suites/javascript-code-scanning.qls`, and fix every alert that lands in a changed file; the reference implementation is <https://github.com/haxtheweb/webcomponents/blob/master/scripts/codeql-local.mjs>. Fix alerts in the code, never by suppressing them, loosening the CodeQL config or adding `paths-ignore` entries. Recurring HAX alerts to avoid while writing: `Math.random()` for ids or anything that reaches the DOM (use a counter or `crypto.randomUUID()`), single-pass or case-sensitive tag/HTML sanitization and quadratic regexes (use linear-time patterns, repeat until stable, or a real parser), assigning to object keys taken from input without guarding `__proto__`/`constructor`/`prototype`, and turning DOM text back into HTML. Say in the PR description that the local CodeQL scan ran and its result. In PRAW RULES.md (scope: global). Enforced by CodeQL.

Connects to

Links