Skip to content

feat(ci): CLI and action step that audits a deployed URL in the cloud and fails on findings new since the previous audit #1776

Closed

Description

@nc9

The CI leg of the always-on posture (private tracker squirrelscan/repo#3969). The private half is done: the comparison endpoint GET /v1/websites/{websiteId}/audits/compare takes fail_on=error|warning|info and returns a gate (status, newAtOrAbove, resolved, notCompared, reason) computed over every finding, plus comparison.newBySeverity. It is in the private PR (draft); a cloud API key (audits:read, audits:write) reaches it today.

This issue is the public half: let a CI job say "audit this deployed URL in the cloud as website X, wait, and fail if the audit has findings new since the previous completed audit of X at or above a severity".

Design (why)

No new server endpoint to start and wait. The CLI (and the action around it) uses the endpoints that exist: POST /v1/agent-runs (with websiteId), poll GET /v1/agent-runs/{id} to a terminal state, then GET /v1/websites/{websiteId}/audits/compare?head=<run>&fail_on=<sev>. The gate is evaluated server-side so every client (CLI, action, GitLab, plain curl) reads new-versus-previous the same way, with the comparison's own coverage honesty (not_crawled and not_checked are neither new nor resolved).

Ready material is in the private repo under plans/3969-ci-gate/ (ask the maintainer for a copy if you cannot read it): public-openapi-compare.patch (the OpenAPI path and the AuditComparison and CompareGate schemas, applied to docs/openapi.json; the private repo's guard needs docs/openapi.json byte-identical, so land this first) and ci-guide-section.mdx (the docs/guides/ci.mdx section, a curl and jq workflow that works without any CLI change).

Acceptance Criteria

  • docs/openapi.json gains GET /v1/websites/{websiteId}/audits/compare with fail_on, head, base, include and limit, and the AuditComparison and CompareGate schemas, from the patch; make validate in docs/ passes. The monorepo's apps/api/openapi.json is then synced to it (private PR, after this lands).
  • docs/guides/ci.mdx has an "audit after deploy and fail on new findings" section (the draft), no credentials in examples, and the page no longer says there is no baseline gating without pointing at this section.
  • A documented CLI command or action step (suggested: squirrel audit --cloud <url> --website <id> --fail-on-new error, or a squirrel ci command; implementer may choose and say why) starts the cloud audit with an org API key, waits, calls the compare endpoint with fail_on, and exits non-zero when gate.status is fail.
  • The exit codes stay the existing distinct ones: 2 for the new-findings gate failing, 3 blocked, 5 unreachable, 1 operational error. A blocked or unreachable site never exits 2. gate.status: not_evaluated is reported with its reason and is not a pass: the exit code is 1.
  • Output lists each new finding (rule id, severity, page or item) and each resolved finding, the gate.notCompared counts, a link to the report, and the credits the run used (read from GET /v1/credits before and after, or the run's ledger entries). Resolved findings never fail the job.
  • The first audit of a website prints that there is no baseline and exits 0.
  • The run appears in the website's audit history in the dashboard (it is a cloud run, not a local CLI audit).
  • Verified on squirrelscan/nut-shop (nutshop.squirrelscan.com): bun run fault on broken-internal-link, deploy, run the step: the job fails and names the fault's finding; fault off, re-run: it passes and lists the finding as resolved.
  • Shell completions (repo-public/apps/cli/src/self/completion.ts) and the CLI docs page are updated for any new command or flag; the PR says whether the squirrelscan agent skill needs a change.

Activity

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

    @nc9
    ContributorAuthor
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

    ciclienhancementsize: L

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions