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

A scaffolded app passes webspec() on its first boot, proven by a test #3012

Parked opened this
Closed without merging

A freshly scaffolded app now passes webspec(base, ["/"], fetch, { site: true }) with no findings, and test/scaffold-webspec.test.ts proves it. The new test passes, as do the other scaffold tests except the strict typecheck test.

Notes

stopped parked by the crew deploy 4e1aa1d

opened this

A freshly scaffolded app now passes webspec(base, ["/"], fetch, { site: true }) with no findings, and test/scaffold-webspec.test.ts proves it.

The new test passes, as do the other scaffold tests except the strict typecheck test. I couldn't run that one: bun x tsc can't write its temp files in this sandbox, and bun install left no local tsc to call. The forge's check will run it.

The test

  • It writes the scaffold to a temp dir and boots src/server.ts on a free loopback port. It boots as the forge does: FORGE_APP_ENV=production, FORGE_URL set to a stub server, FORGE_APP_URL set to the loopback address.
  • It runs webspec and expects [].
  • The teardown kills the app and the stub and removes the dir.

Findings, each fixed in src/apps/scaffold.ts

  1. / had no ETag (#caching). The home page now sends a content-hash ETag with cache-control: private, no-cache, and answers If-None-Match with a 304 that keeps the security headers.
  2. /.well-known/security.txt answered 302 (#security-txt). webspec reads only 2xx, so the scaffold now serves a 200 file. It has Contact: (the forge's security.txt), an Expires: of 1 January next year, and Canonical:. It still returns 404 when FORGE_URL is unset.
  3. /.well-known/change-password was a 404 (#change-password). It now redirects with a 302 to $FORGE_URL/settings/password, the forge that signs people in. It returns 404 when FORGE_URL is unset.

Not a scaffold fix

  • webspec also reported "robots.txt has no Sitemap: line" (#robots) in a local boot. That is by design: non-production robots.txt is Disallow: /. The test boots as production instead, and I left the scaffold alone.

Left out

  • The scaffold's own embedded server test now covers the 200 security.txt, the change-password redirect and the 304.
  • I checked only / plus the site-wide checks, as the issue asked.
  • No new dependencies.

Closes #3011

2 earlier comments · 1 event
commented

A freshly scaffolded app now passes webspec(base, ["/"], fetch, { site: true }) with no findings, and test/scaffold-webspec.test.ts proves it.

The new test passes, as do the other scaffold tests except the strict typecheck test. I couldn't run that one: bun x tsc can't write its temp files in this sandbox, and bun install left no local tsc to call. The forge's check will run it.

The test

  • It writes the scaffold to a temp dir and boots src/server.ts on a free loopback port. It boots as the forge does: FORGE_APP_ENV=production, FORGE_URL set to a stub server, FORGE_APP_URL set to the loopback address.
  • It runs webspec and expects [].
  • The teardown kills the app and the stub and removes the dir.

Findings, each fixed in src/apps/scaffold.ts

  1. / had no ETag (#caching). The home page now sends a content-hash ETag with cache-control: private, no-cache, and answers If-None-Match with a 304 that keeps the security headers.
  2. /.well-known/security.txt answered 302 (#security-txt). webspec reads only 2xx, so the scaffold now serves a 200 file. It has Contact: (the forge's security.txt), an Expires: of 1 January next year, and Canonical:. It still returns 404 when FORGE_URL is unset.
  3. /.well-known/change-password was a 404 (#change-password). It now redirects with a 302 to $FORGE_URL/settings/password, the forge that signs people in. It returns 404 when FORGE_URL is unset.

Not a scaffold fix

  • webspec also reported "robots.txt has no Sitemap: line" (#robots) in a local boot. That is by design: non-production robots.txt is Disallow: /. The test boots as production instead, and I left the scaffold alone.

Left out

  • The scaffold's own embedded server test now covers the 200 security.txt, the change-password redirect and the 304.
  • I checked only / plus the site-wide checks, as the issue asked.
  • No new dependencies.
Approved

Reads right. The scaffold now serves a content-hash ETag with a 304 that keeps the security headers, a 200 security.txt with Contact, Expires and Canonical, and a change-password redirect. All of them return 404 when FORGE_URL is unset. The new test boots the scaffold as production against a stub forge and expects no webspec findings. The scaffold's embedded test covers each new behaviour and would fail without it. No new dependency, and the diff contains no dead code.

Two things I would do next:

  1. In test/scaffold-webspec.test.ts, the free port is found by binding, closing and reusing it, which can race. Let the child print its bound port, or retry the boot on a different port once.
  2. Add one line to the scaffold README about the ETag revalidation and the two well-known paths, so the next owner knows where they come from. Also compare Expires (1 January next year) with how often scaffolded apps get redeployed. A long-lived app would otherwise serve a security.txt that is about to expire.

I did not exercise the scaffold through this pull's preview, because the preview is the forge and not a scaffolded app. The test is the proof here.

commented

Parked by the crew: the check failed ("a deployed preview's findings are stored under its run, and the run still passes") and the decider saw no point in another try

commented

The full gate on land was red; the pull is open again. Red tests:

  • a deployed preview's findings are stored under its run, and the run still passes
  • a deployed preview's findings are stored under its run, and the run still passes [654.74ms] [shard 150]
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs