Public: anyone can read this; the crew can change it.

A literal host in src/ that forge.json egress does not declare fails the test, naming the file #15176

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A new test fails when a host named in code under src/ isn't declared in forge.json egress. It found 12 such hosts on main, so this pull also declares those 12, which lets production reach more hosts than before. That change needs a person's yes.

Notes

shipped production is serving it deploy cfe12e4

opened this

A new test fails when a host named in code under src/ isn't declared in forge.json egress. It found 12 such hosts on main, so this pull also declares those 12, which lets production reach more hosts than before. That change needs a person's yes.

The test (test/egress-literals.test.ts)

  • It strips comments with Bun's transpiler, so hosts that only appear in doc comments are ignored.
  • It then lists every https:// and wss:// host left in code strings and compares the list with forge.json egress. The npm registry (STEP_HOSTS in src/apps/contain.ts) also counts as declared, since every cell can always reach it.
  • Each failure names the host and where it is, for example api.stripe.com in src/billing/stripe.ts:19 is not in forge.json egress.
  • Example names (.example, .invalid, example.com) are skipped.
  • Hosts that appear in code but that the server never fetches (links, form placeholders, schema.org and JSON Feed URIs, the droplet's own bun.sh install) are listed in NOT_CALLED, each with a reason. A second test fails if a listed host no longer appears in code or is also declared.
  • A third test runs the scan on a sample: a host in a comment doesn't count, an undeclared host in a string is reported with its file and line, and *.name and :port entries match.

forge.json On main the first test fails with 22 findings across 12 hosts. These are hosts the server already calls, which the forge's gate refuses at run time today:

  • github.com (OAuth token exchange)
  • api.stripe.com
  • challenges.cloudflare.com (Turnstile siteverify)
  • the cloud provider APIs: api.cloudflare.com, api.digitalocean.com, api.fly.io, api.backblazeb2.com, api.vercel.com, login.microsoftonline.com, management.azure.com
  • api.typesafe.ai
  • graph.instagram.com

I declared all 12, which brings the list to 14 of the 32 allowed. parseManifest still accepts the file. If any of these features should stay off in this deployment, move that host into NOT_CALLED with the reason instead.

Not done

  • Hosts the code builds at run time (configured endpoints, admin-set URLs) aren't caught by a literal scan; test/outbound-sweep.test.ts already covers those fetches.
  • Hosts in http:// URLs aren't scanned.

How to try it Run bun test test/egress-literals.test.ts, then remove a host such as api.stripe.com from egress and run it again to see the failure.

The gate, tsc --noEmit, and the new test plus adapter-template, outbound-sweep, forge-looks and own-code pass locally. scripts/fast.ts couldn't narrow the run because forge.json changed, so I picked those files myself.

The push message suggested git push -o pull; I didn't use it, because the forge opens the pull.

🤖 Generated with Claude Code

Closes #15156

commented

A new test fails when a host named in code under src/ isn't declared in forge.json egress. It found 12 such hosts on main, so this pull also declares those 12, which lets production reach more hosts than before. That change needs a person's yes.

The test (test/egress-literals.test.ts)

  • It strips comments with Bun's transpiler, so hosts that only appear in doc comments are ignored.
  • It then lists every https:// and wss:// host left in code strings and compares the list with forge.json egress. The npm registry (STEP_HOSTS in src/apps/contain.ts) also counts as declared, since every cell can always reach it.
  • Each failure names the host and where it is, for example api.stripe.com in src/billing/stripe.ts:19 is not in forge.json egress.
  • Example names (.example, .invalid, example.com) are skipped.
  • Hosts that appear in code but that the server never fetches (links, form placeholders, schema.org and JSON Feed URIs, the droplet's own bun.sh install) are listed in NOT_CALLED, each with a reason. A second test fails if a listed host no longer appears in code or is also declared.
  • A third test runs the scan on a sample: a host in a comment doesn't count, an undeclared host in a string is reported with its file and line, and *.name and :port entries match.

forge.json On main the first test fails with 22 findings across 12 hosts. These are hosts the server already calls, which the forge's gate refuses at run time today:

  • github.com (OAuth token exchange)
  • api.stripe.com
  • challenges.cloudflare.com (Turnstile siteverify)
  • the cloud provider APIs: api.cloudflare.com, api.digitalocean.com, api.fly.io, api.backblazeb2.com, api.vercel.com, login.microsoftonline.com, management.azure.com
  • api.typesafe.ai
  • graph.instagram.com

I declared all 12, which brings the list to 14 of the 32 allowed. parseManifest still accepts the file. If any of these features should stay off in this deployment, move that host into NOT_CALLED with the reason instead.

Not done

  • Hosts the code builds at run time (configured endpoints, admin-set URLs) aren't caught by a literal scan; test/outbound-sweep.test.ts already covers those fetches.
  • Hosts in http:// URLs aren't scanned.

How to try it Run bun test test/egress-literals.test.ts, then remove a host such as api.stripe.com from egress and run it again to see the failure.

The gate, tsc --noEmit, and the new test plus adapter-template, outbound-sweep, forge-looks and own-code pass locally. scripts/fast.ts couldn't narrow the run because forge.json changed, so I picked those files myself.

The push message suggested git push -o pull; I didn't use it, because the forge opens the pull.

🤖 Generated with Claude Code

commented

A new test, test/egress-literals.test.ts, fails the build when a host written in src/ is missing from forge.json egress, and the failure names the host, file and line. It removes comments first using Bun's transpiler, so a host that only appears in a doc comment doesn't count. Hosts reserved for examples (RFC 2606/6761) are ignored. Hosts that appear in code but that the server never calls (links, placeholders, URIs used only as names) are listed in NOT_CALLED with the reason for each. A second test makes sure every entry on that list still appears in code and is not also declared in egress. A third test, on sample input, shows that a host only in a comment is skipped while one in a string is reported with its line.

This push fixes the gate failure. The gate's /\bas never\b/ rule matched the plain words "listed as never called" in a test title at line 95; there was no actual cast. The title now reads "listed in NOT_CALLED". The test logic is unchanged.

The pull also adds github.com, api.stripe.com and the other hosts the code already calls to egress, so it lists every host those calls need. As the check log notes, those hosts only open once the pull lands, so the preview and the check reach what main reaches until then.

To check it: bun scripts/gate.ts --fix and bun x tsc --noEmit are clean, and bun test test/egress-literals.test.ts passes 3 of 3. To try it, put a string like "https://api.unknown.dev" in any file under src/ and run that test file; it should fail and name the file and line.

🤖 Generated with Claude Code

Approved

The test scans comment-stripped src strings for https/wss hosts, compares them to forge.json egress plus STEP_HOSTS, and names host, file and line. NOT_CALLED is itself checked for staleness, and a sample test proves comment-skip, line naming, wildcard and port matching. No page, API or terminal surface is touched, so the both-doors and security items do not apply. Two things to do next: (1) the 12 added egress hosts widen what production can reach, which a person should explicitly confirm at merge; any feature that stays off should move to NOT_CALLED instead. (2) Extend the scan to http:// literals and to hosts built from configured constants, so the guard covers more than the https literals.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs