Skip to content

feat(rules): a rule's passing and failing checks are linked, so a consumer can tell when a reported finding has been fixed #1741

Closed

Description

@nc9

A consumer that compares two audits (a diff, an issue tracker, an agent deciding whether its fix worked) needs to know when a finding from the first audit is gone because it was fixed. The check names in rule results do not make that possible today, because rules name their outcomes inconsistently:

So "the same check now passes" is not a test anyone can apply across rules. Seen on the public demo site nutshop.squirrelscan.com (repo squirrelscan/nut-shop): a leaked key was removed, the site was re-audited in full, and a comparison of the two audits could not tell that the finding was fixed.

The dependable signal is: the rule ran over the same scope and did not report the finding. That needs the report to say, per rule, that it ran and what it covered, and it needs rules to be consistent about what a clean run looks like.

What is wanted

  • A convention, enforced by a test over every rule: a rule that ran always emits at least one check, including when it finds nothing (a pass or an informational check), so "ran and clean" is never an empty list.
  • Each rule declares, in its metadata, the check names it can emit and which of them are problem outcomes and which are clean outcomes, so a consumer can map a failing check to the clean check that supersedes it without guessing from names.
  • The report records, per rule, whether it ran, was skipped or timed out, and the scope it covered, in a form the comparison and the cloud can rely on (most of this exists as notChecked; the gap is the per-rule positive statement).
  • Existing check names are kept wherever possible; this is additive metadata plus a few rules gaining a clean check.

Acceptance Criteria

  • Every rule that runs emits at least one check; a test runs each rule on a clean fixture and fails on an empty checks list.
  • Rule metadata lists the rule's check names with their outcome class (problem or clean), and a test fails when a rule emits a check name that is not declared.
  • For security/leaked-secrets and content/dev-leakage, the metadata links the problem checks to the clean check, and content/dev-leakage emits a clean check when it finds nothing.
  • squirrel report --diff (and any other comparison in this repo) treats a finding as fixed when the rule ran over the same scope and no longer reports it, using the declared linkage, and treats a rule that did not run or a page that was not crawled as not compared.
  • The JSON report format documentation describes the linkage and how to decide "fixed" from two reports.
  • The rule docs pages list each rule's check names by outcome class (generated from the metadata).
  • No existing check name is renamed without a CHANGELOG entry.

Activity

  1. added
    enhancement
    size: M
    rules
    on Nov 11, 2026
  2. added theissue type on Nov 11, 2026
  3. nc9 commented on Nov 11, 2026

    @nc9
    ContributorAuthor

    Sizing, measured on a real full-audit report (301 rules ran of 326 built in: 212 page, 114 site).

    • Only 9 rules emit an empty checks list: content/date-agreement, schema/rating-scope, and 7 in integrity/ (brand-impersonation, cloaking, fake-auth-overlay, kit-signature, known-malicious-url, obfuscated-script, seo-doorway). One report, so the real count is probably 10 to 25, not hundreds.
    • Another 39 rules have checks but none that is a pass or info (24 only skipped, 12 only warn, 2 only fail). They are not empty, but "clean" is not distinguishable, so they need a declared clean outcome.
    • The content/dev-leakage claim above is stale: it already emits dev-leakage:pass when clean. security/leaked-secrets emits leaked-secrets:pass beside the leaked-secrets-critical problem check, so that one needs linkage, not a new check.
    • squirrel report --diff (apps/cli/src/reports/diff) treats a fingerprint that is absent from the current report as removed. It never asks whether the rule ran over the same scope, so a rule that did not run reads as fixed.

    Plan, all additive:

    1. This issue (P1): meta.checks ({name, outcome: problem | clean | skipped, clears}), a clean check for the empty rules, linkage for leaked-secrets, hsts, x-frame-options and csp, and a contract test with an allowlist baseline that ratchets down.
    2. P2: the report records per rule whether it ran, was skipped or timed out, and the scope it covered; format docs and generated rule-docs check lists.
    3. P3: report --diff decides fixed as "the rule ran over the same scope and no longer reports it" and adds a not-compared bucket. The cloud mirror is private #3993 / #3997.

    nik

  4. nc9 commented on Nov 12, 2026

    @nc9
    ContributorAuthor

    Not closed after v0.0.179 (https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.179). meta.checks exists, nine silent rules emit checks and the named rules declare their linkage. Still open: a test that every rule emits a check on a clean fixture, declarations for the remaining rules, diff logic that reads the linkage, the report docs and the generated check-name lists in the rule docs. The change that shipped is 0e080dd.

    nik

  5. nc9 commented on Nov 21, 2026

    @nc9
    ContributorAuthor

    Graded against current main (43e18bf). Tests run by path: rule-check-declarations, rule-clean-run-checks, rule-clean-run-site-checks (10 pass, 0 fail), diff-not-compared-1748 (31 pass, 0 fail), bun scripts/rule-checks.ts --check in docs (exit 0).

    • Every rule that runs emits a check: rule-clean-run-checks.test.ts:39 (page) and rule-clean-run-site-checks.test.ts:56 (site) fail on an empty list outside a shrinking baseline (6 page and 20 site exemptions).
    • Declared check names with outcome class, and an undeclared name fails: rule-check-declarations.test.ts (declaration shape, undeclared-rule baseline of 311, only shrinks); rule-clean-run-checks.test.ts:56 and rule-clean-run-site-checks.test.ts:75 fail on an undeclared name a declared rule emits on a clean run.
    • leaked-secrets and dev-leakage linkage, dev-leakage clean check: rule-check-declarations.test.ts "the rules this issue names declare their problem to clean linkage"; content-dev-leakage.test.ts.
    • report --diff uses the linkage and has a not-compared bucket: apps/cli/src/reports/diff/index.ts:496-512 and 575-579, not-compared.ts; diff-not-compared-1748.test.ts.
    • JSON docs: docs/cli/report.mdx:266 and configuration/output.mdx "per-rule status and deciding fixed".
    • Rule docs by outcome class: docs/scripts/rule-checks.ts generates "Check names by outcome" (50 rule pages); --check passes.
    • No rename without a CHANGELOG entry: CHANGELOG.md:364 (hsts and x-frame-options rename, fix(rules): security/hsts and security/x-frame-options use one check name for every outcome, so "missing" and "present but weak" cannot be told apart #1737); the rest add checks and rename none (CHANGELOG.md:345).

    Shipped in #2179 and 0e080dd. The remaining baselines are tracked in #2218.

    nik

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: M

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions