Skip to content

ci/console: restore CSP header injection in Vercel deploys#37084

Open
jasonhernandez wants to merge 1 commit into
MaterializeInc:mainfrom
jasonhernandez:console-restore-csp-deploy
Open

ci/console: restore CSP header injection in Vercel deploys#37084
jasonhernandez wants to merge 1 commit into
MaterializeInc:mainfrom
jasonhernandez:console-restore-csp-deploy

Conversation

@jasonhernandez

Copy link
Copy Markdown
Contributor

Problem

The console's Content-Security-Policy header is not committed in console/vercel.json — it's injected at build time by console/bin/apply-vercel-csp.js, which must run before vercel build.

In the original MaterializeInc/console repo, both the production (deploy-prod.yml) and preview (deploy-preview.yml) deploys went through bin/build-ci, which ran apply-vercel-csp.js before building.

When the console was ported into this repo (#35032), the deploy logic was reimplemented as Buildkite scripts that call vercel build directly and dropped the apply-vercel-csp.js step. console/bin/build-ci was carried over intact but is no longer invoked by anything.

As a result, the real console deploys ship with no CSP header at all:

Deploy Script CSP injected?
Production (console.materialize.com) ci/deploy/console.sh ❌ before
Impersonation (internal.console.materialize.com) ci/deploy/console-impersonation.sh ❌ before
PR preview ci/test/console/vercel-preview.sh ❌ before
e2e test (throwaway preview) ci/test/console/e2e-prod.sh ✅ (unchanged)

Confirmed live — curl -sI https://console.materialize.com returns x-frame-options and referrer-policy but no content-security-policy.

Fix

Run bin/apply-vercel-csp.js --sentry-release="$SENTRY_RELEASE" before vercel build in all three real deploy scripts, matching the original bin/build-ci behavior. All three already export SENTRY_RELEASE.

The policy itself (console/contentSecurityPolicy.js) is unchanged.

Verification

After this lands and deploys, curl -sI https://console.materialize.com | grep -i content-security should return the CSP header.

🤖 Generated with Claude Code

The Content-Security-Policy header is not committed in console/vercel.json;
it is injected at build time by console/bin/apply-vercel-csp.js, which must
run before `vercel build`. In the original console repo, both the production
and preview deploys went through bin/build-ci, which ran apply-vercel-csp.js
before building.

When the console was ported into this repo (MaterializeInc#35032), the deploy logic was
reimplemented as Buildkite scripts that call `vercel build` directly and
dropped the apply-vercel-csp.js step. As a result, the production, preview,
and impersonation deploys ship with no CSP header at all (confirmed: a HEAD
request to console.materialize.com returns no content-security-policy). Only
the throwaway e2e test deploy (e2e-prod.sh) still applies it.

Restore the injection step before `vercel build` in all three real deploy
scripts. The policy itself (console/contentSecurityPolicy.js) is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jasonhernandez jasonhernandez marked this pull request as ready for review June 16, 2026 20:24
@jasonhernandez jasonhernandez requested a review from a team as a code owner June 16, 2026 20:24
@jasonhernandez

Copy link
Copy Markdown
Contributor Author

our e2e tests have continued running against this content security policy, so I think our risk in re-enabling it is low!

@def- def- left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, sorry about this!

@jasonhernandez jasonhernandez enabled auto-merge (squash) June 16, 2026 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants