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

An app's fetch to an undeclared host fails with the forge's own words, and a test shows the text names the host and forge.json egress #13552

opened this

Merged 18d 15h ago, live in production

A fetch to a host that forge.json egress doesn't list was already answered with "refused by this forge: : is not in this app's forge.json egress" on main, in the 403 from the gate (src/apps/egress.ts).

Notes

opened this

A fetch to a host that forge.json egress doesn't list was already answered with "refused by this forge: <host>:<port> is not in this app's forge.json egress" on main, in the 403 from the gate (src/apps/egress.ts). Two other places used different words, and this pull makes them all say the same sentence:

  • One source for the sentence: refusedWords(host, port) in src/apps/egress.ts builds it. The gate's decide now uses it instead of an inline template.
  • The parent's log line: it said [egress] <app> was refused <host>: not in its forge.json egress. It now prints [egress] <app>: refused by this forge: <host>:<port> is not in this app's forge.json egress. It still goes through logSafe, so it stays printable ASCII under 200 bytes. Private destinations keep their own wording ("a private destination"), because the gate tells those apps something different.
  • The owner's Blocked row: BlockedRow gains a said field (in src/actions/egress_refused.ts). The app settings page shows it under each non-private row as "Its fetch was told: …", escaped by the html template. Only the host and port appear; nothing else from the request is echoed.
  • Tests: the new test/egress-words.test.ts spells the sentence out literally. It checks that the gate's answer, the log line and the rendered row each contain it exactly, so changing the wording or dropping the host fails. Two assertions in test/egress-refused.test.ts expected the old log wording. I updated them because those tests pinned the wording this issue replaces; the code they cover is unchanged.

I ran test/egress-words.test.ts, egress-refused, ask-to-reach, outbound-gate, contain and checks-placement, and they pass. The suites that need unix sockets or cells (30 tests) are skipped in this sandbox; the forge's check runs them. I confirmed the new test fails without this change. bun x tsc --noEmit and bun scripts/design-lint.ts are clean, and bun scripts/gate.ts --fix rewrapped comments in two files, which are committed. scripts/fast.ts named 2,777 files for this diff, so I didn't run that set and picked the covering files above instead.

To try it: in production, let an app fetch a host it doesn't declare. The parent's log shows the new line, and the app's settings page lists the host under Blocked with "Its fetch was told: refused by this forge: <host>:443 is not in this app's forge.json egress".

🤖 Generated with Claude Code

Closes #13537

commented

A fetch to a host that forge.json egress doesn't list was already answered with "refused by this forge: <host>:<port> is not in this app's forge.json egress" on main, in the 403 from the gate (src/apps/egress.ts). Two other places used different words, and this pull makes them all say the same sentence:

  • One source for the sentence: refusedWords(host, port) in src/apps/egress.ts builds it. The gate's decide now uses it instead of an inline template.
  • The parent's log line: it said [egress] <app> was refused <host>: not in its forge.json egress. It now prints [egress] <app>: refused by this forge: <host>:<port> is not in this app's forge.json egress. It still goes through logSafe, so it stays printable ASCII under 200 bytes. Private destinations keep their own wording ("a private destination"), because the gate tells those apps something different.
  • The owner's Blocked row: BlockedRow gains a said field (in src/actions/egress_refused.ts). The app settings page shows it under each non-private row as "Its fetch was told: …", escaped by the html template. Only the host and port appear; nothing else from the request is echoed.
  • Tests: the new test/egress-words.test.ts spells the sentence out literally. It checks that the gate's answer, the log line and the rendered row each contain it exactly, so changing the wording or dropping the host fails. Two assertions in test/egress-refused.test.ts expected the old log wording. I updated them because those tests pinned the wording this issue replaces; the code they cover is unchanged.

I ran test/egress-words.test.ts, egress-refused, ask-to-reach, outbound-gate, contain and checks-placement, and they pass. The suites that need unix sockets or cells (30 tests) are skipped in this sandbox; the forge's check runs them. I confirmed the new test fails without this change. bun x tsc --noEmit and bun scripts/design-lint.ts are clean, and bun scripts/gate.ts --fix rewrapped comments in two files, which are committed. scripts/fast.ts named 2,777 files for this diff, so I didn't run that set and picked the covering files above instead.

To try it: in production, let an app fetch a host it doesn't declare. The parent's log shows the new line, and the app's settings page lists the host under Blocked with "Its fetch was told: refused by this forge: <host>:443 is not in this app's forge.json egress".

🤖 Generated with Claude Code

commented

The gate, the parent's log and the owner's Blocked row (on the settings page and in the terminal) now all say the forge's own sentence: "refused by this forge: <host>:<port> is not in this app's forge.json egress". It comes from one place, refusedWords(host, port) in src/apps/egress.ts.

On main, the gate's 403 already said this; the log line and the Blocked row used other words. What changed:

  • Log: the line now reads [egress] <app>: refused by this forge: <host>:<port> is not in this app's forge.json egress, still through logSafe. A private destination keeps its own line, [egress] <app> was refused <host>:<port>: a private destination, because the gate tells it something different.
  • Blocked row, page and terminal: the sentence appears once, followed by the tries. For example: refused by this forge: huggingface.co:443 is not in this app's forge.json egress (14 tries, last 2 min ago). The line is built by blockedRowLine in src/apps/egress_refused.ts. The settings page renders it escaped, and the terminal's Blocked screen lists the same line through blockedListRows. A private destination still reads Blocked: 10.0.0.5:5432 (…).
  • Review changes: the earlier extra sentence under each web row is gone, so the host and reason are no longer said twice. The said field is dropped, since the row's line now carries the sentence; the terminal therefore shows that line rather than a said field. docs/features/blocked-hosts.md and docs/features/app-egress-refused.md now say the log and the row print the same sentence as the 403.
  • Tests: test/egress-words.test.ts spells the sentence out and checks the gate, the log, the row line, the page (exactly once, escaped) and the terminal rows. It also pins the private log line and the private row line. Three assertions in test/egress-refused.test.ts expected the old wording of the log line and the page row; I updated them because those tests pinned what this issue replaces.

bun x tsc --noEmit, bun scripts/design-lint.ts and bun scripts/gate.ts --fix are clean, and its comment rewraps are committed. 63 tests pass across the egress-words, egress-refused and ask-to-reach suites and the tests that use the TUI Blocked screen, app_hosts or refusalLine. scripts/fast.ts named 2,777 files for this diff, so I chose those suites myself instead of running its list. The suites that need unix sockets or cells are skipped in this sandbox; the forge's check runs them.

No preview can show the Blocked row, since it needs a real refusal on a live app; the commit says so on a No look: line. To try it in production, let an app fetch a host its forge.json egress doesn't list. The forge's log shows the line above, and the app's settings page and the terminal's Blocked screen (a allows, i ignores) both list the host in the same words.

🤖 Generated with Claude Code

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs