Repository navigation
feat(cli): audit where a start URL redirects, with consent for another site (#1281) - #1282
Merged
Merged
Conversation
…r site (#1281) Resolve the start URL's redirect chain before anything is named, estimated or crawled: one request per hop through the egress guard, capped at 5 hops. A same-site redirect is followed silently. A cross-domain one needs consent: a TTY prompt, --follow-redirect or [crawler] follow_redirect; -y does not imply it. Otherwise exit 4 with a redirected report naming the destination, the chain and the re-run command. Loops, long chains and refused hops are never followed. A followed redirect is recorded as originalUrl and redirectChain in every output format and survives a report rebuild. The MCP audit_website tool answers confirmation_required with the destination until followRedirect: true. Signed-off-by: Nik Cubrilovic <[email protected]>
…-domain, escape outputs (#1281) Print and record each chain URL as scheme, host, port and path only; the re-run command uses the URL the user typed. Classify a chain cross-domain when any hop leaves the registrable domain. Percent-encode markup characters in site-chosen URLs, emit real HTML for the html outcome, and name a refused non-http hop by scheme. Signed-off-by: Nik Cubrilovic <[email protected]>
) Signed-off-by: Nik Cubrilovic <[email protected]>
…te (#1281) Signed-off-by: Nik Cubrilovic <[email protected]>
Signed-off-by: Nik Cubrilovic <[email protected]>
…cument the redacted audit target (#1281) Signed-off-by: Nik Cubrilovic <[email protected]>
|
Reviewed the resolver (
I found no security problems in what I read. Every hop goes through the existing egress guard, only http and https are followed, and Location URLs are redacted before they are printed. |
This was referenced Oct 30, 2026
feat(cli): audit --max-duration stops at a wall-clock budget and writes a partial report #1271
#1324
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1281 (does not close it: the cloud half below is a private follow-up).
squirrel audit bit.ly/abcused to score the shortener. The start URL's redirect chain is now resolved before anything is named, estimated or crawled, and the destination is the audit target.Behaviour
bit.ly/x redirects to https://example.com/pricing. Audit example.com instead? [Y/n]). Non-interactive:--follow-redirector[crawler] follow_redirect = true(--no-follow-redirectoverrides the config). Otherwise nothing is crawled or scored: exit 4, statusredirected, a report naming the final URL, the chain and the re-run command, in console/text/markdown/llm/xml/json.-yis not an input to the decision (pinned bytests/cli/audit-start-redirect-e2e.test.tsand a wiring test).reason:loop,too-many,refused).egressGuardedSend, no new guard). A public start URL may not redirect into a private/link-local/metadata address; a local start URL may redirect around the local network, never to metadata. Resolved under--offlinetoo (the one request per hop the issue allows); the destination is then audited offline.baseUrlare the destination's. A followed redirect is recorded asoriginalUrl+redirectChain(JSONmeta, scan notes in text/markdown/html/console,<start-redirect>in llm/xml), persisted in the scan scope sosquirrel reportrebuilds keep it, and carried through slim-JSON round trips (bounded, canonicalised).audit_website:confirmation_required(reason: "redirect") with the destination until called withfollowRedirect: true(or the config key).confirm: truedoes not do it.Contracts for the private half (cloud register/run, hosted MCP, website alias)
All in
@squirrelscan/core-contracts/seed-redirect(leaf module, one in-package import) unless noted:MAX_SEED_REDIRECT_HOPS = 5,EXIT_CODE_REDIRECTED = 4SeedRedirectHop { url, status },SeedRedirectResolution { kind: none | same-site | cross-domain | loop | too-many | refused, originalUrl, finalUrl, chain, refusal? }SeedRedirectRecord { originalUrl, redirectChain }: what a followed run carries; cloud: website row = final domain,originalUrlstored as the aliasSeedRedirectedOutcome { status: "redirected", reason, originalUrl, finalUrl, redirectChain, rerunCommand, message }andredirectedOutcome(resolution): the answer for a run that was stopped (hosted MCP:confirmation_requiredfor cross-domain,redirectedfor the rest)AuditReport.originalUrl?/redirectChain?,ScanScope.startRedirect?; chain = every URL requested in order with the status each answered, last entry is the destinationresolveStartRedirect(url, { transport?, policy?, pin?, userAgent?, timeoutMs?, maxHops? })from@squirrelscan/crawler/seed-redirect;isSameSitenow exported from@squirrelscan/crawler/frontierrenderRedirectedOutcome(outcome, format),followedStartRedirect(report),startRedirectLine(report)from@squirrelscan/report[crawler] follow_redirect?: boolean. The cloud request should carryfollow_redirect(boolean) next to the url; the API resolves with the same function server-side.Docs, completions, changelog
docs/cli/audit.mdx(flag rows, new "Start URLs that redirect" section, exit code4),docs/cli/mcp.mdx,docs/configuration/crawler.mdx,docs/configuration/output.mdx, bash/zsh/fish completions, CHANGELOG bullet under## [Unreleased].make validateindocs/passes.Agent skill
The agent skill needs a change: an agent now meets exit 4 and a
redirectedreport, and must not add--follow-redirectwithout the user confirming the destination (it is the redirector's choice, not the user's). Private issue squirrelscan/repo#3659 (labelskills, with acceptance criteria) tracks it.Verified
tsgo --noEmit(cli, core-contracts, crawler, report, config),bun run lint,format:checkhttp->https->www, loop, 6 hops, private IP / metadata / non-http refused, local start, unreachable destination), decision + prompt tests, report renderers (hostile URLs neutralised), slim JSON round trip, MCP tool, and an end-to-end subprocess test against local fixtures (localhostvs127.0.0.1:-yalone exits 4 and the destination is asked once and never crawled;--follow-redirectand the config key audit it; same-site is silent)--follow-redirectJSON report withmeta.originalUrl/redirectChain,squirrel reportrebuild keeps the note, redirect to169.254.169.254refused with exit 4, real TTY (pty) prompt shows the issue's copy and declining exits 4--follow-redirect)Not covered
follow_redirect, hosted MCP handshake): private PR.squirrel crawl,squirrel analyzeand MCPquick_checkstill take the URL as given (not in the issue's scope).Review round 1 (head after this push)
htmloutcome is real escaped HTML; a refused non-http hop is named by scheme only.Private follow-up still open for #1281
Website created under the final domain with the original URL as an alias, cloud register/run
follow_redirect, and the hosted MCPconfirmation_requiredhandshake.