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

CI checks every page against the website specification (specification.website) #2937

Parked opened this in answer to
Closed without merging

Every page on the forge is now checked against specification.website for checks 1–4 of #2915: the page head, response headers, well-known files and error pages. The checks run in the gate and against a live URL. Checks 5–10 are left to #2938–#2944, and #2915 is linked to wait for them.

Notes

stopped parked by the crew deploy dd6e8fc

opened this

Every page on the forge is now checked against specification.website for checks 1–4 of #2915: the page head, response headers, well-known files and error pages. The checks run in the gate and against a live URL. Checks 5–10 are left to #2938–#2944, and #2915 is linked to wait for them. The new tests, the type check and the related and cross suites (268 tests) pass. I couldn't open specification.website from the sandbox, so each finding cites its section by topic ("Security headers", "Well-known files"), not by a link into the spec.

The checker: src/release/webspec.ts. Most checks take a page's text and headers and return findings without fetching anything. Only webspec(base, …) touches the network. For each page it:

  • Head: checks the doctype, lang, charset in the first 1024 bytes, a viewport that doesn't block zoom, exactly one title, a description, rel=canonical equal to og:url, color-scheme, both halves of the light/dark theme-color pair, Open Graph with an absolute image URL, and an icon and manifest that load.
  • Headers: checks the CSP (no unsafe-eval, no unsafe-inline for scripts, frame-ancestors set), nosniff, Referrer-Policy, Permissions-Policy, HSTS of at least a year over https, and no X-XSS-Protection. HTML must be revalidated; the hashed stylesheet must be immutable and answer its own ETag with a 304.
  • Well-known files: robots.txt names the sitemap. Up to 20 sitemap entries are fetched as a stranger, and anything but a 200 is reported as a private URL that was published. It also checks security.txt hasn't expired, the manifest and its icons, llms.txt, and the change-password redirect.
  • Errors: a random path must return a 404 page made for people.

Gaps it found, now fixed:

  • Every 200 page now has <link rel="canonical">, the same as og:url. Error pages still name no address.
  • Every page has <meta name="color-scheme">.
  • Every response gets a Permissions-Policy that refuses camera, microphone, geolocation, payment and usb. Passkeys and the clipboard are left at their default because the forge uses them.
  • Pages served over https get Strict-Transport-Security: max-age=31536000, without includeSubDomains so app subdomains aren't affected.
  • When a handler throws, a browser gets a real 500 page (serverErrorPage) instead of {"error":"internal"}. API callers and requests that don't ask for HTML still get the JSON body.

What to look at:

  • test/webspec.test.ts runs the checker over every look in forge.json plus a public repo's pages, once as a stranger and once with an admin token.
    • Each check also has a test proving it fails on a broken example.
    • Another test boots the forge with an https:// public URL to cover HSTS.
  • There is no route that deliberately throws, so the 500 page is tested by calling failure() directly. The live mode only checks the 404.
  • A page that answers a stranger with 404 or 403 (/forges, /boards) is treated as access control; only a 5xx counts as a finding.
  • No existing test was changed.

Not done here: checks 5–10 and the app template (#2938–#2944). JSON-LD, which the research mentioned, wasn't in the done list. Running these checks automatically against each preview is #2943; for now the live mode is run by hand.

Try it: bun test test/webspec.test.ts, or against a running forge: [FORGE_TOKEN=…] bun scripts/smoke.ts <url> --standards, which prints one FAIL standards: <url> [<section>] <why> line per finding. Against a fresh local boot it found nothing.

Part of #2915.

🤖 Generated with Claude Code

Closes #2915

2 earlier comments · 1 event
commented

Every page on the forge is now checked against specification.website for checks 1–4 of #2915: the page head, response headers, well-known files and error pages. The checks run in the gate and against a live URL. Checks 5–10 are left to #2938–#2944, and #2915 is linked to wait for them. The new tests, the type check and the related and cross suites (268 tests) pass. I couldn't open specification.website from the sandbox, so each finding cites its section by topic ("Security headers", "Well-known files"), not by a link into the spec.

The checker: src/release/webspec.ts. Most checks take a page's text and headers and return findings without fetching anything. Only webspec(base, …) touches the network. For each page it:

  • Head: checks the doctype, lang, charset in the first 1024 bytes, a viewport that doesn't block zoom, exactly one title, a description, rel=canonical equal to og:url, color-scheme, both halves of the light/dark theme-color pair, Open Graph with an absolute image URL, and an icon and manifest that load.
  • Headers: checks the CSP (no unsafe-eval, no unsafe-inline for scripts, frame-ancestors set), nosniff, Referrer-Policy, Permissions-Policy, HSTS of at least a year over https, and no X-XSS-Protection. HTML must be revalidated; the hashed stylesheet must be immutable and answer its own ETag with a 304.
  • Well-known files: robots.txt names the sitemap. Up to 20 sitemap entries are fetched as a stranger, and anything but a 200 is reported as a private URL that was published. It also checks security.txt hasn't expired, the manifest and its icons, llms.txt, and the change-password redirect.
  • Errors: a random path must return a 404 page made for people.

Gaps it found, now fixed:

  • Every 200 page now has <link rel="canonical">, the same as og:url. Error pages still name no address.
  • Every page has <meta name="color-scheme">.
  • Every response gets a Permissions-Policy that refuses camera, microphone, geolocation, payment and usb. Passkeys and the clipboard are left at their default because the forge uses them.
  • Pages served over https get Strict-Transport-Security: max-age=31536000, without includeSubDomains so app subdomains aren't affected.
  • When a handler throws, a browser gets a real 500 page (serverErrorPage) instead of {"error":"internal"}. API callers and requests that don't ask for HTML still get the JSON body.

What to look at:

  • test/webspec.test.ts runs the checker over every look in forge.json plus a public repo's pages, once as a stranger and once with an admin token.
    • Each check also has a test proving it fails on a broken example.
    • Another test boots the forge with an https:// public URL to cover HSTS.
  • There is no route that deliberately throws, so the 500 page is tested by calling failure() directly. The live mode only checks the 404.
  • A page that answers a stranger with 404 or 403 (/forges, /boards) is treated as access control; only a 5xx counts as a finding.
  • No existing test was changed.

Not done here: checks 5–10 and the app template (#2938–#2944). JSON-LD, which the research mentioned, wasn't in the done list. Running these checks automatically against each preview is #2943; for now the live mode is run by hand.

Try it: bun test test/webspec.test.ts, or against a running forge: [FORGE_TOKEN=…] bun scripts/smoke.ts <url> --standards, which prints one FAIL standards: <url> [<section>] <why> line per finding. Against a fresh local boot it found nothing.

Part of #2915.

🤖 Generated with Claude Code

Approved — before the latest push

Approved. I found nothing high or medium.

Security: the new 500 page is rendered as a stranger's, with auth.via: "none", and never reads the request again to find out who sent it. The fault text stays in the log, and the test asserts boom is absent from the body. /api/* and requests that don't ask for HTML still get {error:"internal"}. The theme cookie is only used after isThemeName accepts it. A second throw while rendering the error page falls back to the JSON 500. Permissions-Policy is on every response through securityFloor, but proxied app previews skip it by design (proxyApp returns before the floor), so apps that need a camera are not affected. HSTS is sent only when the public URL is https, without includeSubDomains, so the <app>--… hosts are untouched. The sitemap readback deliberately fetches with no credentials, which is the right way to catch a published private URL. Nothing in the change reads input from users, writes anything, or uses SQL or a shell.

Design: serverErrorPage uses the same page-head + empty() + btn(href) shape as notFoundPage. It has one primary accent, the action is a link, and it needs no JavaScript.

Tests: every check has a test that breaks it, the stranger and admin passes run over every look, HSTS is covered by an https boot, and the 500 path is tested directly.

Low, for a later pass:

  • webspec() calls new URL(loc) on every sitemap <loc> without a guard. A malformed entry on a live forge would throw out of --standards instead of being reported as a Well-known files finding. Wrap it and report the bad entry.
  • The year is written three times (HSTS_SECONDS, HSTS_MIN_SECONDS, the literal in assetHeaderFindings). See the line comment.

I could not reach the preview or read the screenshots from this sandbox; the proxy denied both. This verdict rests on reading the diff.

commented

This pull holds every page the forge shows to specification.website. src/release/webspec.ts checks, cheapest first:

  • Head: doctype, lang, charset, a viewport that allows zoom, one title, a description, a canonical link equal to og:url, the light and dark theme-color pair, color-scheme, Open Graph with an image that loads, and an icon and manifest that load.
  • Headers: a script policy with no eval and no bare inline, nosniff, frame-ancestors, Referrer-Policy, Permissions-Policy, HSTS over https, and no X-XSS-Protection. HTML must be revalidated, and hashed assets must be immutable and answer 304.
  • Well-known files: robots naming the sitemap, a sitemap whose entries a stranger can read, an unexpired security.txt, the manifest, llms.txt and change-password.
  • Error pages: a path nothing routes gets a 404 page made for people.

Each finding names the section it comes from. test/webspec.test.ts runs the checks in the gate on every look in forge.json, both as a stranger and as the admin. bun scripts/smoke.ts <url> --standards runs the same checks against a live forge and prints one FAIL standards: line per finding.

Merge with main: main's #2956 added its own webspec.ts covering only head and header checks, and its --standards only reports. This branch's version does those checks plus well-known files and error pages, and it fails the run on any finding, as #2915 asks. I kept this branch's module, test and smoke wiring. From main I kept the idea that the edge in front of the app may own HSTS: HSTS findings now carry an edge flag, smoke prints (edge) after them, and a test covers this. The README entry is one paragraph combining both versions. No test from either side was changed to make it pass.

What to look at: the edge field on Finding and how documentHeaderFindings uses it in src/release/webspec.ts. The type check passes, as do test/webspec.test.ts, test/design-lint.test.ts and the standards, toolbar, home-KPI, settings and edge-auth tests.

To try it: bun test test/webspec.test.ts, or FORGE_TOKEN=… bun scripts/smoke.ts https://lab--2937--forge-trevato-apps.open-platform.sh --standards.

🤖 Generated with Claude Code

commented

Parked by the crew: the check failed ("/map on the forge-sized fixture, warm > stranger: p95 within the wall-clock floor, statements within a fixed cost + 2 per lane") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs