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

Loopback is not a trusted proxy unless FORGE_TRUSTED_PROXIES names it #14984

Merged opened this

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

Merged

scout/forge:scout/14950-loopback-is-not-a-trusted-proxy-unless-f → main 3 commits fork

  • Merged. scout/14950-loopback-is-not-a-trusted-proxy-unless-f was merged into main as feff67d.

Review

Sign in to review this change.
21 files changed +69 −41
docs/OPERATING.md +1 −1
@@ -88,7 +88,7 @@ from `FORGE_CLIENT_IP_HEADER` when the edge sets one (`cf-connecting-ip`
8888 behind a Cloudflare tunnel, where the ingress rewrites `X-Forwarded-For`;
8989 read only from a listed proxy). Once set, only the listed ranges are proxies:
9090 this machine is not one unless listed, since every app runs beside the forge.
91 Unset, only this machine may say so, and the named header is never read. Everything a forge
91 Unset, no one may say so, this machine included: the socket peer is the client, and neither `X-Forwarded-For` nor the named header is read (a local proxy in development names `127.0.0.0/8,::1`). Everything a forge
9292 instance _is_ lives under the data directory — the SQLite index, the bare
9393 repos, and the SSH host key, in plain layout. Tar it up and it moves.
9494
src/app.ts +2 −2
@@ -144,8 +144,8 @@ export interface ForgeConfig {
144144 mailer?: Mailer;
145145 /**
146146 * Proxies whose forwarded headers say who the client is
147 * (\`FORGE_TRUSTED_PROXIES\`, CIDR ranges). Empty or absent, only this
148 * machine is trusted to say so (\`http/peer.ts\`).
147 * (\`FORGE_TRUSTED_PROXIES\`, CIDR ranges). Empty or absent, no one is
148 * trusted to say so, loopback included (\`http/peer.ts\`).
149149 */
150150 trustedProxies?: readonly string[];
151151 /** A header a trusted edge sets to the client's address (\`FORGE_CLIENT_IP_HEADER\`). */
src/http/peer.ts +6 −8
@@ -6,8 +6,9 @@
66 * The socket's peer is the answer unless that peer is a proxy the operator
77 * trusts. With `FORGE_TRUSTED_PROXIES` set, those ranges are the proxies and
88 * nothing else is — not even this machine, where every app and crew run is
9 * a process that could call the forge and claim to be anyone. Unset, this
10 * machine alone may say (a local proxy in development). From a trusted
9 * a process that could call the forge and claim to be anyone. Unset, no
10 * one may say: the socket's peer is the client, loopback included (a local
11 * proxy in development names `127.0.0.0/8,::1`). From a trusted
1112 * proxy, `X-Forwarded-For` is walked from the right, past each trusted hop,
1213 * to the first address no trusted proxy vouches for; the left end is
1314 * whatever the client wrote and is never read as such. A named header the
@@ -38,11 +39,9 @@ export function resolveClient(
3839 trust: ProxyTrust,
3940 ): string {
4041 if (peer === undefined) return "unknown";
41 const listed = trust.proxies.length > 0;
42 const trusted = (address: string): boolean =>
43 listed ? inCidrs(address, trust.proxies) : LOOPBACK.has(address);
42 const trusted = (address: string): boolean => inCidrs(address, trust.proxies);
4443 if (!trusted(peer)) return peer;
45 if (trust.header !== undefined && listed) {
44 if (trust.header !== undefined) {
4645 const named = headers.get(trust.header)?.trim() ?? "";
4746 if (isAddress(named)) return named;
4847 }
@@ -86,8 +85,7 @@ export const notePeer = (
8685 ): void => {
8786 clients.set(request, resolveClient(address, request.headers, trust));
8887 if (isInternalPeer(address, request.headers, trust)) internals.add(request);
89 else if (address !== undefined && (trust.proxies.length > 0 ? inCidrs(address, trust.proxies) : LOOPBACK.has(address)))
90 edged.add(request);
88 else if (address !== undefined && inCidrs(address, trust.proxies)) edged.add(request);
9189 };
9290
9391 /** The request came through a proxy the operator trusts, so the headers an edge adds (bot score, country) are its, not the client's. */
test/anonymous-deep.test.ts +2 −1
@@ -15,6 +15,7 @@ import { crawlerShare, createPerfRecord } from "../src/perf/record.ts";
1515 import { crawlReport } from "../src/perf/crawlers.ts";
1616 import { clearTreeCache, treeCacheStats } from "../src/web/pages/tree_cache.ts";
1717 import { keptPageStats } from "../src/web/pages/kept_page.ts";
18 import { LOOPBACK_PROXIES } from "./helpers/loopback-proxy.ts";
1819
1920 let dataDir: string;
2021 let app: App;
@@ -28,7 +29,7 @@ const get = (path: string, headers: Record<string, string> = {}) => fetch(`${ser
2829
2930 beforeAll(async () => {
3031 dataDir = await mkdtemp(join(tmpdir(), "forge-anon-deep-"));
31 app = createApp({ dataDir, port: 0 });
32 app = createApp({ dataDir, port: 0 , trustedProxies: LOOPBACK_PROXIES });
3233 servers = await serve(app);
3334 const u = await createUser(app.db, { origin: "seed", trusted: true, username: "alice", email: "[email protected]", password: "a-good-passphrase", isAdmin: true });
3435 if (!u.ok) throw new Error(u.error);
test/apps-feedback.test.ts +2 −1
@@ -25,6 +25,7 @@ import { createUser, type User } from "../src/core/users.ts";
2525 import { serve, type Servers } from "../src/http/server.ts";
2626 import { taskPrompt, type TaskInput } from "../src/crew/brief.ts";
2727 import { quietLogs } from "./helpers/globals.ts";
28 import { LOOPBACK_PROXIES } from "./helpers/loopback-proxy.ts";
2829
2930 quietLogs();
3031
@@ -39,7 +40,7 @@ describe("the forge button takes notes from anyone", () => {
3940
4041 beforeAll(async () => {
4142 dataDir = await mkdtemp(join(tmpdir(), "forge-app-feedback-"));
42 app = createApp({ dataDir, port: 0, host: "forge.test" });
43 app = createApp({ dataDir, port: 0, host: "forge.test", trustedProxies: LOOPBACK_PROXIES });
4344 servers = await serve(app);
4445 runtime = new AppsRuntime(app, {
4546 domain: DOMAIN,
test/apps-proxy-client-ip.test.ts +2 −4
@@ -94,10 +94,8 @@ test("with no client headers, the app hears the socket's address", async () => {
9494 onlyForwardedFor(await seen(), LOOPBACK);
9595 });
9696
97 test("a list in x-forwarded-for reaches the app as the one address the forge resolved", async () => {
98 // From loopback (the only trusted proxy here) the list is walked from the right: the
99 // left end is whatever the client wrote and never reaches the app.
100 onlyForwardedFor(await seen({ "x-forwarded-for": "203.0.113.9, 198.51.100.7" }), "198.51.100.7");
97 test("a forged x-forwarded-for from loopback never reaches the app: with no proxy listed, the client is the socket", async () => {
98 onlyForwardedFor(await seen({ "x-forwarded-for": "203.0.113.9, 198.51.100.7" }), LOOPBACK);
10199 });
102100
103101 test("client-written x-real-ip, forwarded, cf-connecting-ip, true-client-ip and the edge header are dropped", async () => {
test/client-address.test.ts +15 −10
@@ -10,6 +10,7 @@ import {
1010 clientAddress,
1111 notePeer,
1212 resolveClient,
13 wasViaEdge,
1314 type ProxyTrust,
1415 } from "../src/http/peer.ts";
1516 import { serve, type Servers } from "../src/http/server.ts";
@@ -134,17 +135,21 @@ describe("the client behind the proxy", () => {
134135 ).toBe("198.51.100.8");
135136 });
136137
137 test("this machine counts as a proxy, as before, but its hop is read from the right", () => {
138 test("unset, this machine is not a proxy: a forged X-Forwarded-For from loopback is ignored", () => {
138139 const none = trust("");
139 expect(
140 resolveClient(
141 "127.0.0.1",
142 headers({ "x-forwarded-for": "1.1.1.1, 198.51.100.3" }),
143 none,
144 ),
145 ).toBe("198.51.100.3");
140 const forged = headers({ "x-forwarded-for": "1.1.1.1, 198.51.100.3", "cf-connecting-ip": "2.2.2.2" });
141 expect(resolveClient("127.0.0.1", forged, none)).toBe("127.0.0.1");
142 expect(resolveClient("::1", forged, none)).toBe("::1");
143 expect(resolveClient("::ffff:127.0.0.1", forged, none)).toBe("::ffff:127.0.0.1");
146144 expect(resolveClient("127.0.0.1", headers({}), none)).toBe("127.0.0.1");
147145 });
146
147 test("unset, a request from loopback is not via the edge", () => {
148 const r = new Request("http://x/", { headers: { "x-forwarded-for": "198.51.100.3" } });
149 notePeer(r, "127.0.0.1");
150 expect(clientAddress(r)).toBe("127.0.0.1");
151 expect(wasViaEdge(r)).toBe(false);
152 });
148153 });
149154
150155 describe("this machine is not a proxy once the proxies are named", () => {
@@ -169,9 +174,9 @@ describe("this machine is not a proxy once the proxies are named", () => {
169174 expect(resolveClient("127.0.0.1", h, { proxies: parsed.value })).toBe("198.51.100.30");
170175 });
171176
172 test("with no proxies named, the named header is never read, even from this machine", () => {
177 test("with no proxies named, neither the named header nor X-Forwarded-For is read, even from this machine", () => {
173178 const h = headers({ "cf-connecting-ip": "2.2.2.2", "x-forwarded-for": "198.51.100.31" });
174 expect(resolveClient("127.0.0.1", h, { proxies: [], header: "cf-connecting-ip" })).toBe("198.51.100.31");
179 expect(resolveClient("127.0.0.1", h, { proxies: [], header: "cf-connecting-ip" })).toBe("127.0.0.1");
175180 });
176181 });
177182
test/crawl-budget.test.ts +2 −1
@@ -11,6 +11,7 @@ import { createUser, type User } from "../src/core/users.ts";
1111 import { AGENT_BUDGET, BEHIND_DIVISOR, STRANGER_BUDGET, CRAWL_BUDGET, DEEP_SEGMENTS, SHARED_BUDGET, agentOf, crawlAgentCount, isCrawler, pinCrawlLag, setCrawlClock, takeCrawl } from "../src/http/crawl.ts";
1212 import { serve, type Servers } from "../src/http/server.ts";
1313 import { crawlerShare, createPerfRecord } from "../src/perf/record.ts";
14 import { LOOPBACK_PROXIES } from "./helpers/loopback-proxy.ts";
1415
1516 let dataDir: string;
1617 let app: App;
@@ -33,7 +34,7 @@ const get = (path: string, headers: Record<string, string> = {}) => fetch(`${ser
3334
3435 beforeAll(async () => {
3536 dataDir = await mkdtemp(join(tmpdir(), "forge-crawl-"));
36 app = createApp({ dataDir, port: 0 });
37 app = createApp({ dataDir, port: 0 , trustedProxies: LOOPBACK_PROXIES });
3738 servers = await serve(app);
3839 const u = await createUser(app.db, { origin: "seed", trusted: true, username: "alice", email: "[email protected]", password: "a-good-passphrase", isAdmin: true });
3940 if (!u.ok) throw new Error(u.error);
test/helpers/apps-forge.ts +2 −1
@@ -18,6 +18,7 @@ import { listRuns, type Run } from "../../src/core/runs.ts";
1818 import { createUser, type User } from "../../src/core/users.ts";
1919 import { serve, type Servers } from "../../src/http/server.ts";
2020 import "./roomy-disk.ts";
21 import { LOOPBACK_PROXIES } from "./loopback-proxy.ts";
2122
2223 export const APPS_DOMAIN = "apps.test";
2324
@@ -49,7 +50,7 @@ export async function startAppsForge(
4950 ): Promise<AppsForge> {
5051 const dataDir = await mkdtemp(join(tmpdir(), "forge-apps-"));
5152 const work = await mkdtemp(join(tmpdir(), "forge-apps-work-"));
52 const app = createApp({ dataDir, port: 0 });
53 const app = createApp({ dataDir, port: 0 , trustedProxies: LOOPBACK_PROXIES });
5354 setSsh(app.db, true, "test");
5455 const servers = await serve(app);
5556 // Every app the runtime boots is handed this key; the tests sign as
test/helpers/loopback-proxy.ts added +7
@@ -0,0 +1,7 @@
1 /**
2 * The test client is this machine, and a test that plays several outside
3 * clients sends `X-Forwarded-For` from loopback. Loopback is a proxy only
4 * when named (`src/http/peer.ts`), so such a test names it, as an operator
5 * running a local proxy would: `createApp({ …, trustedProxies: LOOPBACK_PROXIES })`.
6 */
7 export const LOOPBACK_PROXIES: readonly string[] = ["127.0.0.0/8", "::1"];
test/muse-journey.test.ts +2 −1
@@ -19,6 +19,7 @@ import { createUser } from "../src/core/users.ts";
1919 import { OFFER_REL } from "../src/apps/proxy.ts";
2020 import { serve, type Servers } from "../src/http/server.ts";
2121 import { quietLogs } from "./helpers/globals.ts";
22 import { LOOPBACK_PROXIES } from "./helpers/loopback-proxy.ts";
2223
2324 quietLogs();
2425
@@ -51,7 +52,7 @@ describe("the Muse test: a stranger agent needs no teaching", () => {
5152 }),
5253 });
5354 dataDir = await mkdtemp(join(tmpdir(), "forge-muse-"));
54 app = createApp({ dataDir, port: 0, host: "forge.test" });
55 app = createApp({ dataDir, port: 0, host: "forge.test" , trustedProxies: LOOPBACK_PROXIES });
5556 servers = await serve(app);
5657 runtime = new AppsRuntime(app, {
5758 domain: DOMAIN,
test/muse-report-journey.test.ts +2 −1
@@ -15,6 +15,7 @@ import { createToken } from "../src/core/tokens.ts";
1515 import { createUser } from "../src/core/users.ts";
1616 import { serve, type Servers } from "../src/http/server.ts";
1717 import { quietLogs } from "./helpers/globals.ts";
18 import { LOOPBACK_PROXIES } from "./helpers/loopback-proxy.ts";
1819
1920 describe("an anonymous client finds the report door from the page alone", () => {
2021 quietLogs();
@@ -28,7 +29,7 @@ describe("an anonymous client finds the report door from the page alone", () =>
2829
2930 beforeAll(async () => {
3031 dataDir = await mkdtemp(join(tmpdir(), "forge-muse-journey-"));
31 app = createApp({ dataDir, port: 0 });
32 app = createApp({ dataDir, port: 0 , trustedProxies: LOOPBACK_PROXIES });
3233 servers = await serve(app);
3334 base = servers.url;
3435 const a = await createUser(app.db, {
test/note-pictures.test.ts +2 −1
@@ -23,6 +23,7 @@ import { createSession } from "../src/core/sessions.ts";
2323 import { createUser, getUserByName } from "../src/core/users.ts";
2424 import { serve, type Servers } from "../src/http/server.ts";
2525 import { quietLogs } from "./helpers/globals.ts";
26 import { LOOPBACK_PROXIES } from "./helpers/loopback-proxy.ts";
2627
2728 quietLogs();
2829
@@ -36,7 +37,7 @@ describe("a note may carry a picture of the page", () => {
3637
3738 beforeAll(async () => {
3839 dataDir = await mkdtemp(join(tmpdir(), "forge-app-feedback-"));
39 app = createApp({ dataDir, port: 0, host: "forge.test" });
40 app = createApp({ dataDir, port: 0, host: "forge.test" , trustedProxies: LOOPBACK_PROXIES });
4041 servers = await serve(app);
4142 runtime = new AppsRuntime(app, {
4243 domain: DOMAIN,
test/offer-limits.test.ts +2 −1
@@ -14,6 +14,7 @@ import { fileOffer, OFFER_REQUEST_MAX, OFFERS_WAITING_MAX } from "../src/actions
1414 import { getRepo, type Repo } from "../src/core/repos.ts";
1515 import { createUser, type User } from "../src/core/users.ts";
1616 import { serve, type Servers } from "../src/http/server.ts";
17 import { LOOPBACK_PROXIES } from "./helpers/loopback-proxy.ts";
1718
1819 const patchFor = (n: number) => `diff --git a/f${n}.txt b/f${n}.txt\nnew file mode 100644\n--- /dev/null\n+++ b/f${n}.txt\n@@ -0,0 +1 @@\n+${n}\n`;
1920
@@ -42,7 +43,7 @@ describe("offer limits", () => {
4243
4344 beforeAll(async () => {
4445 dataDir = await mkdtemp(join(tmpdir(), "forge-offer-limits-"));
45 app = createApp({ dataDir, port: 0 });
46 app = createApp({ dataDir, port: 0 , trustedProxies: LOOPBACK_PROXIES });
4647 servers = await serve(app);
4748 const a = await createUser(app.db, { origin: "seed", trusted: true, username: "alice", email: "[email protected]", password: "a-good-passphrase", adminIfFirst: true });
4849 if (!a.ok) throw new Error(a.error);
test/offer-mcp.test.ts +2 −1
@@ -10,6 +10,7 @@ import { OFFER_RECEIVED, OFFER_WORDS } from "../src/actions/offer.ts";
1010 import { getRepo } from "../src/core/repos.ts";
1111 import { createUser } from "../src/core/users.ts";
1212 import { serve, type Servers } from "../src/http/server.ts";
13 import { LOOPBACK_PROXIES } from "./helpers/loopback-proxy.ts";
1314
1415 const PATCH = `diff --git a/hello.txt b/hello.txt
1516 --- a/hello.txt
@@ -39,7 +40,7 @@ describe("offer over MCP", () => {
3940
4041 beforeAll(async () => {
4142 dataDir = await mkdtemp(join(tmpdir(), "forge-offer-mcp-"));
42 app = createApp({ dataDir, port: 0 });
43 app = createApp({ dataDir, port: 0 , trustedProxies: LOOPBACK_PROXIES });
4344 servers = await serve(app);
4445 const a = await createUser(app.db, { origin: "seed", trusted: true, username: "alice", email: "[email protected]", password: "a-good-passphrase", adminIfFirst: true });
4546 if (!a.ok) throw new Error(a.error);
test/offer-receipt.test.ts +2 −1
@@ -13,6 +13,7 @@ import { submitReview } from "../src/core/reviews.ts";
1313 import { getRepo } from "../src/core/repos.ts";
1414 import { createUser, type User } from "../src/core/users.ts";
1515 import { serve, type Servers } from "../src/http/server.ts";
16 import { LOOPBACK_PROXIES } from "./helpers/loopback-proxy.ts";
1617
1718 const PATCH = `diff --git a/hello.txt b/hello.txt
1819 --- a/hello.txt
@@ -47,7 +48,7 @@ describe("offer receipt", () => {
4748
4849 beforeAll(async () => {
4950 dataDir = await mkdtemp(join(tmpdir(), "forge-offer-receipt-"));
50 app = createApp({ dataDir, port: 0 });
51 app = createApp({ dataDir, port: 0 , trustedProxies: LOOPBACK_PROXIES });
5152 servers = await serve(app);
5253 const a = await createUser(app.db, { origin: "seed", trusted: true, username: "alice", email: "[email protected]", password: "a-good-passphrase", adminIfFirst: true });
5354 if (!a.ok) throw new Error(a.error);
test/offer-stranger.test.ts +3 −2
@@ -18,6 +18,7 @@ import { runGit } from "../src/git/env.ts";
1818 import { repoDir } from "../src/git/repos.ts";
1919 import { guestWaits } from "../src/origins/guest.ts";
2020 import { serve, type Servers } from "../src/http/server.ts";
21 import { LOOPBACK_PROXIES } from "./helpers/loopback-proxy.ts";
2122
2223 const PATCH = `diff --git a/hello.txt b/hello.txt
2324 --- a/hello.txt
@@ -55,7 +56,7 @@ describe("offers from outside", () => {
5556
5657 beforeAll(async () => {
5758 dataDir = await mkdtemp(join(tmpdir(), "forge-offer-"));
58 app = createApp({ dataDir, port: 0 });
59 app = createApp({ dataDir, port: 0 , trustedProxies: LOOPBACK_PROXIES });
5960 servers = await serve(app);
6061 const a = await createUser(app.db, { origin: "seed", trusted: true, username: "alice", email: "[email protected]", password: "a-good-passphrase", adminIfFirst: true });
6162 if (!a.ok) throw new Error(a.error);
@@ -239,7 +240,7 @@ describe("offers from outside", () => {
239240 test("one source is limited to three a minute (rate_limited)", async () => {
240241 // A forge of its own: the forge-wide minute is spent by the tests above.
241242 const dir = await mkdtemp(join(tmpdir(), "forge-offer-mcp-limit-"));
242 const own = createApp({ dataDir: dir, port: 0 });
243 const own = createApp({ dataDir: dir, port: 0 , trustedProxies: LOOPBACK_PROXIES });
243244 const srv = await serve(own);
244245 try {
245246 const u = await createUser(own.db, { origin: "seed", trusted: true, username: "bob", email: "[email protected]", password: "a-good-passphrase", adminIfFirst: true });
test/reports.test.ts +2 −1
@@ -22,6 +22,7 @@ import { createToken } from "../src/core/tokens.ts";
2222 import { createUser, type User } from "../src/core/users.ts";
2323 import type { Repo } from "../src/core/repos.ts";
2424 import { serve, type Servers } from "../src/http/server.ts";
25 import { LOOPBACK_PROXIES } from "./helpers/loopback-proxy.ts";
2526
2627 describe("reports from outside", () => {
2728 let dataDir: string;
@@ -39,7 +40,7 @@ describe("reports from outside", () => {
3940
4041 beforeAll(async () => {
4142 dataDir = await mkdtemp(join(tmpdir(), "forge-reports-"));
42 app = createApp({ dataDir, port: 0 });
43 app = createApp({ dataDir, port: 0 , trustedProxies: LOOPBACK_PROXIES });
4344 servers = await serve(app);
4445 base = servers.url;
4546 const a = await createUser(app.db, { origin: "seed", trusted: true,
test/scrape-evidence.test.ts +7 −1
@@ -10,6 +10,7 @@ import { tmpdir } from "node:os";
1010 import { join } from "node:path";
1111 import { createApp, type App } from "../src/app.ts";
1212 import { wasViaEdge, notePeer } from "../src/http/peer.ts";
13 import { parseCidrs } from "../src/kernel/cidr.ts";
1314 import { createSession } from "../src/core/sessions.ts";
1415 import { createUser, type User } from "../src/core/users.ts";
1516 import { serve, type Servers } from "../src/http/server.ts";
@@ -207,7 +208,12 @@ test("a bot score and country are believed only from a trusted edge", () => {
207208 expect(wasViaEdge(viaProxy) || wasViaEdge(direct)).toBe(false); // loopback with no client named is the forge itself; a stranger is no edge
208209 const named = new Request("http://forge.test/", { headers: { "cf-connecting-ip": "203.0.113.5" } });
209210 notePeer(named, "127.0.0.1", { proxies: [] });
210 expect(wasViaEdge(named)).toBe(true);
211 expect(wasViaEdge(named)).toBe(false); // unlisted, this machine is no edge: any process beside the forge could write the score
212 const listedLoopback = parseCidrs("127.0.0.0/8");
213 if (!listedLoopback.ok) throw new Error("cidr");
214 const viaListed = new Request("http://forge.test/", { headers: { "cf-connecting-ip": "203.0.113.5" } });
215 notePeer(viaListed, "127.0.0.1", { proxies: listedLoopback.value });
216 expect(wasViaEdge(viaListed)).toBe(true);
211217 });
212218
213219 test("an agent account, even an admin's, cannot start a capture or import networks", async () => {
test/strangers.test.ts +2 −1
@@ -33,6 +33,7 @@ import { forgeSearch } from "../src/tui/forge.ts";
3333 import { Session } from "../src/tui/session.ts";
3434 import { seedAdmin } from "./helpers/admin.ts";
3535 import { gitClientEnv } from "./helpers/git-client.ts";
36 import { LOOPBACK_PROXIES } from "./helpers/loopback-proxy.ts";
3637
3738 describe("Fresh: one piece of work per key per while", () => {
3839 test("kept for ttl, made again after, by the clock it is given", () => {
@@ -84,7 +85,7 @@ describe("strangers at every door", () => {
8485
8586 beforeAll(async () => {
8687 dataDir = await mkdtemp(join(tmpdir(), "forge-strangers-"));
87 app = createApp({ dataDir, port: 0 });
88 app = createApp({ dataDir, port: 0 , trustedProxies: LOOPBACK_PROXIES });
8889 // The windows stand still: a slow request on a loaded machine never
8990 // slides one, so a count is the same count however long the test takes.
9091 setStrangerClock(app, () => 1_000_000);
test/stripe-hook.test.ts +2 −1
@@ -10,6 +10,7 @@ import { serve, type Servers } from "../src/http/server.ts";
1010 import { getStored } from "../src/billing/store.ts";
1111 import { refusedCount, setStripeHookCaps } from "../src/http/stripe_hook.ts";
1212 import { setStripeFetch } from "../src/billing/sync.ts";
13 import { LOOPBACK_PROXIES } from "./helpers/loopback-proxy.ts";
1314
1415 const secret = "whsec_hook_test_secret";
1516 let dir: string;
@@ -19,7 +20,7 @@ let base: string;
1920
2021 beforeAll(async () => {
2122 dir = await mkdtemp(join(tmpdir(), "stripe-hook-"));
22 app = createApp({ dataDir: dir, port: 0 });
23 app = createApp({ dataDir: dir, port: 0 , trustedProxies: LOOPBACK_PROXIES });
2324 servers = await serve(app);
2425 base = `http://127.0.0.1:${servers.port}`;
2526 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs