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

/security tells a visitor in plain words how the forge keeps them safe and how to report a problem #13216

Merged opened this

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

Merged

scout/forge:scout/13208-security-tells-a-visitor-in-plain-words → main 8 commits fork 4 threads · 4 unresolved

  • Merged. scout/13208-security-tells-a-visitor-in-plain-words was merged into main as 2faf288.

Review

Sign in to review this change.
18 files changed +385 −14
docs/design/audit.md +1
@@ -79,6 +79,7 @@ Machine routes are not pages and have no entry: `/audit.csv`,
7979 - `/displays` — `pages/displays.ts` · every display the viewer may read, each with its layout, repository and showcased demos; a stranger signs in first · none yet (read only; a repository's display is its own page) · none seen.
8080 - `/api` — `pages/api.ts` · the forge's OpenAPI operations by area, with search and Try it, public · the footer, the OpenAPI document, the terminal's API screen · none seen. An app's own spec is its `/:owner/:name/api` tab.
8181 - `/contribute` — `pages/contribute.ts` · what this forge is and where outside work is welcome, open to anyone · `/llms.txt`, MCP `contribute` tool · none seen.
82 - `/security` — `pages/security_public.ts` · how the forge keeps a visitor safe and how to report a problem, each claim with its code and test, public · the footer, `/.well-known/security.txt`, `/settings/security` (the admin's side) · none seen.
8283 - `/agents`: `pages/agents.ts` · `/llms.txt` drawn as a page for an assistant whose reader takes only HTML, and for the person beside it, public · the home page's prompt and its Open in ChatGPT, Claude and Grok links · none seen.
8384 - `/search` — `pages/search.ts` · find across what I can read · the palette (`palette.ts`) · none seen.
8485 - `/-/confirm` — `pages/search.ts` (`confirmPage`) · the "are you sure" step for a destructive action · none · none seen.
docs/features/README.md +1
@@ -403,6 +403,7 @@ Read with the guide page [Backups and moving](../guide-backups-moving.md).
403403 Read with the guide page [Every setting, by topic](../guide-settings.md).
404404
405405 - [Account settings help](account-help.md)
406 - [Security, for a visitor](security.md)
406407 - [Devices](devices.md)
407408 - [Edge-only accounts](edge-only-accounts.md)
408409 - [Knobs](knobs.md)
docs/features/security.md added +16
@@ -0,0 +1,16 @@
1 # Security, for a visitor
2
3 `/security` says in plain words what this forge enforces for every app and every visitor with no
4 setting (egress refused by name, code in a cell, sandboxed agents, the sign-in cookie, the
5 cross-site refusal, the response headers) and how to report a problem with no account: the
6 security contact, a sealed security issue, `/<owner>/<name>/report` and an app's own
7 `/__forge/report`. Each row names the file that enforces it.
8
9 Try it: signed out, follow **Security** in the foot of any page, or open `/security`.
10
11 The terminal: open the palette and choose **Security**; the same rows scroll with `j`/`k`, `q`
12 closes. Both read `src/view/security.ts`.
13
14 Every claim names its source and its proof, and `test/security-page.test.ts` fails when a source
15 no longer says what the claim leans on or the proof is gone. Machines read
16 `/.well-known/security.txt`; the admin's side is `/settings/security`.
forge.json +1 −1
@@ -4,7 +4,7 @@
44 "api.github.com"
55 ],
66 "app": {
7 "looks": ["/", "/docs", "/explore", "/board", "/notes", "/review", "/releases", "/apps", "/map", "/system", "/maintenance", "/talk", "/flow", "/resilience", "/boards?help", "/settings/crew", "/settings/crew?help", "/settings/security/controls", "/preview-admin/sample", "/preview-admin/sample/pulls/3", "/preview-admin/sample/next?pick", "/preview-admin/sample/bets", "/preview-admin/sample/waves", "/preview-admin/sample/space"],
7 "looks": ["/", "/docs", "/explore", "/board", "/notes", "/review", "/releases", "/apps", "/security", "/system", "/maintenance", "/talk", "/flow", "/resilience", "/boards?help", "/settings/crew", "/settings/crew?help", "/settings/security/controls", "/preview-admin/sample", "/preview-admin/sample/pulls/3", "/preview-admin/sample/next?pick", "/preview-admin/sample/bets", "/preview-admin/sample/waves", "/preview-admin/sample/space"],
88 "looksAsOwner": ["/", "/board", "/flow", "/boards?help", "/settings/crew", "/settings/crew?help", "/settings/security/controls", "/talk", "/system", "/maintenance", "/resilience", "/preview-admin/sample", "/preview-admin/sample/pulls/3", "/preview-admin/sample/next?pick", "/preview-admin/sample/bets", "/preview-admin/sample/waves", "/preview-admin/sample/space"],
99 "run": "bun run src/main.ts",
1010 "install": "",
src/core/reserved.ts +1
@@ -36,6 +36,7 @@ export const SYSTEM_NAMES: readonly string[] = [
3636 "agent",
3737 "agents",
3838 "privacy",
39 "security",
3940 "pricing",
4041 "bot",
4142 "steward",
src/crew/runner.ts +11 −4
@@ -645,7 +645,10 @@ async function forkTipOf(app: App, pull: Pull): Promise<string | undefined> {
645645 );
646646 }
647647
648 /** What a retried follow-up is told: the latest verdict asking for changes, and the last builder run's final answer. */
648 /**
649 * What a retried follow-up is told: the latest verdict asking for changes, and the last builder
650 * run's final answer.
651 */
649652 function lastTryOf(
650653 app: App,
651654 pullId: string,
@@ -934,7 +937,10 @@ export interface Pause {
934937 readonly summary?: string | undefined;
935938 }
936939
937 /** The file names a conflict or converge run's summary carries, after "main|parent|upstream moved: ". */
940 /**
941 * The file names a conflict or converge run's summary carries, after "main|parent|upstream moved:
942 * ".
943 */
938944 export function conflictFilesOf(summary: string): string[] {
939945 return summary
940946 .replace(/^(main|parent|upstream) moved: /, "")
@@ -2438,8 +2444,9 @@ export function holdModelCredential(key: string, env: Record<string, string>): s
24382444 */
24392445 export function credentialEnv(picked: Pick, dataDir?: string): Record<string, string> {
24402446 if (picked.kind === "ready") return credentialEnvOf(picked);
2441 // A forge its parent funds (#10484): with no account of its own, the crew calls the model through the parent.
2442 // "none" reaches here only under an owner's grant (an org's, #10991), which is the forge's account too.
2447 // A forge its parent funds (#10484): with no account of its own, the crew calls the model through
2448 // the parent. "none" reaches here only under an owner's grant (an org's, #10991), which is the
2449 // forge's account too.
24432450 const lent = (picked.kind === "env" || picked.kind === "none") && dataDir !== undefined ? fundedEnv(dataDir) : undefined;
24442451 if (lent !== undefined) return lent;
24452452 return ownEnv();
src/http/route_marks.ts +1
@@ -162,6 +162,7 @@ export const HEADS: Readonly<Record<string, Mark | "mixed">> = {
162162 "/plugins": "open",
163163 "/pricing": "open",
164164 "/privacy": "open",
165 "/security": "open",
165166 "/recover": "open",
166167 "/releases": "admin",
167168 "/releases.json": "open",
src/http/server.ts +2
@@ -24,6 +24,7 @@ import { secureFor } from "./cookie_secure.ts";
2424 import { refusedByDatabase, shownRefusal } from "./refusal.ts";
2525 import { NOT_A_MEMBER } from "../core/roles.ts";
2626 import { privacyPage } from "../web/pages/privacy.ts";
27 import { publicSecurityPage } from "../web/pages/security_public.ts";
2728 import { startClaimAccountSubmit, startClaimPage, startClaimSubmit } from "../web/pages/start_claim.ts";
2829 import { signupOptions, signupPasskey } from "../web/pages/signup-passkey.ts";
2930 import { toolbarComment, toolbarPage } from "../web/studio/toolbar.ts";
@@ -1056,6 +1057,7 @@ export function buildRouter(): Router<Handler> {
10561057 router.add("GET", "/releases", releasesPage);
10571058 // The forge's own documentation: a redirect built from configuration only.
10581059 router.add("GET", "/privacy", privacyPage);
1060 router.add("GET", "/security", publicSecurityPage);
10591061 router.add("GET", "/docs", docsFolder);
10601062 router.add("GET", "/docs/:file", docsFile);
10611063 router.add("GET", "/docs/features/:file", docsFeature);
src/tui/forge.ts +18 −5
@@ -54,6 +54,7 @@ import { askedScreen } from "./screens/asked.ts";
5454 import { notesScreen } from "./screens/thoughtnotes.ts";
5555 import { deciderScreen } from "./screens/decider.ts";
5656 import { familyScreen } from "./screens/family.ts";
57 import { securityScreen } from "./screens/security_public.ts";
5758 import { familyLines, familyView } from "../spawn/family.ts";
5859 import { issueScreen } from "./screens/issue.ts";
5960 import { pullScreen } from "./screens/pull.ts";
@@ -359,7 +360,8 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] {
359360 hint: "paste a link from another forge; it runs here",
360361 run: () => ctx.push(bringScreen(session, ctx, blank("Bring an app"))),
361362 });
362 // An organization you own, as /organizations/new and MCP `org_create` make it: a person's, never an agent's (#7260).
363 // An organization you own, as /organizations/new and MCP `org_create` make it: a person's,
364 // never an agent's (#7260).
363365 if (session.user !== undefined && session.user.kind !== "agent")
364366 commands.push({
365367 id: "new-org",
@@ -543,7 +545,8 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] {
543545 hint: "concurrency and guards, live; e changes a settable one",
544546 run: () => ctx.push(capacityScreen(session, ctx)),
545547 });
546 // What crawlers cost and who was refused, as GET /api/v1/admin/crawlers: the capacity screen's readers.
548 // What crawlers cost and who was refused, as GET /api/v1/admin/crawlers: the capacity screen's
549 // readers.
547550 if (mayCapacity(session))
548551 commands.push({
549552 id: "crawlers",
@@ -572,7 +575,8 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] {
572575 hint: "the last 30 releases and their pulls",
573576 run: () => ctx.push(changelogScreen(session, ctx)),
574577 });
575 // The live release and the kept ones, as /releases gates them: a site admin or a reader of FORGE_REPO.
578 // The live release and the kept ones, as /releases gates them: a site admin or a reader of
579 // FORGE_REPO.
576580 if (mayRead(session.app, session.user))
577581 commands.push({
578582 id: "releases",
@@ -620,7 +624,8 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] {
620624 hint: "internal hosts an origin may reach",
621625 run: () => ctx.push(trustedHostsPrompt(session, ctx, blank("Trusted hosts"))),
622626 });
623 // Usage: the forge's spend for any signed-in user (#8308); the route list stays the page's gate, the same as Flags (#1565).
627 // Usage: the forge's spend for any signed-in user (#8308); the route list stays the page's
628 // gate, the same as Flags (#1565).
624629 if (session.user !== undefined)
625630 commands.push({
626631 id: "usage",
@@ -652,7 +657,8 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] {
652657 hint: "what your crew may spend, and add your own subscription",
653658 run: () => ctx.push(modelScreen(session, ctx)),
654659 });
655 // The caller's own role and row of the roles table, as /settings and `whoami_can` have it (#2304).
660 // The caller's own role and row of the roles table, as /settings and `whoami_can` have it
661 // (#2304).
656662 if (session.user !== undefined)
657663 commands.push({
658664 id: "can",
@@ -662,6 +668,13 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] {
662668 });
663669 // Entries that live beside their screen, each at the place it names.
664670 addEntries(commands, session, ctx);
671 // What /security says, for anyone (#13208).
672 commands.push({
673 id: "security",
674 title: "Security",
675 hint: "what the forge enforces for everyone, and how to report a problem",
676 run: () => ctx.push(securityScreen(ctx)),
677 });
665678 commands.push({
666679 id: "family",
667680 title: "Family",
src/tui/screens/security_public.ts added +60
@@ -0,0 +1,60 @@
1 /**
2 * Security in the terminal (#13208): the same claims /security shows, from
3 * `view/security.ts`, as scrolling lines. Offered to everyone, signed in or
4 * not, like the page. Read-only.
5 */
6
7 import { CLAIMS, REPORT_CLAIMS, SECURITY_PURPOSE, type Claim } from "../../view/security.ts";
8 import type { Ctx, Screen } from "../app/app.ts";
9 import { binding } from "../app/keys.ts";
10 import { BOLD, style } from "../term/style.ts";
11 import { wrap } from "../term/width.ts";
12 import { Scroll, drawLines, hitScroll } from "./common.ts";
13
14 type Line = { text: string; kind: "head" | "label" | "body" | "muted" };
15
16 /** The screen's lines at a width: plain data, so a test reads what a person reads. */
17 export function securityLines(width: number): Line[] {
18 const w = Math.max(20, width);
19 const out: Line[] = [];
20 const para = (text: string, kind: Line["kind"]) => {
21 for (const t of wrap(text, w)) out.push({ text: t, kind });
22 };
23 const claim = (c: Claim) => {
24 out.push({ text: c.what, kind: "label" });
25 para(` ${c.words}`, "body");
26 para(` Enforced in ${c.source}.`, "muted");
27 };
28 para(SECURITY_PURPOSE, "body");
29 out.push({ text: "", kind: "body" }, { text: "Enforced for everyone, with no setting", kind: "head" });
30 CLAIMS.forEach(claim);
31 out.push({ text: "", kind: "body" }, { text: "Report a problem", kind: "head" });
32 para("A vulnerability: tell the contact in /.well-known/security.txt on this forge.", "body");
33 REPORT_CLAIMS.forEach(claim);
34 return out;
35 }
36
37 export function securityScreen(ctx: Ctx): Screen {
38 const scroll = new Scroll();
39 let count = 0;
40 return {
41 title: "Security",
42 keys: [binding(["j", "k"], "scroll"), binding(["esc", "q"], "back")],
43 render(area, s) {
44 const c = ctx.theme.c;
45 const tone = { head: style(c.fg, c.bg, BOLD), label: style(c.fg, c.bg, BOLD), body: style(c.fg, c.bg), muted: style(c.mutedFg, c.bg) };
46 const lines = securityLines(area.w - 2);
47 count = lines.length;
48 drawLines(s, area, c, scroll, lines.map((l) => [{ text: l.text, style: tone[l.kind] }]));
49 hitScroll(ctx, area, scroll, count);
50 },
51 key(e) {
52 if (scroll.key(e, count)) return true;
53 if (e.key === "esc" || e.key === "q") {
54 ctx.pop();
55 return true;
56 }
57 return false;
58 },
59 };
60 }
src/view/security.ts added +110
@@ -0,0 +1,110 @@
1 /**
2 * What /security says (#13208), as plain data the page and the terminal screen
3 * both draw: each claim names the file that enforces it and the test that
4 * proves it, and test/security-page.test.ts checks both still stand, so a claim
5 * cannot outlive its behaviour.
6 */
7
8 import { REFUSED_PREFIX } from "../apps/egress.ts";
9
10 /** One thing the forge does for every app and every visitor, with no setting to turn it on. */
11 export interface Claim {
12 /** The row's label: what is kept safe, in a word or two. */
13 what: string;
14 /** The sentence a visitor reads. */
15 words: string;
16 /** The file that enforces it, from the repository root. */
17 source: string;
18 /** Text that file must still contain for the sentence to stay true. */
19 needle: string;
20 /** The test that proves the behaviour. */
21 proof: string;
22 }
23
24 export const CLAIMS: readonly Claim[] = [
25 {
26 what: "Outside hosts",
27 words: `An app reaches only the hosts its forge.json egress names; any other is refused with a 403 that says "${REFUSED_PREFIX} <host> is not in this app's forge.json egress".`,
28 source: "src/apps/egress.ts",
29 needle: "is not in this app's forge.json egress",
30 proof: "test/egress-refused.test.ts",
31 },
32 {
33 what: "Repository code",
34 words:
35 "An app, its preview, its terminal and every install and test step run in a cell of their own: the machine is read-only to them, they see no other process, and the forge's proxy is their only way out.",
36 source: "src/apps/contain.ts",
37 needle: "bubblewrap",
38 proof: "test/contain.test.ts",
39 },
40 {
41 what: "Agents",
42 words:
43 "An agent's shell reaches the forge, the package registry and its own app, writes only in its own clone, and cannot read the forge's data, keys or other agents' work.",
44 source: "src/crew/sandbox.ts",
45 needle: "export function sandboxPolicy",
46 proof: "test/crew-sandbox.test.ts",
47 },
48 {
49 what: "Weaker machines",
50 words:
51 "Where a machine cannot hold a cell or a sandbox, the forge still runs and says so to its admin at the foot of every page.",
52 source: "src/kernel/protection.ts",
53 needle: "export function protectionNotice",
54 proof: "test/protection.test.ts",
55 },
56 {
57 what: "Your sign-in",
58 words:
59 "It lives in a cookie scripts cannot read (HttpOnly), other sites cannot send (SameSite=Lax), and that travels only over https when the forge is served over https (Secure).",
60 source: "src/auth/cookies.ts",
61 needle: '"HttpOnly", "SameSite=Lax"',
62 proof: "test/cookie-flags.test.ts",
63 },
64 {
65 what: "Changes from other sites",
66 words:
67 "A POST, PUT, PATCH or DELETE your browser sends from another site with your sign-in is refused before any code acts on it.",
68 source: "src/http/origin_gate.ts",
69 needle: 'new Set(["POST", "PUT", "PATCH", "DELETE"])',
70 proof: "test/origin-every-mutation.test.ts",
71 },
72 {
73 what: "Every answer",
74 words:
75 "It tells your browser not to guess its type (nosniff) and not to send the address you were on to another site (Referrer-Policy: same-origin).",
76 source: "src/http/respond.ts",
77 needle: "export function securityFloor",
78 proof: "test/security-floor-every-route.test.ts",
79 },
80 ];
81
82 /** The ways to tell someone about a problem; the security contact is drawn beside them. */
83 export const REPORT_CLAIMS: readonly Claim[] = [
84 {
85 what: "Sealed report",
86 words:
87 'In a repository here, open an issue and tick "Sealed security report": only people who can write there and its crew see it, until one of them unseals it.',
88 source: "src/core/sealed.ts",
89 needle: "export function canSeeSealed",
90 proof: "test/sealed-issues.test.ts",
91 },
92 {
93 what: "A repository",
94 words: "Any public repository takes a report at /<owner>/<name>/report, with no account.",
95 source: "src/http/server.ts",
96 needle: 'router.add("GET", "/:owner/:name/report", reportPage)',
97 proof: "test/reports.test.ts",
98 },
99 {
100 what: "An app",
101 words: "Every public app takes one at /__forge/report on its own address, even while the app is down.",
102 source: "src/apps/proxy.ts",
103 needle: 'url.pathname === "/__forge/report"',
104 proof: "test/apps-report.test.ts",
105 },
106 ];
107
108 /** The page's opening sentence, said once on both surfaces. */
109 export const SECURITY_PURPOSE =
110 "What this forge enforces for every app and visitor without a setting, and how to report a problem without an account.";
src/web/layout.ts +2
@@ -754,6 +754,8 @@ function footer(ctx: Ctx, own?: Html): Html {
754754 <span class="spacer"></span>
755755 <a href="/docs">Docs</a>
756756 <a href="/pricing">Pricing</a>
757 <a href="/privacy">Privacy</a>
758 <a href="/security">Security</a>
757759 <a href="/changelog">Changelog</a>
758760 <a href="/api">API</a>
759761 ${ctx.auth.user !== undefined && ctx.auth.user.kind !== "org"
src/web/pages/security_public.ts added +56
@@ -0,0 +1,56 @@
1 /**
2 * GET /security (#13208): how the forge keeps a visitor safe and how to tell
3 * someone about a problem, in plain words — /.well-known/security.txt for
4 * people. Public, static, server-rendered in the shared layout. Each claim
5 * is a `status-rows` row (what, then the sentence and the file that enforces
6 * it); the claims are plain data in `view/security.ts`, which the terminal's
7 * Security screen draws too. (/settings/security, the admin's page, is
8 * `security.ts`.)
9 */
10
11 import { publicForgeRepo } from "../../core/forge_repo.ts";
12 import { notePhase, takeSessionTime, timePhase } from "../../core/route_timing.ts";
13 import type { Ctx } from "../../http/context.ts";
14 import { CLAIMS, REPORT_CLAIMS, SECURITY_PURPOSE, type Claim } from "../../view/security.ts";
15 import { html, type Html } from "../html.ts";
16 import { page } from "../layout.ts";
17 import { securityContact } from "../standards.ts";
18
19 function claimRow(c: Claim): Html {
20 return html`<div class="status-row">
21 <dt>${c.what}</dt>
22 <dd>${c.words} <span class="small muted">Enforced in <code>${c.source}</code>.</span></dd>
23 </div>`;
24 }
25
26 /** The contact as a row: a link only when it is http(s), else plain text. */
27 function contactRow(contact: string): Html {
28 const shown = /^https?:\/\//.test(contact)
29 ? html`<a href="${contact}">${contact}</a>`
30 : html`<code>${contact}</code>`;
31 return html`<div class="status-row">
32 <dt>A vulnerability</dt>
33 <dd>Tell ${shown}. Machines read the same at <a href="/.well-known/security.txt">/.well-known/security.txt</a>.</dd>
34 </div>`;
35 }
36
37 /** The page's body: plain data in (the contact), escaped HTML out. */
38 export function securityBody(contact: string): Html {
39 return html`<div class="page-head"><h1>Security</h1></div>
40 <p class="mb">${SECURITY_PURPOSE}</p>
41 <h2>Enforced for everyone, with no setting</h2>
42 <dl class="status-rows">${CLAIMS.map(claimRow)}</dl>
43 <h2>Report a problem</h2>
44 <dl class="status-rows">${contactRow(contact)}${REPORT_CLAIMS.map(claimRow)}</dl>`;
45 }
46
47 export function publicSecurityPage(ctx: Ctx): Response {
48 notePhase(ctx.request, "session", takeSessionTime(ctx.request));
49 return timePhase(ctx.request, "render", () =>
50 page({
51 ctx,
52 title: "Security",
53 body: securityBody(securityContact(ctx, publicForgeRepo(ctx.app))),
54 }),
55 );
56 }
src/web/standards.ts +1 −1
@@ -78,7 +78,7 @@ function text(body: string, type = "text/plain; charset=utf-8"): Response {
7878 * page on this forge — already public, and a real way to reach whoever
7979 * runs it.
8080 */
81 function securityContact(ctx: Ctx, own: Repo | undefined): string {
81 export function securityContact(ctx: Ctx, own: Repo | undefined): string {
8282 const configured = process.env["FORGE_SECURITY_CONTACT"]?.trim();
8383 if (configured) return configured;
8484 if (own !== undefined)
test/forge-looks.test.ts +1
@@ -37,6 +37,7 @@ const NOT_A_PAGE: Record<string, string> = {
3737 "/family": "no picture: its slot went to the preview's /waves and /milestones; the page is covered by its own tests",
3838 "/llms.txt": "plain markdown for machines, not a page to picture",
3939 "/agents": "/llms.txt drawn as a page for an assistant; no picture: not in app.looks, and test/agents-page.test.ts covers it",
40 "/map": "no picture: its slot went to /security, the visitor's security page (#13208); covered by test/map-cache.test.ts and the other map tests",
4041 "/packs": "no picture: not in app.looks; the page is covered by test/packs.test.ts",
4142 "/fleet": "no picture: not in app.looks; the page is covered by test/fleet-table.test.ts",
4243 "/robots.txt": "plain text for crawlers",
test/palette-roster.test.ts +4
@@ -212,6 +212,7 @@ test("a site-admin person is offered the whole roster", () => {
212212 ["origin-ahead", "New commits upstream", "mirrors whose origin has moved on: take them"],
213213 ["profile", "Your profile", "display name and email"],
214214 ["dotfiles", "Your dotfiles", "the repository every shell you open copies from"],
215 ["security", "Security", "what the forge enforces for everyone, and how to report a problem"],
215216 ["family", "Family", "the forge that sent this one, and the forges it sent"],
216217 ["chain", "Chain", "the forges this forge's code descends from, root first"],
217218 ["quit", "Quit", "disconnect"],
@@ -303,6 +304,7 @@ test("a site-admin agent is offered the roster without the person-only entries",
303304 ["origin-ahead", "New commits upstream", "mirrors whose origin has moved on: take them"],
304305 ["front-milestones", "Milestones", "the biggest open milestones: how far, what landed this week"],
305306 ["forge-view", "Forge view", "the forge's counts, and Foundry when it is installed"],
307 ["security", "Security", "what the forge enforces for everyone, and how to report a problem"],
306308 ["family", "Family", "the forge that sent this one, and the forges it sent"],
307309 ["chain", "Chain", "the forges this forge's code descends from, root first"],
308310 ["quit", "Quit", "disconnect"],
@@ -399,6 +401,7 @@ test("a member person is offered the signed-in roster without the admin entries"
399401 ["dotfiles", "Your dotfiles", "the repository every shell you open copies from"],
400402 ["front-milestones", "Milestones", "the biggest open milestones: how far, what landed this week"],
401403 ["forge-view", "Forge view", "the forge's counts, and Foundry when it is installed"],
404 ["security", "Security", "what the forge enforces for everyone, and how to report a problem"],
402405 ["family", "Family", "the forge that sent this one, and the forges it sent"],
403406 ["chain", "Chain", "the forges this forge's code descends from, root first"],
404407 ["quit", "Quit", "disconnect"],
@@ -449,6 +452,7 @@ test("signed out, the palette offers sign-in and the public entries", () => {
449452 ["front", "Front page", "the apps a first visitor sees, ranked; an admin pins or hides"],
450453 ["origin-ahead", "New commits upstream", "mirrors whose origin has moved on: take them"],
451454 ["front-milestones", "Milestones", "the biggest open milestones: how far, what landed this week"],
455 ["security", "Security", "what the forge enforces for everyone, and how to report a problem"],
452456 ["family", "Family", "the forge that sent this one, and the forges it sent"],
453457 ["chain", "Chain", "the forges this forge's code descends from, root first"],
454458 ["quit", "Quit", "disconnect"],
test/security-page.test.ts added +92
@@ -0,0 +1,92 @@
1 /**
2 * GET /security (#13208): public, in the shared layout, linked from the foot,
3 * each claim a row; every claim still stands on the file and test it names,
4 * and the terminal's Security screen says the same.
5 */
6 import { afterAll, beforeAll, expect, test } from "bun:test";
7 import { existsSync, readFileSync } from "node:fs";
8 import { mkdtemp, rm } from "node:fs/promises";
9 import { tmpdir } from "node:os";
10 import { join } from "node:path";
11 import { createApp, type App } from "../src/app.ts";
12 import { serve, type Servers } from "../src/http/server.ts";
13 import { escapeHtml } from "../src/web/html.ts";
14 import { CLAIMS, REPORT_CLAIMS, SECURITY_PURPOSE } from "../src/view/security.ts";
15 import { securityBody } from "../src/web/pages/security_public.ts";
16 import { securityLines } from "../src/tui/screens/security_public.ts";
17
18 const root = join(import.meta.dir, "..");
19 let dir: string;
20 let app: App;
21 let servers: Servers;
22
23 beforeAll(async () => {
24 dir = await mkdtemp(join(tmpdir(), "forge-security-page-"));
25 app = createApp({ dataDir: dir, port: 0 });
26 servers = await serve(app);
27 });
28 afterAll(async () => {
29 servers.stop();
30 app.close();
31 await rm(dir, { recursive: true, force: true });
32 });
33
34 test("signed out, /security answers 200 in the shared layout: one opening sentence, a row per claim, the security floor", async () => {
35 const res = await fetch(`${servers.url}/security`);
36 expect(res.status).toBe(200);
37 const text = await res.text();
38 expect(text).toContain('class="topbar');
39 expect(text).toMatch(/<title>Security[^<]*<\/title>/);
40 expect(text).toContain(`<p class="mb">${escapeHtml(SECURITY_PURPOSE)}</p>`);
41 expect(res.headers.get("x-content-type-options")).toBe("nosniff");
42 expect(res.headers.get("referrer-policy")).toBe("same-origin");
43 expect(res.headers.get("content-security-policy")).toBeTruthy();
44 for (const c of [...CLAIMS, ...REPORT_CLAIMS]) {
45 expect(text).toContain(`<dt>${escapeHtml(c.what)}</dt>`);
46 expect(text).toContain(escapeHtml(c.words));
47 }
48 expect(text).toContain('href="/.well-known/security.txt"');
49 });
50
51 test("the contact it names is security.txt's own", async () => {
52 const txt = await (await fetch(`${servers.url}/.well-known/security.txt`)).text();
53 const contact = /^Contact: (.+)$/m.exec(txt)?.[1];
54 expect(contact).toBeDefined();
55 const page = await (await fetch(`${servers.url}/security`)).text();
56 expect(page).toContain(escapeHtml(contact!));
57 });
58
59 test("every claim's source still says what the claim leans on, and its proof exists", () => {
60 expect(CLAIMS.length).toBeGreaterThanOrEqual(5);
61 expect(REPORT_CLAIMS.map((c) => c.words).join(" ")).toContain("/__forge/report");
62 for (const c of [...CLAIMS, ...REPORT_CLAIMS]) {
63 expect(readFileSync(join(root, c.source), "utf8")).toContain(c.needle);
64 expect(existsSync(join(root, c.proof))).toBe(true);
65 }
66 // The cookie claim names flags the cookie test asserts.
67 const cookieTest = readFileSync(join(root, "test/cookie-flags.test.ts"), "utf8");
68 for (const flag of ["HttpOnly", "SameSite", "Secure"]) expect(cookieTest).toContain(flag);
69 });
70
71 test("a contact is escaped, and only an http(s) one becomes a link", () => {
72 const evil = securityBody('mailto:a@b"><x>').text;
73 expect(evil).not.toContain("<x>");
74 expect(evil).not.toContain('href="mailto');
75 expect(securityBody("https://f.example/sec").text).toContain('href="https://f.example/sec"');
76 });
77
78 test("the foot of a shared page links /security beside /privacy", async () => {
79 const text = await (await fetch(`${servers.url}/pricing`)).text();
80 expect(text).toMatch(/<a href="\/privacy">Privacy<\/a>\s*<a href="\/security">Security<\/a>/);
81 });
82
83 test("the terminal's Security screen carries every claim, wrapped to its width", () => {
84 const lines = securityLines(60);
85 for (const l of lines) expect(l.text.length).toBeLessThanOrEqual(60);
86 const joined = lines.map((l) => l.text.trim()).join(" ");
87 expect(joined).toContain(SECURITY_PURPOSE);
88 for (const c of [...CLAIMS, ...REPORT_CLAIMS]) {
89 expect(lines.some((l) => l.kind === "label" && l.text === c.what)).toBe(true);
90 expect(joined).toContain(c.words);
91 }
92 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs