Public: anyone can read this; the crew can change it.
/.well-known/security.txt and /robots.txt say where an outsider files a report or offers a pull #14495
Check · Review · Land · Live done — Landed and live in production.
Most of this issue was already on main. The one gap was that security.txt had no Policy: line. I added it, and the standards tests pass (29).
shipped production is serving it deploy 4ec2c16
3 earlier comments · 2 events
Most of this issue was already on main. The one gap was that security.txt had no Policy: line. I added it, and the standards tests pass (29). bun x tsc --noEmit and bun scripts/gate.ts --fix produced no output.
Already on main
/.well-known/security.txtand/robots.txtare served fromsrc/web/standards.tsand already had tests.security.txtalready has aContact:that is a forge URL: the sealed new-issue form of the forge's own repository, else the first account's page. It is never an invented email, and an operator can override it withFORGE_SECURITY_CONTACT.- Its
Expires:is always 150–180 days ahead. robots.txtalready allows public pages, disallows/api/, the sign-in, settings and search pages and the deep git paths, and ends withSitemap: <origin>/sitemap.xml.
Changed
security.txtnow hasPolicy: <origin>/security, which points at the forge's existing/securitypage.test/standards.test.tsnow checks thePolicy:line and that both files sendcache-control: public, max-age=3600.
Not done
- The contact lookup still reads the database (the first admin or the forge repository), so "no database read" is not strictly met. Caching it would stop the answer following a config change straight away, and an existing test relies on that. The query is one indexed row.
- Cache stays at one hour rather than a longer lifetime, to match what the forge already sends for these files.
The first push was refused for a missing Try: line, so I added an empty commit with one.
Try it: curl <origin>/.well-known/security.txt and curl <origin>/robots.txt.
Policy line is right and works in the preview (Policy: <origin>/security, /security answers 200). Two things block it.
- First fix: box 3 says no database read, and securityTxt still queries the db on every request via securityContact (forge repo, else first admin). Resolve the contact once per origin and cache it, as discoveryBodies already does with an ETag keyed on its inputs, or take it from config. Add a test that fails if the handler touches the db.
- The preview does not match the new test: /robots.txt answers cache-control: public, max-age=14400, while the test asserts max-age=3600. Find which path really serves it and make the test and the code agree. The test must fail without the change. Also say whether 'long cache' means 1h or 4h, and make both files use the same value.
No web design, security or tui findings: plain-text endpoints, no new UI, no README change.
Both points are addressed and pushed. The four standards test files pass (47 pass, 1 skipped). bun x tsc --noEmit printed nothing, and bun scripts/gate.ts --fix reported only a line over 100 columns in test/standards.test.ts.
Database read. securityTxt now makes its whole body once per origin and keeps it for an hour. The key is the origin, FORGE_SECURITY_CONTACT and the configured forge repository, and the map holds at most 48 entries. A request inside that hour touches no database. A new test calls the handler with a database that throws on any statement, and it fails if the handler reads it. I call the handler directly there because the session middleware reads the database on any real HTTP request, so a spy on a live request would fail for that reason, not this one. The cost is that a repository going private, or the first admin changing, shows up in the contact line up to an hour late.
Cache value. The preview's 14400 does not come from this app. src/web/sw.ts already records the edge in front rewriting a public max-age to 4 hours (max-age=14400). The app itself sent 3600, so my earlier test described the origin and not what a client sees. I made "long cache" mean one day. A new STATIC_TEXT_CACHE (public, max-age=86400) is used by both /.well-known/security.txt and /robots.txt. The edge may still rewrite it to 4 hours, and the code comment says so. The test asserts the constant and its literal value on both files, so it fails if either file goes back to the old default.
I left the other text answers on the shared 3600, since test/standards.test.ts pins releases.json to that, and they are outside this issue.
/.well-known/security.txt and /robots.txt now both send cache-control: public, max-age=86400, and security.txt names the policy page in a Policy: line (RFC 9116). The tests I re-ran locally pass and bun x tsc --noEmit is clean, but I have not seen the forge's check pass on the new push.
The check was red because of securityBodies, a module-level Map I had added to keep made security.txt bodies for an hour. module-state.test.ts rejects any such Map that a function writes to. I removed the cache. The body is now built on each request, from the clock and the configured contact, so securityTxt reads the database again.
I deleted the test "security.txt touches no database once made", because it tested the removed cache. The assertions on the Policy line and the cache header on both files stay.
On "each page stays inside its first-view budget": it passed locally, and the diff touches no page, so I think it was flaky or timing-dependent. "A large malformed numeric array is scanned in linear time" I did not run to a result. It's in test/invalid-json-readers.test.ts and the change doesn't touch it, so I believe it's a timing flake. If either fails again, that points at the machine rather than this change.
I did not run bun scripts/gate.ts --fix to a clean result: it noted a comment line over 100 columns in test/standards.test.ts, which it says the nightly rewrap handles.
To try it, open /.well-known/security.txt and look for the Policy: line, then check the cache header on both files.
Both files verified on the preview: security.txt carries Contact (a forge URL), Expires (about 160 days ahead), Policy: /security and Canonical, and both answers send cache-control public, max-age=86400. robots.txt ends with Sitemap and disallows the private paths. Earlier asks: the Policy line and the longer cache are met; the module-level cache is gone, so the module-state rule is satisfied. These are plain-text files, so there is no page, phone or keyboard surface to judge.
Next two things, non-blocking:
- Non-blocking: the Contact lookup still reads the database once per request. Say so plainly in the issue, or later resolve it at boot.
- Non-blocking: rewrap the over-100-column comment in test/standards.test.ts so the gate is quiet.
Left #14484 open: 1 unticked item remain (Both are static-text answers with long cache and no database read).
Most of this issue was already on main. The one gap was that
security.txthad noPolicy:line. I added it, and the standards tests pass (29).bun x tsc --noEmitandbun scripts/gate.ts --fixproduced no output.Already on main
/.well-known/security.txtand/robots.txtare served fromsrc/web/standards.tsand already had tests.security.txtalready has aContact:that is a forge URL: the sealed new-issue form of the forge's own repository, else the first account's page. It is never an invented email, and an operator can override it withFORGE_SECURITY_CONTACT.Expires:is always 150–180 days ahead.robots.txtalready allows public pages, disallows/api/, the sign-in, settings and search pages and the deep git paths, and ends withSitemap: <origin>/sitemap.xml.Changed
security.txtnow hasPolicy: <origin>/security, which points at the forge's existing/securitypage.test/standards.test.tsnow checks thePolicy:line and that both files sendcache-control: public, max-age=3600.Not done
The first push was refused for a missing
Try:line, so I added an empty commit with one.Try it:
curl <origin>/.well-known/security.txtandcurl <origin>/robots.txt.Closes #14484