Skip to content

refactor(fetchers): share the TLS probe with the cloud worker through a subpath #3922 - #1812

Closed
nc9 wants to merge 1 commit into
mainfrom
r3/tls-probe-shared-3922
Closed

nc9 wants to merge 1 commit into
mainfrom
r3/tls-probe-shared-3922

Conversation

@nc9

@nc9 nc9 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Public half of private #3922 (decision D7).

Design

  • The probe moves from apps/cli/src/audit/tls-probe.ts to packages/fetchers/src/tls-probe.ts, exported only as the @squirrelscan/fetchers/tls-probe subpath (not from the package root). The CLI file re-exports it, so CLI imports and tests are unchanged.
  • docs(agents): Antigravity, Hermes Agent, OpenClaw, GitHub Copilot surfaces and allowlisting #5454 #2410 rule ("shared packages hold no raw socket code") is honoured: rules, crawler and audit-engine only take an injected TlsProbeFn. The raw-socket guard test now allowlists exactly this one file and a new test asserts no shared package imports the subpath, the fetchers index does not export it, and the manifest exposes it as a subpath.
  • docs(agents): Antigravity, Hermes Agent, OpenClaw, GitHub Copilot surfaces and allowlisting #5454 #2410 noted the cloud needs a refuse-without-proxy mode first. New option requireProxy: a handshake that would go out directly is unavailable, nothing resolved or sent. The worker will pass its egress guard's local proxy as proxyUrl with requireProxy: true. The vetted-address pinning, EGRESS_REFUSED and 8s default timeout are unchanged.
  • Already on main from earlier #3922 work: hosted wording (ctx.hosted), the runStreamingRules threading test.
  • runCloudAudit itself is in the private repo, so passing the probe is the private PR after the gitlink bump.

Acceptance criteria

  • One probe implementation for CLI and cloud, CLI behaviour and tests unchanged: apps/cli tls-probe, tls-probe-proxy-url, tls-root-failure tests pass.
  • Egress rules (private/loopback/link-local refused, vetted address connected to): unchanged code, plus new test "a refused address stays refused through the proxy path".
  • Own short timeout: unchanged default 8s and per-target timeoutMs; measured added time per cloud audit is for the private PR.
  • Docs: tls-certificate rule page no longer says the check is CLI-only.
  • Not done here (private side / needs live data): cloud pass/fail verification on test hosts, 30-day not-checked count, dashboard notice.

Gates

  • bun test: fetchers require-proxy + utils tls-certificate (27 pass); CLI tls tests + audit-engine threading + rules hosted (90 pass)
  • tsgo --noEmit: fetchers, utils, apps/cli clean; apps/cli lint and format:check clean; test-suites --check ok; docs make validate ok

Docs: docs/rules/security/tls-certificate.mdx. CHANGELOG bullet under Changed. Skill: none. Private rule catalog: no meta text change, no regeneration.

… a subpath, add requireProxy #3922

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9

nc9 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Lead review (Codex, Boat):

Head: d291bd114705160a1511efa8434e5993fca952d4

Verdict: MERGE

packages/fetchers/package.json:7 and packages/fetchers/src/tls-probe.ts:1-14: socket implementation is exported only through the separate /tls-probe subpath, not the fetchers root. The CLI wrapper is the production importer in this public diff; rules, crawler and audit-engine still receive the injected function. packages/utils/tests/tls-certificate.test.ts:308 adds an importer/root-export guard.

Compared the moved implementation against origin/main:apps/cli/src/audit/tls-probe.ts: executable change is solely the opt-in requireProxy branch; without that option CLI behavior is unchanged. The private worker integration is not claimed delivered by this verdict and must explicitly opt into requireProxy.

Public checklist: the single head commit has Signed-off-by; CHANGELOG.md and the TLS rule docs are updated; no added em dash or mock.module found. No migration or apps/api import is part of this public diff.

Review method: fetched-head diff and origin/main source inspection. Tests/gates not rerun; no production operations.

@nc9

nc9 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Lead review (Opus, Boat):

Head: d291bd114705160a1511efa8434e5993fca952d4

Verdict: FIX (one docs line)

What passes:

  • packages/fetchers/src/tls-probe.ts is byte-identical to the old apps/cli/src/audit/tls-probe.ts, apart from the header comment and the requireProxy option plus its early unavailable return (lines ~104-110 and ~158-163).
  • With requireProxy unset, CLI behaviour is identical. apps/cli/src/audit/tls-probe.ts is export * from "@squirrelscan/fetchers/tls-probe", and the probe has no default export.
  • Exported only as the ./tls-probe subpath. packages/fetchers/src/index.ts does not export it.
  • git grep "fetchers/tls-probe" shows only apps/cli importing it. The new guard test fails if any packages/*/src file imports it.
  • The docs(agents): Antigravity, Hermes Agent, OpenClaw, GitHub Copilot surfaces and allowlisting #5454 #2410 raw-socket guard allowlists exactly this one file.
  • @squirrelscan/fetchers already depends on @squirrelscan/utils, and apps/cli already depends on fetchers.
  • Checklist: DCO Signed-off-by present, CHANGELOG bullet under Changed, docs updated, no em or en dashes in added lines, no mock.module.
  • Tests run on the head:

Finding:

  • docs/rules/security/tls-certificate.mdx:52: "The handshake runs in the squirrel CLI and in cloud audits, where it leaves only through the cloud's egress guard". This is not true yet. Cloud audits do not run the probe until the private worker PR wires createTlsProbe({ proxyUrl, requireProxy: true }) into runCloudAudit, and the docs publish from this repo's main.

Exact instruction:

  • Revert that sentence to main's "The handshake runs in the squirrel CLI." Keep the CHANGELOG bullet.
  • Add the cloud sentence in the public docs batch that ships with the private worker wiring.
  • Force-push with lease, signed off.

@nc9

nc9 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded: this change is on main via separate merges (rebasing bundle #1814 onto main skipped every code commit from #1810/#1806/#1809/#1812 as already applied).

@nc9 nc9 closed this Nov 14, 2026
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.

1 participant