Skip to content

fix(cli): preserve deep audit start URL - #1385

Closed
WilliamK112 wants to merge 4 commits into
squirrelscan:mainfrom
WilliamK112:codex/deep-url-requested-1369-v2
Closed

WilliamK112 wants to merge 4 commits into
squirrelscan:mainfrom
WilliamK112:codex/deep-url-requested-1369-v2

Conversation

@WilliamK112

@WilliamK112 WilliamK112 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • disclose that a deep start URL audits the whole origin and crawl the requested page first
  • include the sanitized deep URL as meta.requestedUrl beside meta.baseUrl in JSON reports
  • preserve origin-only behavior, document the distinction, and cover the small-page-budget case

Closes #1369.

Verification

  • bun test ./apps/cli/tests/cli/audit-deep-url-1369-e2e.test.ts ./apps/cli/tests/cli/audit-stdout.test.ts ./apps/cli/tests/squirrel-home-guard.test.ts ./packages/report/tests/json-pages-1260.test.ts (17 pass)
  • bun run --filter @squirrelscan/core-contracts typecheck
  • bun run --filter @squirrelscan/crawler typecheck
  • bun run --filter @squirrelscan/report typecheck
  • bun run --filter @squirrelscan/cli typecheck
  • bun run docs:check
  • bun run scripts/test-suites.ts --check
  • changed-file lint and detect-secrets 1.5.0 scan

Checklist

  • I added or updated tests for behavioral changes.
  • I did not include secrets, customer data, or incompatible third-party material.
  • Every commit includes a DCO Signed-off-by line (git commit -s).

Docs: updated docs/cli/audit.mdx and docs/configuration/output.mdx. Skill: none.

nc9 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed head: 8cbcada

Verdict: pending maintainer review. Thanks for the PR. The approach is sound and the tests are targeted, but there are a few findings below. There is no earlier maintainer review on this PR.

  1. Docs placement (medium): in docs/cli/audit.mdx the new "Deep start URLs" heading is inserted in the middle of the "Start URLs that redirect" section. The paragraph that follows it ("The hops are requested before the credit check...") is about redirect hops, and it now reads as part of "Deep start URLs". Please move the new section after that paragraph.
  2. Where requestedUrl comes from (medium, unverified): in apps/cli/src/reports/reconstruct.ts, requestedDeepUrl reads crawl.originalUrl. As the output docs describe it, originalUrl is recorded when a cross-site redirect was followed. For a plain deep URL with no redirect, I could not see in the diff where it gets set. The e2e test expects meta.requestedUrl in that case, so please point to where originalUrl is populated, or confirm the e2e test passes.
  3. Schema docs (low): docs/configuration/output.mdx still says "1.1 added the opt-in pages list" in the always-present paragraph. The 1.2 note was added as a separate line above it, so please fold them into one description. The meta JSON sample comment is good.
  4. Seed ordering (low): in packages/crawler/src/core/crawler.ts, deepSeed is computed from seedResolution.seedUrl, while the CLI notice uses the user's URL before redirects. If a deep URL redirects to a site root, or the reverse, the notice and the crawl order can disagree. Please add a test or a note for that case.
  5. Conventions: DCO check passes, CHANGELOG [Unreleased] and docs are updated, and no runtime dependency is added. I found no regex or unbounded-loop concerns in the diff.
  6. CI: DCO, changelog guard and file classification pass. Format/lint/typecheck, docs build, secret scan and CodeQL were still running at review time.

nik

@WilliamK112
WilliamK112 force-pushed the codex/deep-url-requested-1369-v2 branch from 8cbcada to 556aa58 Compare October 30, 2026 23:19
@WilliamK112

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed review. I pushed 556aa58c and rebased onto current main.

  1. Moved Deep start URLs after the redirect-hops paragraph.
  2. Confirmed CrawlMetadata.originalUrl is populated for every crawl: packages/crawler/src/core/crawler.ts passes userProvidedUrl to storage.createCrawl, independently of the report-only cross-site redirect field. I clarified that distinction beside requestedDeepUrl; the plain deep-URL e2e test passes.
  3. Folded the 1.1 and 1.2 schema history into one description.
  4. Preserved the user-supplied URL across silent same-site redirects, prioritized the resolved seed when either side is deep, and added e2e cases for deep-to-root and root-to-deep redirects.

Focused validation now has 19 passing tests. Format, lint, four affected-package typechecks, docs checks, test-suite wiring and detect-secrets also pass locally.

nc9 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed head: 556aa58

Verdict: pending maintainer review. Thanks for the quick turnaround. All four findings from the earlier review look addressed in the diff; the items below are what remains. CI "CLI tests" was still running at review time, everything else was green.

Earlier findings:

  1. Docs placement: addressed. docs/cli/audit.mdx now puts "Deep start URLs" after the redirect-hops paragraph.
  2. Source of originalUrl: addressed. The new comment in apps/cli/src/reports/reconstruct.ts (requestedDeepUrl) explains that CrawlMetadata.originalUrl is the user-supplied URL on every crawl, separate from the report's cross-site redirect field. I did not re-run the e2e test; please let the CLI tests job finish.
  3. Schema docs: addressed. docs/configuration/output.mdx now describes 1.1 and 1.2 in one sentence. Small nit: the next sentence, "A report without it predates 1.1", now reads as if it refers to meta.requestedUrl. Please say "A report without meta.schemaVersion".
  4. Seed ordering: addressed. apps/cli/src/cli/commands/audit.ts keeps the user's URL across silent same-site redirects (sameSiteRequestedUrl), the crawler prioritises the seed when either side is deep, and the e2e file gains deep-to-root and root-to-deep cases.

New findings:

  1. Low, packages/crawler/src/core/crawler.ts (prioritizeSeed): new URL(userProvidedUrl) and new URL(seedResolution.seedUrl) are unguarded. Both come from validated URLs today, but a throw here would abort the crawl start, so a try/catch or a shared helper would be safer.
  2. Low, apps/cli/src/cli/commands/audit.ts (sameSiteRequestedUrl): the value passed to the crawler as the user's URL is redactStartUrl(...), so crawl metadata stores a redacted URL for same-site redirects but the raw one otherwise. Please confirm that difference is intended, or add a test for a start URL with a query string.
  3. Low, crawler.ts: the "Origin-only audits retain the old order" comment is accurate, but there is no test for the !prioritizeSeed path ordering. The existing sitemap tests may cover it; a pointer would help.

Conventions: DCO passes, CHANGELOG [Unreleased] and docs are updated, no new runtime dependency, and I found no regex or unbounded-loop concerns. Whether the crawl-order change in the shared crawler is acceptable for the hold list is a maintainer call.

nik

@nc9

nc9 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Thanks for this, it covers every criterion on #1369 and the e2e for the small page budget case is exactly what we wanted.

We are going to take it into the next release by cherry-picking your three commits (so the authorship stays yours) with one small follow-up commit on top. Two things from our review that the follow-up will handle, so you do not need to change anything:

  • crawl.originalUrl now carries the pre-redirect URL for same-site redirected starts (http to https, apex to www). entityMapSite() reads it, so analyze and report reassembly could name a different site than the audit did. We will carry requestedUrl separately and leave originalUrl as it was.
  • The seed reorder also fires when an origin-only start redirects to a deep URL (for example / to /en/). It should key on the URL the user typed only.

We will comment here with the release when it ships.

nik

@WilliamK112

Copy link
Copy Markdown
Contributor Author

Addressed the remaining review notes in 6dcb284f:

  • Clarified the schema sentence to name meta.schemaVersion explicitly.
  • Replaced the unguarded URL parsing in seed-priority selection with a safe helper.
  • Kept same-site redirect requests in the same normalized form as non-redirected starts; report reconstruction still redacts userinfo, query and fragment. The deep-to-root e2e case now starts with a query string and verifies the public meta.requestedUrl stays redacted.
  • Added an origin-only e2e assertion against the persisted frontier to verify sitemap insertion still wins seed dedup on the !prioritizeSeed path.

Validation: 5 focused e2e tests pass; workspace formatting, CLI lint, CLI/crawler typechecks, and docs checks pass locally.

@WilliamK112

Copy link
Copy Markdown
Contributor Author

Thanks, understood. Our messages crossed while I was finishing the automated review nits. Please continue with the three commits you identified; 6dcb284f is only additional review polish, and I will leave the branch alone for your follow-up.

nc9 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed head: 6dcb284

Verdict: pending maintainer review. This head adds one commit (6dcb284f) on top of the three the maintainer is cherry-picking. It resolves the three low findings from the last review, but the two maintainer follow-ups from the 2026-10-31 comment are still open on this branch.

Earlier review items:

  1. prioritizeSeed unguarded new URL: addressed. hasDeepPath in packages/crawler/src/core/crawler.ts catches and returns false.
  2. Redacted vs raw start URL for same-site redirects: addressed by making both paths store the normalized, unredacted URL (apps/cli/src/cli/commands/audit.ts, sameSiteRequestedUrl). Output is redacted in requestedDeepUrl (apps/cli/src/reports/reconstruct.ts) and in the notice. The deep-to-root e2e now starts with ?ref=campaign and checks that meta.requestedUrl has no query.
  3. Test for the !prioritizeSeed path: addressed by the /?origin-order=1 e2e that checks the frontier row keeps source = sitemap.

Still open (maintainer decisions, not resolved by this commit):

  1. Medium, apps/cli/src/controllers/audit.ts:1492: crawler.start(finalUrl, requestedUrl) still passes the user's pre-redirect URL as crawl.originalUrl for same-site redirected starts (http to https, apex to www). entityMapSite() reads that field, so analyze and report reassembly can name a different site than the audit did. The maintainer plans to carry requestedUrl separately and leave originalUrl as it was.
  2. Medium, packages/crawler/src/core/crawler.ts (prioritizeSeed): it is still hasDeepPath(userProvidedUrl) || hasDeepPath(seedResolution.seedUrl), so an origin-only start that redirects to a deep URL (for example / to /en/) still reorders the frontier. The maintainer wants this keyed on the URL the user typed only. The new "root redirect to a deep page" e2e only asserts that the page is included, so it would not catch this.

New findings:

  1. Low, apps/cli/src/cli/commands/audit.ts (deepAuditScope): it is exported but has no unit test. The e2e cases cover it only through a spawned CLI. A small table test for root, deep, query-only and invalid inputs would be cheaper to keep.
  2. Low, docs: docs/cli/audit.mdx says the requested page is "placed first in the crawl frontier". The code comment says the seed already had the first-dispatch bonus and the change only stops a sitemap copy from winning dedup. Please word the docs to match what is guaranteed.

Conventions: DCO passes on all four commits, CHANGELOG [Unreleased] and docs are updated, no new runtime dependency, and I found no regex or unbounded-loop concerns in the diff. CI: everything is green except "CLI tests", which was still running at review time.

nik

@nc9

nc9 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Landed in v0.0.147 as 47271665 b941d7fb af46427f d94c6fc2 via #1412. Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.147. Thank you William: the deep start URL work landed with your four commits and authorship intact, and the review follow-up for the seed order is tracked in #1405. Closing this original.

nik

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.

Auditing a deep URL silently audits the site root; the page you named may not be audited

2 participants