Repository navigation
security(fix): PR-audit remediations — GHA input hardening, analytics URL guard, GPC/DNT opt-out, CodeRabbit coverage - #352
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
… parse Findings from a full-backlog PR lifecycle audit (263 PRs triaged, 33 deep-verified against the live tree). - visual-baselines.yml interpolated the `spec` workflow_dispatch input directly into three `run:` blocks on a job holding contents: write and pull-requests: write, so the input was spliced in as shell code before parsing. Pass it through `env:` instead, leaving the call site unquoted because the filter may legitimately name several specs (e.g. "components-visual frontend"). - trackPrimaryLinkClick parsed href with an unguarded `new URL()` inside a document-wide click listener. Hrefs such as "//" or "http://" throw, which dropped the event and logged an uncaught error on every such click. The file already wraps all three transport calls under "analytics must never block the user action"; this parse was the one unprotected step. - The anonymous analytics contract described only the PostHog signals while AnalyticsShell also mounts GA4 (own cookies, own auto-pageviews) and Vercel Analytics. Document the full stack, and note that the contract spec pins PostHog payloads only and cannot catch an undisclosed provider. Verified on the dev base: lint clean, tsc clean, 341 int tests passing. Co-Authored-By: Claude Opus 5 <[email protected]>
…e CodeRabbit coverage Follow-ups from the full-backlog PR audit. Restore review coverage. CodeRabbit only auto-reviews the default branch, and almost all work here lands on `dev`, so dev-targeted PRs were skipped with a notice that reads like a finished review. Across 263 PRs only 14 ever received a substantive AI review. Add .coderabbit.yaml listing `dev` as a base branch. Honour explicit privacy signals. Every event this repo emits is now skipped when the browser sends Global Privacy Control (legally binding under the CCPA) or Do Not Track, and no pc_distinct_id is minted or stored for those visitors. The PostHog gate is folded in after the __posthogEvents push so the e2e harness still records intent; Playwright sets neither signal, so existing assertions are unaffected. Stop sending from non-production hosts. isAnalyticsHost() accepted localhost and 127.0.0.1, so a maintainer running `pnpm dev` with a real key wrote synthetic traffic into the production dataset and leaked unreleased route paths to a third party. Production hostnames only. This is deliberately not a full consent gate: the GA4 script still loads on first paint, so its own automatic collection and cookies are unchanged. The docs now say so explicitly rather than implying the opt-out covers everything. Verified: lint clean, tsc clean, 341 int tests passing. Co-Authored-By: Claude Opus 5 <[email protected]>
792fb66 to
9a2b335
Compare
Closes the gap the PR audit left open: GA4, Vercel Analytics/Speed Insights and PostHog all loaded on first paint, so an EU visitor had GA4 cookies set before any interaction. Honouring GPC/DNT (shipped in #352) narrowed that but could not close it, because GA4 was mounted regardless. AnalyticsShell now renders nothing until consent is 'granted'. On a first visit there is no GA4 script, no Vercel bundle, no PostHog beacon and no stored identifier. State lives in src/lib/consent.ts under `pc_consent`; ConsentBanner collects the choice and /privacy documents the stack and can withdraw it. Three things worth calling out: - A browser privacy signal is a decision, not a prompt. GPC (binding under the CCPA) or DNT resolves to 'denied' and the banner never renders. - Withdrawal reloads. Unmounting AnalyticsShell does not unload a third party that is already running — gtag stays initialised on window and keeps collecting — so setConsent reloads on granted -> denied. It also clears pc_distinct_id, so opting out erases the identifier instead of freezing it. This was caught by the e2e spec, not by review. - The banner is fixed-positioned, so it costs no layout shift on the landing page's LCP content. Testing: specs that assert on analytics or capture visual baselines grant consent up-front via tests/e2e/consent.ts, which keeps the banner out of every snapshot — only the two landing baselines changed, and only because /privacy was added to the footer. The axe suites deliberately run without consent, so the banner is held to the same a11y bar as the rest of the site. Verified: lint clean, tsc clean, 341 int tests, and e2e — consent 6/6, a11y 10/10, frontend 39/39, templates 60/60, templates-visual 62/62, components-visual 69/69, blog 5/5, geo 13/13. blog-index visual baselines fail identically on clean origin/dev (stale darwin snapshots, unrelated to this change). Co-Authored-By: Claude Opus 5 <[email protected]>
Closes the gap the PR audit left open: GA4, Vercel Analytics/Speed Insights and PostHog all loaded on first paint, so an EU visitor had GA4 cookies set before any interaction. Honouring GPC/DNT (shipped in #352) narrowed that but could not close it, because GA4 was mounted regardless. AnalyticsShell now renders nothing until consent is 'granted'. On a first visit there is no GA4 script, no Vercel bundle, no PostHog beacon and no stored identifier. State lives in src/lib/consent.ts under `pc_consent`; ConsentBanner collects the choice and /privacy documents the stack and can withdraw it. Three things worth calling out: - A browser privacy signal is a decision, not a prompt. GPC (binding under the CCPA) or DNT resolves to 'denied' and the banner never renders. - Withdrawal reloads. Unmounting AnalyticsShell does not unload a third party that is already running — gtag stays initialised on window and keeps collecting — so setConsent reloads on granted -> denied. It also clears pc_distinct_id, so opting out erases the identifier instead of freezing it. This was caught by the e2e spec, not by review. - The banner is fixed-positioned, so it costs no layout shift on the landing page's LCP content. Testing: specs that assert on analytics or capture visual baselines grant consent up-front via tests/e2e/consent.ts, which keeps the banner out of every snapshot — only the two landing baselines changed, and only because /privacy was added to the footer. The axe suites deliberately run without consent, so the banner is held to the same a11y bar as the rest of the site. Verified: lint clean, tsc clean, 341 int tests, and e2e — consent 6/6, a11y 10/10, frontend 39/39, templates 60/60, templates-visual 62/62, components-visual 69/69, blog 5/5, geo 13/13. blog-index visual baselines fail identically on clean origin/dev (stale darwin snapshots, unrelated to this change). Co-Authored-By: Claude Opus 5 <[email protected]>
…#372) * privacy(feat): gate all third-party analytics behind explicit consent Closes the gap the PR audit left open: GA4, Vercel Analytics/Speed Insights and PostHog all loaded on first paint, so an EU visitor had GA4 cookies set before any interaction. Honouring GPC/DNT (shipped in #352) narrowed that but could not close it, because GA4 was mounted regardless. AnalyticsShell now renders nothing until consent is 'granted'. On a first visit there is no GA4 script, no Vercel bundle, no PostHog beacon and no stored identifier. State lives in src/lib/consent.ts under `pc_consent`; ConsentBanner collects the choice and /privacy documents the stack and can withdraw it. Three things worth calling out: - A browser privacy signal is a decision, not a prompt. GPC (binding under the CCPA) or DNT resolves to 'denied' and the banner never renders. - Withdrawal reloads. Unmounting AnalyticsShell does not unload a third party that is already running — gtag stays initialised on window and keeps collecting — so setConsent reloads on granted -> denied. It also clears pc_distinct_id, so opting out erases the identifier instead of freezing it. This was caught by the e2e spec, not by review. - The banner is fixed-positioned, so it costs no layout shift on the landing page's LCP content. Testing: specs that assert on analytics or capture visual baselines grant consent up-front via tests/e2e/consent.ts, which keeps the banner out of every snapshot — only the two landing baselines changed, and only because /privacy was added to the footer. The axe suites deliberately run without consent, so the banner is held to the same a11y bar as the rest of the site. Verified: lint clean, tsc clean, 341 int tests, and e2e — consent 6/6, a11y 10/10, frontend 39/39, templates 60/60, templates-visual 62/62, components-visual 69/69, blog 5/5, geo 13/13. blog-index visual baselines fail identically on clean origin/dev (stale darwin snapshots, unrelated to this change). Co-Authored-By: Claude Opus 5 <[email protected]> * test(chore): mint Linux visual baselines (frontend) (#373) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * privacy(fix): erase the identifier on a privacy signal and reload other tabs Both found by CodeRabbit on #372 — the first substantive AI review this repo has had on a dev-targeted PR since .coderabbit.yaml listed `dev` as a base branch. resolveConsent() returned 'denied' for a GPC/DNT visitor without clearing a pc_distinct_id that an earlier opt-in may have stored. It was never sent while denied, but it survived to re-link the visitor to their previous identity if they later opted back in. A signal is now treated exactly like an explicit withdrawal. subscribeToConsent() notified React on a cross-tab change but never reloaded. That is the same defect the reload in setConsent exists to prevent, one tab over: a tab that already mounted GA4 keeps gtag initialised on window and keeps collecting, because unmounting AnalyticsShell cannot unload it. A withdrawal elsewhere now tears this tab down too. Both are covered by new specs that fail without the fix: a privacy signal arriving after an opt-in must leave no identifier, and withdrawing in one tab must strip the Google tag from a second tab that already had it. Verified: lint clean, tsc clean, 341 int tests, consent e2e 8/8. Co-Authored-By: Claude Opus 5 <[email protected]> --------- Co-authored-by: Claude Opus 5 <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Remediations from a full-backlog PR lifecycle audit (263 PRs triaged, 33 deep-verified against the live tree).
Why this matters most
Only 14 of 263 PRs ever received a substantive AI review. CodeRabbit auto-reviews the default branch only, and almost all work lands on
dev, so dev-targeted PRs were skipped with a notice that reads like a finished review..coderabbit.yamlnow listsdevas a base branch.Changes
visual-baselines.ymlspliced thespecdispatch input directly into threerun:blocks on a job holdingcontents: write+pull-requests: write. Now passed viaenv:. Left unquoted at the call site on purpose: the filter may legitimately name several specs ("components-visual frontend").trackPrimaryLinkClickparsedhrefwith an unguardednew URL()inside a document-wide click listener.//andhttp://throw, dropping the event and logging an uncaught error. Guarded.pc_distinct_idis minted for them. The PostHog gate sits after the__posthogEventspush so the e2e harness still records intent.isAnalyticsHost()acceptedlocalhost/127.0.0.1, so a maintainer runningpnpm devwith a real key wrote synthetic traffic into the production dataset and leaked unreleased route paths. Production hostnames only.Deliberately out of scope
This is not a full consent gate. The GA4 script still loads on first paint, so its own automatic collection and cookies are unaffected. The docs say so explicitly rather than implying the opt-out covers everything. Closing that gap means deferring third-party mounts until opt-in plus a privacy page — it re-baselines landing visual snapshots and must clear the axe gate, so it deserves its own scoped change.
Verification
lint clean ·
tscexit 0 · 341 int tests passing · opt-out semantics unit-checked (doNotTrack: "0"and"unspecified"correctly do not opt out; Playwright's default state is unaffected, so existing e2e assertions hold).