Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ client components initialized.
The Content Security Policy uses a fresh request nonce for Next's generated
scripts and the initial theme script. HTML renders per request; immutable
JavaScript and static assets keep their existing caching. Keep the request and
response policies consistent, and verify a real theme toggle and mounted scene
response policies consistent, and verify a real theme toggle and rendered specimen plates
when changing scripts, headers or rendering.

Analytics uses the shared CodesWhat Public Websites PostHog project through
Expand Down
8 changes: 3 additions & 5 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@ Links, `llms.txt` and `.well-known/security.txt`.

## Open

- [ ] Evaluate the next `posthog-js` upgrade against the public SDK capture
contract tests. CI runs both `test:posthog` and the production response
check, `test:posthog:browser`.
- [ ] #57, the public-repo security baseline, is partly done. The remaining
items are tracked privately.

## Parked: coherent 3D brand-asset set

- [ ] Decide whether three, react-three-fiber, drei and rapier stay. They're only
imported under `frontend/components/studio/`, which backs the dev-only
`/studio/*` capture routes (they 404 in production), but they're still in
`frontend/package.json` and the lockfile, so they show up in audits.

## Parked: coherent 3D brand-asset set

The Catalogue uses hand-drawn pixel sprites, so a 3D-minted icon set isn't on
the critical path. `frontend/scripts/capture-assets.mjs` and the `/studio/*`
routes still work. What exists today: `exports/coin/` (light and dark spin WebP)
Expand Down
4 changes: 3 additions & 1 deletion frontend/README-VERCEL.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ then runs `test:posthog:browser` against an isolated local production server and
it requires a production build.

`npm run og` regenerates the share cards in `public/og*` with playwright-core
and the locally installed Google Chrome; it isn't part of the build.
and the locally installed Google Chrome; it isn't part of the build. After
`npm ci`, provision Chrome once with `npx playwright-core install chrome` before
running `npm run og`. Installing `playwright-core` alone doesn't install Chrome.

## Rendering and security headers

Expand Down
39 changes: 20 additions & 19 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@react-three/fiber": "^9.8.2",
"@react-three/rapier": "^2.2.0",
"next": "^16.4.3",
"posthog-js": "1.443.0",
"posthog-js": "1.447.0",
"react": "19.3.1",
"react-dom": "19.3.1",
"three": "^0.187.0"
Expand Down
27 changes: 24 additions & 3 deletions frontend/test/posthog-browser.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,28 @@ after(async () => {
});
});

function protectsHtml(cacheControl) {
const unquoted = cacheControl.replace(/"(?:[^"\\]|\\.)*"/g, '""');
return /(?:^|,)\s*(?:private|no-store)\s*(?:,|$)/i.test(unquoted);
}

test("HTML cache protection requires an unqualified directive", () => {
for (const header of ["private", "no-store", "max-age=0, private", "private, no-store"]) {
assert.equal(protectsHtml(header), true, header);
}
for (const header of [
"",
"public, max-age=600",
'public, private="Set-Cookie"',
'private="Set-Cookie, no-store, X-Other"',
'x-note="private", public',
'public, x-note="a\\"b, no-store, c"',
"no-store=true",
]) {
assert.equal(protectsHtml(header), false, header);
}
});

test("production browser response keeps PostHog on the exact proxy", async () => {
const response = await fetch(`${baseUrl}/?query-secret=should-not-leave`, {
signal: AbortSignal.timeout(15_000),
Expand All @@ -66,9 +88,8 @@ test("production browser response keeps PostHog on the exact proxy", async () =>
assert.match(csp, /script-src[^;]*https:\/\/e\.codeswhat\.com/);
assert.match(csp, /connect-src[^;]*https:\/\/e\.codeswhat\.com/);
assert.doesNotMatch(csp, /\*\.posthog\.com|https:\/\/(app|us)\.posthog\.com/);
assert.match(
response.headers.get("cache-control") ?? "",
/\b(private|no-store)\b/,
assert.ok(
protectsHtml(response.headers.get("cache-control") ?? ""),
"HTML reflects request data (Next.js flight payload), which is only safe if the page isn't shared-cached",
);
// Next.js inlines router state, including the request's own query, in
Expand Down
4 changes: 3 additions & 1 deletion frontend/test/posthog-source.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ test("PostHog is initialized only by instrumentation-client", async () => {

test("telemetry dependencies use the audited exact PostHog version", async () => {
const packageJson = JSON.parse(await read("package.json"));
assert.equal(packageJson.dependencies["posthog-js"], "1.443.0");
assert.equal(packageJson.dependencies["posthog-js"], "1.447.0");
const installedSdk = JSON.parse(await read("node_modules/posthog-js/package.json"));
assert.equal(installedSdk.version, packageJson.dependencies["posthog-js"]);
assert.equal(packageJson.dependencies["@vercel/analytics"], undefined);
assert.equal(packageJson.dependencies["@vercel/speed-insights"], undefined);
});
Expand Down
7 changes: 7 additions & 0 deletions frontend/test/site-browser.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { existsSync } from "node:fs";
import { after, before, test } from "node:test";
import { fileURLToPath } from "node:url";
import { chromium, firefox, webkit } from "playwright-core";
import { SPECIMEN_EXAMPLES } from "../lib/specimen-examples.ts";

const root = fileURLToPath(new URL("..", import.meta.url));
const nextBin = fileURLToPath(new URL("../node_modules/next/dist/bin/next", import.meta.url));
Expand Down Expand Up @@ -260,6 +261,7 @@ test("the primary navigation marks Support only while its page is current", {
await nav.getByRole("link", { name: "Specimens" }).click();
await page.waitForURL(`${baseUrl}/#specimens`);
assert.equal(await nav.locator('[aria-current="page"]').count(), 0);
assert.equal(await support.evaluate((link) => getComputedStyle(link).textDecorationLine), "none");
await support.click();
await page.waitForURL(`${baseUrl}/support`);
await page.waitForFunction(
Expand Down Expand Up @@ -341,8 +343,13 @@ test("field notes show attributed README excerpts and leave unsourced examples a
const excerpt = await row.locator("pre code").textContent();
const lines = excerpt.split("\n");
assert.equal(lines[0], firstLine, slug);
assert.equal(excerpt, SPECIMEN_EXAMPLES[slug].excerpt, `${slug}: complete rendered excerpt`);
assert.ok(lines.length >= 3 && lines.length <= 6, `${slug}: a short excerpt`);
const source = row.getByRole("link", { name: "Read the full README" });
const sourceUrl = await source.getAttribute("href");
assert.equal(sourceUrl, SPECIMEN_EXAMPLES[slug].sourceUrl, `${slug}: exact source URL`);
const [, start, end] = sourceUrl.match(/#L(\d+)-L(\d+)$/);
assert.equal(Number(end) - Number(start) + 1, lines.length, `${slug}: source range length`);
assert.match(
await source.getAttribute("href"),
new RegExp(
Expand Down
Loading