Skip to content

feat(rules): [[ignore]] waives findings by item or URL without disabling a rule (#1262) - #1333

Closed
nc9 wants to merge 1 commit into
mainfrom
feat/ignore-1262
Closed

nc9 wants to merge 1 commit into
mainfrom
feat/ignore-1262

Conversation

@nc9

@nc9 nc9 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Refs #1262 (first PR of the plan in the spec comment; not complete against the AC, see "Not in this PR").

What

One engine-level [[ignore]] table in squirrel.toml, applied to every rule's results. Decisions recorded on the issue (Nik, 2026-10-30): ignorable: false only for integrity/*; a fully waived check is a pass with an "N waived" note; reason optional; AND within an entry, OR across entries; --no-ignore in the first PR.

[[ignore]]
rule   = "security/cookie-flags"
items  = ["localization", "cart_currency"]
reason = "Shopify sets these cookies itself"

[[ignore]]
rule = "perf/ttfb"
urls = ["/apps/"]
  • Config (packages/config/src/ignore.ts): IgnoreEntrySchema (rule or glob, optional checks, items, urls, reason; items or urls required; selectors refused as "not supported yet"; caps of 200 entries, 100 matchers, 200/512 characters), Config.ignore optional so an absent list changes nothing.
  • Engine (packages/rules/src/ignore.ts, hook in RuleRunner.runOneRule): the one place every result passes (page rules, site rules, fanned template verdicts, after the fan-out clone so a URL waiver is judged against this page). Items match exactly by default, glob: and regex: by prefix, against item id then label; urls use the excludePatterns forms. Regexes over 200 characters, with nested quantifiers or invalid are refused (reported, never run); glob and regex inputs are clamped to 1000 characters.
  • Semantics: items removed before the finding is counted; check with items left keeps its status, message gains (N ignored) (rules with meta.messageCountsItems, security/cookie-flags first, show the remaining count); all items waived: the check becomes a pass N waived by squirrel.toml: ...; urls alone on a page rule: the rule is not run on a matching page and a visible skipped check (skipReason: "ignored", excluded from the score) says why; items AND urls prune sourcePages and waive an item left with none; pass and skipped checks are never touched.
  • Cache: pageRuleSignature() carries the entries that name a rule, and computeRunContextHash now includes it (it previously projected only id and options, so an edited waiver would have replayed stale results). Only the named rules' keys move; with no list every key is unchanged.
  • Template fan-out: a rule named by an entry with urls is disqualified from fan-out (like skipOnSoft404/skipOnNoindex), because its verdict is no longer a property of the template.
  • ignorable: false on the nine integrity/* rules; an entry naming one is a squirrel config validate error and the engine never applies it.
  • Reporting: report.ignored (meta.ignored in JSON): waived items and pages, per rule, per entry with its reason, entries that matched nothing, disabled for --no-ignore, carriedStale. A Ignored by squirrel.toml: ... line plus an Ignore entry N (...) matched nothing. line in console, text, markdown and HTML; <ignored> elements in LLM and XML; slim-JSON round trip with validation (a stored report is untrusted: control characters stripped, counts made safe). The per-check record lives in details.ignored (already persisted with a check, no storage migration), and the summary is rebuilt from the stored checks plus the entries stamped on scanScope.ignore, so squirrel report shows the same.
  • squirrel audit --no-ignore, completions (bash, zsh, fish), squirrel config validate and the audit preflight report unknown rules (with a suggestion), non-ignorable rules, unsafe patterns, and point rule_options keys named ignore* at [[ignore]].
  • Docs: new docs/configuration/ignore.mdx (nav entry), docs/cli/audit.mdx, docs/configuration/rule-options.mdx, docs/configuration/output.mdx; CHANGELOG bullet under Unreleased. make validate passes.

Smart-audit carry path (the open question in the spec): verified

Findings carried from pages a run did not crawl are replayed from the per-page store (carriedFindingToCheck and its SQL twin for untouched pages) and never pass through runOneRule, so a list edited since the earlier audit cannot reach them. Filtering the store-side twin is not feasible in this PR. Instead the audit stamps a fingerprint of the list on the crawl's scan scope; when the previous audit's differs and this run carried findings, the report sets ignored.carriedStale and the line says carried findings may still include waived items, with the fix (re-run without a page limit, or --refresh). An unchanged list says nothing. Tested end to end (three real audits with smart_audits = true: changed list gives carriedStale, same list again does not). Findings recorded after the list existed are already filtered, so the stale case is only "the list changed since".

Tests (failing first where noted)

  • packages/rules/tests/ignore-1262.test.ts (21): the security/cookie-flags case from the issue (localization and cart_currency waived, merchant_pref still reported with counts and (2 ignored)), all-waived pass, no-list byte identity, checks scoping, page waiver (rule not run, skipped check), items AND urls, site-rule sourcePages pruning, every matcher form, entry OR/AND, unsafe regex refused, a 5 MB id compared in bounded time, non-ignorable rule, signature behaviour, every integrity/* rule ignorable: false. With the runner hook reverted 9 fail.
  • packages/audit-engine/tests/ignore-rule-cache-1262.test.ts (4; 3 fail with rule-cache.ts reverted) and ignore-template-fanout-1262.test.ts (3; 1 fails with the fan-out change reverted).
  • packages/config/tests/ignore-1262.test.ts (7), packages/report/tests/ignored-1262.test.ts (20, including hostile stored values), apps/cli/tests/commands/config-validate.test.ts (+4), apps/cli/tests/controllers/report.test.ts (+1 round trip), apps/cli/tests/cli/audit-ignore-e2e.test.ts (5 real squirrel audit runs against a local site setting Shopify-style cookies: waived, --no-ignore, no list, text output with the unmatched entry, the carry case).
  • Also run by explicit path and green: rule-verdict-scope, template-verdict-page-independence, template-verdict-inputs, meta-string-limits, rule-time-budget, docs-rule-pages, cookie-flags, rule-options-check, the canonical and cache-replay and fan-out goldens, completion, help, config, report controller tests, four audit wiring tests; tsgo for config, core-contracts, report, rules, audit-engine and cli; oxlint and format check; docs make validate. Not run here: scripts/test-suites.ts --run rules and --run rest (left to CI).

Not in this PR (the AC checklist is not complete, so Refs, not Fixes)

  • Per-issue "(N ignored)" suffix next to each issue heading in the console, markdown and HTML renderers: the counts are in the scan line, meta.ignored.byRule and the check messages for now.
  • Cloud: website settings ignore column, API, MCP, dashboard editor and report line (private follow-up). Published reports do not carry ignored yet (slimForPublish is unchanged).
  • Selectors (phase 3), squirrel config show --cloud.
  • Filtering carried findings themselves (see above).
  • Rules other than security/cookie-flags have not opted into messageCountsItems; they keep their message and gain the (N ignored) suffix.

Skill

The squirrelscan agent skill needs a change (an agent must know a report can be filtered and read ignored before proposing fixes for a waived finding). A private issue labelled skills is filed.

Rebased onto main 5387823 (head 803670e; was approved at e2667df). Conflicts resolved with behaviour unchanged: template-fanout.ts now builds its set from main's fannableRules(...) and keeps the [[ignore]] per-page disqualification as an extra filter (!runner.ignoresByPage(id)); the ignoreTimedOut report fields sit beside main's pagesTooLarge and tooLargePages in the cli and audit-engine adapters and the controller; output.mdx is main's text plus the meta.ignored sentences; CHANGELOG has the entry under Unreleased. Re-run: the PR's 9 test files (rules, config, report, audit-engine, cli e2e, config-validate, report controller) all pass, plus template-fanout-gates-841 and cookie-flags; tsgo clean in rules, audit-engine, report, core-contracts, config and cli; cli lint and format, make validate and the changelog guard pass.

@nc9

nc9 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

@nc9 nc9 closed this Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants