Skip to content

rule_options: ignore known items, selectors or URLs per rule without disabling it #1262

Closed

Description

@deniskern

Summary

Some findings are right in general but not actionable on a given platform, for one known item or URL. Today the only switch is disabling the whole rule, which also drops the cases that are actionable. Only a few rules take excludePatterns (links/orphan-pages, links/dead-end-pages, crawl/all-noindex-pages).

Examples from our Shopify audits:

  • security/cookie-flags (cookie-httponly, cookie-secure): Shopify sets localization and cart_currency itself; merchant cookies on the same site must stay reported. We keep the rule on and drop the finding in post-processing only when every item is one of those two names.
  • a11y label-name mismatch on Shopify Markets' native country <select>: option text such as "🇩🇪 Deutschland · EUR €" vs aria-label="Land auswählen"; the select is rendered by Shopify.

Request

A generic per-rule option, available on every rule, that drops matching items before the finding is built (and drops the finding when no item is left):

[rule_options."security/cookie-flags"]
ignore_items = ["localization", "cart_currency"]   # matched against item id/value

[rule_options."a11y/label-content-name-mismatch"]
ignore_selectors = ["localization-form select"]

[rule_options."perf/ttfb"]
ignore_urls = ["/apps/"]                            # same pattern forms as excludePatterns

Ignored items could be counted in the check (ignoredCount) so the report stays honest.

Why

We maintain item filters per platform outside squirrel (about 150 lines) and they break silently when item shapes change between releases. In config they would be versioned with the audit and visible in the report.


Triage

Only a handful of rules take excludePatterns, each declared in its own optionsSchema and applied in its own run(): links/orphan-pages, links/dead-end-pages, links/no-contextual-inbound and links/weak-internal-links, all using matchesExcludePattern from packages/utils/src/patterns.ts. The reporter lists crawl/all-noindex-pages too; the list is otherwise accurate and there is no generic mechanism. rule_options is free-form per rule (packages/config/src/schema.ts), validated against the rule's Zod schema, so unknown keys are not a generic channel today. Items are CheckItem (packages/core-contracts/src/index.ts): id, optional label, snippet, sourcePages, meta; there is no value field, so ignore_items would match id (and possibly label). A central filter is feasible: drop matching CheckItems from each check after the rule returns, and drop the check (or turn a fail into a pass) when no item is left, which needs no per-rule code. Risks: rules whose status or message is computed before items are built (counts, details, scores) would disagree with the filtered items, and the streaming and cached rule paths (rule-cache.ts, streaming.ts) must key the cache on the option. Recommend building ignore_items and ignore_urls as a central post-filter with an ignoredCount on the check, scoped to rules whose checks carry items; defer ignore_selectors (needs per-rule selector semantics) and say so. Do not silently drop findings: the ignored count must show in the report.

Acceptance Criteria

Rewritten after the decision of 2026-10-29 (one engine-level ignore, see the spec comment). The original criteria used per-rule ignore_items / ignore_urls options.

  • [[ignore]] entries (rule, optional checks, items, urls, reason) are accepted in squirrel.toml without per-rule schema changes; squirrel config validate rejects an entry with neither items nor urls, an unknown rule, rule_options keys named ignore*, and selectors ("not supported yet").
  • Items whose id or label match an items matcher (exact by default, glob:, regex:) are removed from the check before the finding is counted; a check left with no items becomes a pass with an "N waived" note (denominators and scores stay stable; --no-ignore shows the unwaived result).
  • urls accepts the excludePatterns forms; a page-scope rule is not run on a matching page and emits a visible skipped check (skipReason: "ignored"); items listing sourcePages lose the matching pages.
  • A test with the security/cookie-flags case: localization and cart_currency ignored, a merchant cookie still reported, and the message and counts built from the remaining cookies.
  • Checks record ignored, the report records meta.ignored (waived items and pages per rule and per entry, with reason), and the console, text, markdown, LLM, JSON and HTML reports say that findings were ignored; entries that matched nothing are listed.
  • Scores and counts are computed from the remaining items. Messages: for a rule with messageCountsItems only the first number in the message is replaced with the remaining count; every rule whose check keeps some items then gets an (N ignored) suffix; a check with every item waived reads as a pass, N waived by squirrel.toml: <the original message>; a message that names its items (the platform-cookie note lists cookie names) is not rewritten and may still name a waived item. (Restated from the ctx.ignore opt-in, which was not built.)
  • Changing an entry invalidates the cached results of the rules it targets and no others; a fanned template sibling is not affected by another page's URL ignore; carried (smart audit) findings honour the ignore.
  • Rules marked ignorable: false (only integrity/* and the threat-intel rules) cannot be named by an entry: squirrel config validate errors and the engine skips the entry with a notice.
  • reason is optional and shown in the report and dashboard when present; fields within an entry AND, entries OR.
  • squirrel audit --no-ignore runs without the table (ships in the first PR).
  • With no [[ignore]] entries the output is byte-identical to today.
  • Cloud: website settings accept the same entries (private follow-up), with API-side caps.
  • Selector ignores are tracked in a follow-up issue. (Moot: selectors entries are already implemented, see packages/rules/src/ignore-selector.ts and docs/configuration/ignore.mdx.)
  • Config reference docs (docs/configuration/ignore.mdx), report docs and completions are updated and make validate passes in docs/; the agent skill change is filed as a skills issue.
  • scripts/test-suites.ts --run rules and --run rest pass.

Activity

  1. added
    enhancement
    rules
    size: L
    on Oct 29, 2026
  2. nc9 commented on Oct 29, 2026

    @nc9
    Contributor

    Thanks @deniskern, this is a real gap: disabling a rule is too blunt. We will build a generic per-rule ignore for items and URLs with an ignored count in the report, and track selector ignores separately. Queued.

  3. added theissue type on Oct 29, 2026
  4. nc9 commented on Oct 30, 2026

    @nc9
    Contributor

    Decision (Nik, 2026-10-29): one generic engine-level ignore applied to every rule's results, items and URLs first, selectors later, instead of per-rule options. This is a large change, so a short spec (config shape, matching semantics, interaction with excludePatterns and disabled rules, report wording for ignored findings) comes before implementation.

  5. nc9 commented on Oct 30, 2026

    @nc9
    Contributor

    Spec: one engine-level ignore

    Status: decisions made (below); PR 1 in progress. Decision recorded above (Nik, 2026-10-29): a single generic ignore applied to every rule's results, items and URLs first, selectors later, instead of per-rule options. This replaces the ignore_items / ignore_urls / ignore_selectors option names in the issue body and the acceptance criteria are rewritten to match (below).

    1. Where it plugs in

    Every rule result passes through RuleRunner.runOneRule in packages/rules/src/runner.ts (page rules, site rules, fanned template verdicts, cached replays are all rebuilt from checks that came through it). That is the one choke point, and it is before the streaming tallies, the fold and the score, so an ignored finding is simply never counted as a finding. The filter runs after run() returns and also after the fanned-verdict substitution (a template sibling's checks are cloned onto this page, so a URL ignore must be judged against this page, not the sibling).

    Two things the engine already does that the design must respect:

    • getRuleOptions parses rule_options.<rule> with the rule's Zod schema, which strips unknown keys. So an ignore stored under rule_options would never reach the rule or the cache key. The ignore therefore lives in its own config table and is not read through rule_options.
    • The per-page rule-result cache keys on pageRuleSignature() (resolved options per rule). The ignore entries that target a rule must be part of that rule's signature, or an edited ignore would replay stale results.

    2. Config shape (squirrel.toml)

    A top-level array of tables, one entry per waiver:

    [[ignore]]
    rule   = "security/cookie-flags"          # rule id, or a glob: "a11y/*", "*"
    checks = ["cookie-httponly", "cookie-secure"]   # optional: only these check names of the rule
    items  = ["localization", "cart_currency"]      # optional: item matchers (id, then label)
    urls   = ["/apps/"]                             # optional: page matchers
    reason = "Shopify sets these cookies itself"    # optional, shown in the report
    
    [[ignore]]
    rule = "a11y/label-content-name-mismatch"
    urls = ["/pages/store-locator"]

    Rules for an entry:

    • rule is required. A glob matches rule ids (security/*). * (all rules) needs at least one of items or urls.
    • An entry needs at least one of items or urls. An entry with neither would silently turn a rule off, and [rules] disable already does that, visibly. squirrel config validate rejects it and points at disable.
    • Within one entry the fields AND together (the narrower scope: "ignore the localization cookie on /apps/ pages"). Across entries they OR. Each entry is evaluated on its own so the report can say which entry waived what.
    • reason is free text, shown in the report next to the count (and in the dashboard). Recommended, not required.
    • selectors is reserved: validated as "not supported yet" with a message, never silently accepted (see phase 3).
    • rule_options keys named ignore, ignore_items, ignore_urls, ignore_selectors are reserved. squirrel config validate already reports unknown option names (rule-options-check.ts); add a specific message pointing at [[ignore]].
    • The table is read from squirrel.toml by the CLI and from the website settings by the cloud (section 9). One source per surface keeps "what was ignored" answerable.

    3. Matcher forms

    Both items and urls take strings:

    • urls: exactly the matchesExcludePattern forms from packages/utils/src/patterns.ts (substring of the path, /exact-segment/, regex:...:flags), so one learned syntax covers excludePatterns, the paths option of fix(cli): offline level snapshot reports what ran; unreachable start URL writes a report, exit 5 #1275 #1269 #1297, and this. Matched against the page the finding is on.
    • items: exact match by default (not substring: localization must not waive localization_extra). glob: prefix for * and ? wildcards, regex: prefix for a regular expression. Matched against item.id, then item.label; a match on either waives the item. There is no value field on CheckItem, so "id/value" in the issue means id and label. snippet is deliberately not matchable (it is page content and can be large).
    • All forms are compiled once per run. Regexes are capped at 200 characters, rejected when they contain nested quantifiers ((a+)+, (a*)*), tested with a bounded input (item ids are already clamped to the medium-string cap by clampCheckItemIds, URLs to maxUrlLength) and run under the existing rule time budget. This matters more here than for excludePatterns because the cloud accepts the config from a dashboard form (section 9).

    4. Matching semantics (what an entry does to a result)

    For a rule whose id matches the entry's rule (and a check whose name is in checks, when given):

    1. Page match (urls present): if the rule is page-scope and ctx.page.url matches, the rule is not run for that page. The engine emits one skipped check with skipReason: "ignored", details.foldKey: "ignored" and the entry's reason, exactly like the existing soft-404 and noindex gates in runOneRule. Skipped checks are excluded from tallies and score, which is the right model for "this page is waived for this rule". It also saves the work.
    2. Item match: for each check with items, drop the items that match (items matchers, and, when urls is also present, whose sourcePages all match; a page-scope item's page is ctx.page.url). If an item lists several sourcePages and only some match urls, the matching pages are removed from the item and the item stays while it has a page left.
    3. A check that had items and has none left is replaced by a pass check with the same name, message N waived by squirrel.toml: <check message> and the ignored count. It is not deleted: the rule ran and found nothing left to act on, and a deleted check would change the page's check count.
    4. A check that keeps some items keeps its status, gets the remaining items, and records ignored. Messages and details counts were built by the rule from the full list ("3 cookies lack HttpOnly"), and a central filter cannot rebuild them. Two measures: the engine appends (N ignored) to the message, and a rule can opt into exactness by declaring meta.ignoreAware and receiving ctx.ignore.filter(items) so it builds the message from the remaining items. Phase 1 migrates security/cookie-flags (the motivating case) and any rule whose check message embeds an item count; the rest keep the suffix. This changes the issue's criterion "messages computed from the remaining items" from every rule to the migrated rules, plus an honest suffix for the others.
    5. A check without items and without a page (a pure site-wide value check) is only affected by rule entries with no items/urls, which is rejected, so such checks are never ignored. The way to silence one is disable.
    6. Checks whose status is skipped or pass are never altered.

    5. Interaction with what exists

    Existing Relation
    [crawler] exclude / excludePatterns (crawl scope) Not crawled at all, so not in page counts, link graphs or any rule. ignore.urls crawls and counts the page, and waives findings. Docs say which to use: exclude for "never touch", ignore for "touched, finding not actionable".
    links/orphan-pages etc. excludePatterns option Stays. It changes the analysis (a page removed from the link graph), which a post-filter cannot reproduce. Docs point to it as the exception.
    [rules] disable / rule_options.<rule>.enabled Rule off: not run, not counted. An [[ignore]] naming a disabled rule is reported by config validate as unused.
    rules.enable allowlists Unchanged: ignore applies only to rules that ran.
    Per-rule options (paths, thresholds) Unchanged.
    Smart audits (carried findings) Carried findings are re-injected from the per-page store. The ignore must be applied to them too, or a waived item would reappear from a previous audit. To confirm in phase 1 (the carry path is in audit-engine); if it bypasses runOneRule, the same filter is applied at injection.

    6. Reporting, score and honesty

    Nothing is dropped silently.

    • Per check: ignored?: { items: number; pages: number; entries: number[] } (indexes into the config list), set whenever the engine removed something. Additive on CheckResult, so older readers ignore it.
    • Per report: meta.ignored (JSON) with total waived items, waived pages (skipped for ignore), counts per rule and per entry, and each entry's reason. Computed from the streaming tallies (add ignored counters to RuleTally) so it does not need the pages resident.
    • Entries that matched nothing are listed: Ignore entry 2 (a11y/select-name) matched nothing. This is the guard against the rot the reporter described (filters that "break silently when item shapes change").
    • Renderers: console and text scan-details line Ignored by squirrel.toml: 3 findings on 2 rules, 5 pages (see --verbose); per-issue suffix (2 ignored); markdown, LLM (an <ignored> element with the entries and reasons, so an agent knows the report is filtered and is not tempted to "fix" a waived item) and HTML get the same data. --verbose lists each waived item with its entry.
    • Score: computed from what remains. A fully waived check counts as a pass, a waived page as skipped (excluded). The score is therefore higher than without the ignores, by design, and the report says so in the same line. --no-ignore runs the audit with the table disabled for a comparison run and for the question "what did we waive?". --fail-on is evaluated on the filtered report, like every other gate.
    • Waiving is a user decision, so only the compromise-detection class (integrity/* and the threat-intel rules, where an ignore could hide a compromised site) gets meta.ignorable: false: an entry naming one is a config validate error and the engine skips it with a notice. Everything else is ignorable, including security/leaked-secrets.

    7. Cache and the other readers of results

    • Include the entries that target a rule (their rule, checks, items, urls, in normalised form) in that rule's pageRuleSignature() options, so editing an ignore invalidates exactly the rules it touches and not the whole cache. The fingerprint hash of the rules source is not enough: it covers code, not config.
    • Stored rule_results are post-filter. squirrel report on an old audit shows what that audit's config waived; changing the config does not re-open old results (re-run, or --refresh). Documented.
    • Fanned template verdicts: the filter runs after the clone (section 1), and the signature test must pin that a URL ignore on one cluster member does not leak to its siblings.

    8. Selectors (phase 3)

    ignore_selectors needs a defined meaning per rule. Proposal: CheckItem gets an optional selector (a CSS path the rule already computes for element findings) and selectors entries match it with the same exact/glob/regex forms. Rules that cannot say where in the DOM an item is simply cannot be waived by selector, and config validate says so per rule (a11y/label-content-name-mismatch supports selectors, security/cookie-flags does not). The a11y label-mismatch example in the issue is the first consumer. Until then selectors is rejected with "not supported yet" rather than accepted and ignored (the issue's own criterion).

    9. Cloud

    A cloud audit does not read squirrel.toml; it builds its config from the plan, the website settings and the run (buildCloudConfig merges disabledRulePatterns into rules.disable; crawl exclude patterns live in website_settings.exclude_patterns). To honour the same waivers:

    • Private: a nullable JSON column website_settings.ignore (migration in UserAuditStore.ensureSchema), validated with the same schema as the TOML table (shared Zod schema in @squirrelscan/config), exposed on the website settings API and the MCP get_website_settings / update_website_settings, edited in the dashboard crawl-settings page (a table with rule picker, items, URLs, reason), and merged into the run config next to disabledRulePatterns. Item and entry caps (50 entries, 100 items per entry, 200 characters per matcher) are enforced at the API, because this is user input executed in our workers.
    • CLI cloud-published runs already carry the filtered results (the filter ran locally); the published report carries meta.ignored, and the dashboard shows the line. A website-level ignore and a local squirrel.toml ignore are separate: a local run honours squirrel.toml, a hosted/scheduled run honours the website settings. squirrel config can print the website's list (squirrel config show --cloud, phase 4) so the two do not drift unnoticed.

    10. Docs and skill

    • docs/configuration/ignore.mdx (new: shape, matchers, semantics, examples for the Shopify cases), a section in docs/configuration/rule-options.mdx pointing at it and at excludePatterns vs ignore, report docs for meta.ignored (docs/configuration/output.mdx), docs/cli/audit.mdx for --no-ignore, completions, the rule pages of migrated rules.
    • Agent skill: needs a change (agents must know a report can be filtered, and read ignored before proposing fixes for a finding). A private issue labelled skills is filed when the first PR is opened.

    11. Test plan

    • Pure matcher module (packages/rules/src/ignore.ts): every matcher form, case, glob escaping, regex rejection (nested quantifiers, length), bounded input, AND within an entry, OR across entries, checks scoping.
    • Runner: page skip with foldKey; item drop; all-items-dropped becomes pass; partial keeps status plus suffix; fanned sibling not affected; skipped/pass untouched; non-ignorable rule refused.
    • The cookie case from the issue as a failing-first test: localization and cart_currency ignored, a merchant cookie still reported, message counts correct (migrated rule).
    • Cache: editing one entry invalidates only the rule it targets (pageRuleSignature test), and a warm run with an unchanged ignore replays.
    • Streaming and resident engines both, plus the canonical golden with an ignore applied.
    • Reporting: tallies, meta.ignored, unused-entry notice, each renderer, --no-ignore.
    • Config: squirrel config validate for every rejection, reserved rule_options keys.
    • Smart-audit carry path (section 5).
    • Property test: with an empty [[ignore]] the output is byte-identical to today (no result changes, no new fields).

    12. Phases and PR split

    1. Public PR A (size L): config schema and validation, matcher module, runner integration (page skip, item filter, pass replacement, suffix), ignored on checks, signature/cache, meta.ignored plus the minimal console/JSON line, docs, tests. Items and URLs only. security/cookie-flags migrated to ctx.ignore.
    2. Public PR B: renderers (markdown, LLM, HTML), verbose listing, unused-entry notice, --no-ignore, completions, migrate other count-in-message rules.
    3. Private PR: website_settings.ignore, API and MCP, dashboard editor, cloud run config merge, dashboard report line. Depends on A for the shared schema.
    4. Public PR C: selectors (CheckItem.selector, per-rule support list).
    5. Skill update (squirrelscan/skills) after A.

    No migration for existing users: the table is new, rule_options is untouched. An empty list changes nothing.

    13. Decisions (2026-10-30)

    1. ignorable: false only for compromise detection: integrity/* and the threat-intel rules. Everything else is ignorable, including security/leaked-secrets. An entry that names a non-ignorable rule is a squirrel config validate error, and the engine skips it with a notice if it gets through.
    2. A fully waived check is a pass with an "N waived" note, so denominators and scores stay stable. --no-ignore shows the unwaived result. (Replaces the pass-or-skip question; a waived PAGE, where the rule is not run at all, remains a visible skip.)
    3. reason is optional and is shown in the report and dashboard when present.
    4. Fields within an entry AND together; entries OR.
    5. --no-ignore ships in the first PR.

    Acceptance criteria (replaces the checklist above, per the decision)

    The issue body is updated to match.

  6. nc9 commented on Oct 30, 2026

    @nc9
    Contributor

    Decisions (Nik, 2026-10-30): (1) ignorable: false only for compromise detection (integrity/* and the threat-intel rules); everything else is ignorable, including security/leaked-secrets. (2) A fully waived check is a pass with an 'N waived' note, so denominators and scores stay stable; --no-ignore shows the unwaived result. (3) reason is optional, shown in the report and dashboard when present. (4) AND within an entry, OR across entries. (5) --no-ignore ships in the first PR. Spec comment and acceptance criteria updated; PR 1 (config, engine hook, cache, reporting, --no-ignore) is next.

  7. nc9 commented on Oct 31, 2026

    @nc9
    Contributor

    Verified against main after v0.0.148 ([[ignore]] landed). Met and ticked: criteria 1 to 4 (validation, item and URL waiving, the cookie example), 8 (integrity/* rules are not ignorable), 10 (--no-ignore) and 11 (no change without entries). Open: criterion 5 (the HTML report lists no unused entries), criterion 6 (the message rewrite is the shipped mechanism, no ctx.ignore opt-in; the platform-cookie info message still names waived cookies after a partial waiver), criterion 7 (carried smart-audit findings do not honour an ignore; the docs say so), criterion 9 (reason is not shown in the console, text, markdown or HTML reports), criterion 13 (no public follow-up issue for selectors yet), and the hosted parts of 9 and 12. Criterion 14 and 15 are process items. Leaving this open for those.

    nik

  8. nc9 commented on Nov 12, 2026

    @nc9
    Contributor

    Criterion 6 restated to match what shipped (rules with messageCountsItems rewrite their count; other rules keep their text with an (N ignored) suffix; a message naming its items may still name a waived item) and ticked; criterion 13 ticked as moot (selectors are already implemented). Still open: criterion 7 (carried smart-audit findings do not honour an ignore; the report warns with carriedStale), criterion 12 (cloud, private), the skills issue and the suite runs; the HTML/console/text/Markdown reason lines are in draft PR #1791.

    nik

  9. nc9 commented on Nov 13, 2026

    @nc9
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementrulessize: L

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions