Public: anyone can read this; the crew can change it.
The weekly production probe also checks /terms, /privacy and /.well-known/security.txt answer 200 #13287
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13116-the-weekly-production-probe-also-checks → main 2 commits fork 1 thread · 1 unresolved
3 files
changed +62
−5
src/core/v1_proof.ts +16
| @@ -227,6 +227,22 @@ export const probes: readonly Probe[] = [ | ||
| 227 | 227 | return `${path} carries ${entries} entr${entries === 1 ? "y" : "ies"} (${bytes} bytes)`; |
| 228 | 228 | }, |
| 229 | 229 | }, |
| 230 | { | |
| 231 | issue: 13116, | |
| 232 | item: "/terms, /privacy and /.well-known/security.txt answer 200", | |
| 233 | // The failure names the first path that does not, with its status and bytes; the defect's | |
| 234 | // evidence block carries the URL. | |
| 235 | run: async (get) => { | |
| 236 | const seen: string[] = []; | |
| 237 | for (const path of ["/terms", "/privacy", "/.well-known/security.txt"]) { | |
| 238 | const got = await get(path); | |
| 239 | const bytes = new TextEncoder().encode(got.text).length; | |
| 240 | expect(got.status === 200, `${path} answers ${got.status}, not 200 (${bytes} bytes)`); | |
| 241 | seen.push(path); | |
| 242 | } | |
| 243 | return `${seen.join(", ")} answer 200`; | |
| 244 | }, | |
| 245 | }, | |
| 230 | 246 | { |
| 231 | 247 | issue: 10441, |
| 232 | 248 | item: "the security headers are on the page and on a machine answer", |
test/maintain-v1-proven.test.ts +29 −1
| @@ -10,7 +10,7 @@ import { createApp, type App } from "../src/app.ts"; | ||
| 10 | 10 | import { createIssue, listComments } from "../src/core/issues.ts"; |
| 11 | 11 | import { createRepo } from "../src/core/repos.ts"; |
| 12 | 12 | import { createUser } from "../src/core/users.ts"; |
| 13 | import { probes, type Result } from "../src/core/v1_proof.ts"; | |
| 13 | import { probes, prove, type Result } from "../src/core/v1_proof.ts"; | |
| 14 | 14 | import { v1Proven } from "../src/maintain/duties/v1_proven.ts"; |
| 15 | 15 | import { watcherId } from "../src/rules/bot.ts"; |
| 16 | 16 | import { duties } from "../src/maintain/registry.ts"; |
| @@ -235,3 +235,31 @@ test("a run defect notes passing once when every probe passes again", async () = | ||
| 235 | 235 | await run(undefined, undefined, mixed({})); |
| 236 | 236 | expect(listComments(app.db, made.id).map((c) => c.body.split(" ")[0])).toEqual(["Passing"]); |
| 237 | 237 | }); |
| 238 | ||
| 239 | test("a failing /terms probe files exactly one defect carrying its URL, status and bytes (#13116)", async () => { | |
| 240 | closeDefects(); | |
| 241 | const before = total(); | |
| 242 | const origin = Bun.serve({ | |
| 243 | port: 0, | |
| 244 | fetch: (req) => { | |
| 245 | const path = new URL(req.url).pathname; | |
| 246 | return path === "/terms" ? new Response("nope", { status: 404 }) : new Response("ok"); | |
| 247 | }, | |
| 248 | }); | |
| 249 | try { | |
| 250 | const base = `http://localhost:${origin.port}`; | |
| 251 | const only = async (b: string): Promise<Result[]> => { | |
| 252 | const all = await prove(b, fetch); | |
| 253 | return all.filter((r) => r.issue === 13116); | |
| 254 | }; | |
| 255 | const proof = async (b: string): Promise<Result[]> => (await only(b)).concat([]); | |
| 256 | await run(base, undefined, proof); | |
| 257 | await run(base, undefined, proof); | |
| 258 | expect(total()).toBe(before + 1); | |
| 259 | const made = defects().at(-1)!; | |
| 260 | const ev = readEvidence(app.db.query<{ body: string }, [string]>("SELECT body FROM issue WHERE id = ?1").get(made.id)!.body)!; | |
| 261 | expect(ev).toMatchObject({ url: `${base}/terms`, status: "404", bytes: "4" }); | |
| 262 | } finally { | |
| 263 | origin.stop(true); | |
| 264 | } | |
| 265 | }); |
test/v1-proven.test.ts +17 −4
| @@ -42,6 +42,9 @@ function stub(over: Over = {}, seen: string[] = []): Fetch { | ||
| 42 | 42 | "/settings/crew": () => new Response(null, { status: 303, headers: { location: "/signin?next=%2Fsettings%2Fcrew" } }), |
| 43 | 43 | "/api/v1/health": () => health({ overdue: 0, oldestSeconds: 0 }), |
| 44 | 44 | "/changelog.atom": () => new Response(FEED), |
| 45 | "/terms": () => new Response("terms"), | |
| 46 | "/privacy": () => new Response("privacy"), | |
| 47 | "/.well-known/security.txt": () => new Response("Contact: mailto:[email protected]"), | |
| 45 | 48 | ...over, |
| 46 | 49 | }; |
| 47 | 50 | return async (url, init) => { |
| @@ -55,9 +58,9 @@ describe("v1-proven", () => { | ||
| 55 | 58 | test("every list item has a probe, and all pass on a healthy forge", async () => { |
| 56 | 59 | const results = await prove("https://f.test/", stub()); |
| 57 | 60 | expect(results.map((r) => r.issue).sort()).toEqual( |
| 58 | [11541, 11539, 11158, 11573, 10304, 13042, 11507, 11138, 11140, 11141, 11515, 11595, 13072, 10441].sort(), | |
| 61 | [11541, 11539, 11158, 11573, 10304, 13042, 11507, 11138, 11140, 11141, 11515, 11595, 13072, 13116, 10441].sort(), | |
| 59 | 62 | ); |
| 60 | expect(probes.length).toBe(14); | |
| 63 | expect(probes.length).toBe(15); | |
| 61 | 64 | const status = (n: number) => results.find((r) => r.issue === n)?.status; |
| 62 | 65 | // What no public read can show is unproven, never a pass. |
| 63 | 66 | expect(results.filter((r) => r.status === "unproven").map((r) => r.issue).sort()).toEqual([]); |
| @@ -72,6 +75,16 @@ describe("v1-proven", () => { | ||
| 72 | 75 | expect(line(results.find((r) => r.issue === 13042)!)).toBe("fail #13042 the release production runs is 1.0.0 or later: the release is 0.7.604, not 1.0.0"); |
| 73 | 76 | }); |
| 74 | 77 | |
| 78 | test("/terms, /privacy and security.txt must answer 200: a failure names the path, status and bytes (#13116)", async () => { | |
| 79 | for (const path of ["/terms", "/privacy", "/.well-known/security.txt"]) { | |
| 80 | const results = await prove("https://f.test", stub({ [path]: () => new Response("gone", { status: 404 }) })); | |
| 81 | const bad = results.filter((r) => r.status === "fail"); | |
| 82 | expect(bad).toHaveLength(1); | |
| 83 | expect(bad[0]!.detail).toBe(`${path} answers 404, not 200 (4 bytes)`); | |
| 84 | expect(bad[0]!.seen).toMatchObject({ url: `https://f.test${path}`, status: 404, bytes: 4 }); | |
| 85 | } | |
| 86 | }); | |
| 87 | ||
| 75 | 88 | test("only reads: every request is a GET", async () => { |
| 76 | 89 | const seen: string[] = []; |
| 77 | 90 | await prove("https://f.test", stub({}, seen)); |
| @@ -163,7 +176,7 @@ describe("v1-proven", () => { | ||
| 163 | 176 | const { code, out } = await run(async () => new Response("down", { status: 503 })); |
| 164 | 177 | expect(code).toBe(1); |
| 165 | 178 | expect(out).toContain("fail #11539"); |
| 166 | expect(out).toContain("v1.0.0 is not proven: 14 of 14 fail, 0 unproven"); | |
| 179 | expect(out).toContain("v1.0.0 is not proven: 15 of 15 fail, 0 unproven"); | |
| 167 | 180 | }); |
| 168 | 181 | |
| 169 | 182 | test("the script exits 3, not 0, when nothing fails but some items are unproven", async () => { |
| @@ -171,7 +184,7 @@ describe("v1-proven", () => { | ||
| 171 | 184 | expect(out).not.toContain("fail #"); |
| 172 | 185 | expect(code).toBe(3); |
| 173 | 186 | expect(out).toContain("unproven #11595"); |
| 174 | expect(out).toContain("v1.0.0 is not proven: none fail, 1 of 14 unproven"); | |
| 187 | expect(out).toContain("v1.0.0 is not proven: none fail, 1 of 15 unproven"); | |
| 175 | 188 | }); |
| 176 | 189 | |
| 177 | 190 | test("the script exits 2 on bad usage", () => { |
new above
offline
(await only(b)).concat([])is a no-op wrapper;proofandonlyshould be one function.