fix(csp): add missing analytics domains, remove unsafe-eval, fix workspace CSP gap#4179
fix(csp): add missing analytics domains, remove unsafe-eval, fix workspace CSP gap#4179waleedlatif1 wants to merge 1 commit intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Adjusts allowed sources by removing Fixes header application gaps/overlap by having middleware ( Reviewed by Cursor Bugbot for commit f7aeaf6. Configure here. |
Greptile SummaryThis PR centralizes CSP configuration into Confidence Score: 5/5Safe to merge — all route/CSP logic is correct, no double-header conflicts, and the unsafe-eval removal is conservative and intentional. No P0 or P1 issues found. The STATIC_* refactor correctly deduplicates domain lists, the catch-all negative-lookahead regex properly excludes all middleware-owned routes (including root via $), both explicit analytics.google.com and *.analytics.google.com entries in connect-src are non-redundant (wildcard excludes the apex), and workspace/login/signup/root pages now correctly receive runtime CSP via generateRuntimeCSP(). No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
REQ[Incoming Request] --> MATCH{Route?}
MATCH -->|"/ (root)"| ROOT["middleware: generateRuntimeCSP()"]
MATCH -->|"/login or /signup"| AUTH_ROUTE["middleware: generateRuntimeCSP()"]
MATCH -->|"/workspace/* (authenticated)"| WS["middleware: generateRuntimeCSP()"]
MATCH -->|"/workspace/*/templates"| WS_TEMPL["middleware: NextResponse.next()\n(no CSP — public page)"]
MATCH -->|"/chat/* or /form/*"| EMBED["next.config.ts:\ngetChatEmbedCSPPolicy()\ngetFormEmbedCSPPolicy()"]
MATCH -->|"/api/workflows/:id/execute"| EXEC["next.config.ts:\ngetWorkflowExecutionCSPPolicy()\n(unsafe-eval retained)"]
MATCH -->|"Other routes\n(e.g. /templates, /api/*)"| CATCH["next.config.ts catch-all:\ngetMainCSPPolicy()"]
ROOT --> CSP1["Content-Security-Policy\n(runtime env vars via getEnv)"]
AUTH_ROUTE --> CSP1
WS --> CSP1
EMBED --> CSP2["Content-Security-Policy\n(build-time + frame-ancestors: *)"]
EXEC --> CSP3["default-src * unsafe-inline unsafe-eval"]
CATCH --> CSP4["Content-Security-Policy\n(build-time env vars)"]
Reviews (2): Last reviewed commit: "fix(csp): add missing analytics domains,..." | Re-trigger Greptile |
67133b7 to
bb9c776
Compare
bb9c776 to
f7aeaf6
Compare
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit f7aeaf6. Configure here.
Summary
analytics.google.com,www.google.com) and Ahrefs (analytics.ahrefs.com) that were causing console violations on sim.aiSTATIC_*constants so build-time and runtime CSP compose from a single source of truth — no more duplicate domain lists that drift apartunsafe-evalfromscript-src— nothing in the app useseval()and the workflow execution endpoint already has its own permissive CSP/workspace/*routes had no CSP header at all (middleware returned early before setting it, andnext.config.tsexcluded them)/loginand/signupgot redundant CSP from both middleware andnext.config.tsType of Change
Testing
Tested manually
Checklist