Repository navigation
test: automated claim-link fragment-leak check (M3-14) - #34
Merged
Merged
Conversation
The security headers/CSP work already existed; the row's actual Done-when (an automated test confirming the claim-link fragment never appears in any network request) didn't. csp.test.ts only unit-tests the CSP string builder, not real runtime behavior. Added e2e/claim-fragment-privacy.spec.ts: loads /claim/[id] with a real-shaped fragment, captures every outbound request for the page's lifetime, fails if the reference or salt appears anywhere. Configured playwright.config.ts with a webServer and baseURL (neither existed). Verified the test can actually fail: temporarily injected a real leak into useClaim.ts, confirmed the test caught it, reverted (byte- identical diff), confirmed a clean pass on the real code. Not done here: wiring into CI. .github/workflows/e2e.yml is marked DRAFT (ask-first: CI); editing it needs explicit approval.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
M3-14's security headers/CSP implementation (proxy.ts,lib/security/csp.ts) already existed and was solid. The row's actual "Done when" criterion was an automated test confirming the claim-link fragment never appears in any network request, and that didn't exist:lib/security/csp.test.tsonly unit-tests the CSP string-builder function, never real runtime browser behavior.Changes
e2e/claim-fragment-privacy.spec.ts: loads/claim/[id]with a real-shaped claim-link fragment (reference + agenerateSalt()-format salt), captures every outbound network request for the page's whole lifetime (URL, POST body, and headers), and fails if the reference or salt turns up anywhere.playwright.config.ts: added awebServer(pnpm build && pnpm start, notdev, sinceproxy.ts's CSP differs byNODE_ENV) and abaseURL. Neither existed before; the config was a one-liner.Hard rules / invariants touched
Rule 5 (claim-link fragment never reaches a server). This is the automated enforcement of it, not a change to it.
Tests
pnpm lint,pnpm typecheck,pnpm test(108/108),pnpm buildall green.Didn't just write the E2E test and assume it works. Verified it can actually fail, not just trivially pass:
useClaim.ts(a strayfetchechoing the reference and salt to a throwaway path).git diffon that file is empty, confirming byte-identical to before).Also hit and fixed two real test-design bugs along the way, not app bugs: an invalid (not
generateSalt()-shaped) test salt silently madeparseClaimLinkthrow before any of the code under test ever ran (so my first "passing" result was a false negative), andwaitForLoadState("networkidle")never resolves on this page since it polls, so switched to a fixed wait window.Docs / ADR
None needed.
Roadmap
M3-14→DONE. Phase 4 App: 13→14 DONE, 6→5 IN PROGRESS (50%→54%). All rows: 43→44 DONE, 15→14 IN PROGRESS (24%→25%). Changelog entry added with the full verification account.Assumptions and open questions
Not done here, by design: wiring this into CI.
.github/workflows/e2e.ymlis markedDRAFT (ask-first: CI)and currently just echoes a placeholder (E2E not configured yet) rather than running anything — that's whye2ehas been passing trivially on every PR this whole session. Actually runningpnpm e2ethere is a CI/CD change, whichAGENTS.mdrequires a human to approve first. No new secrets would be needed either way: every env var the test needs is already-publicNEXT_PUBLIC_*testnet config.If you want it enabled, the change is small: