Skip to content

test: Add Subresource Integrity (SRI) tests for bundler plugins and SDKs - #26965

Merged
timfish merged 5 commits into
developfrom
test/subresource-integrity-tests
Nov 30, 2026
Merged

timfish merged 5 commits into
developfrom
test/subresource-integrity-tests

Conversation

@timfish

@timfish timfish commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

Adds tests that build real projects with SRI on and check each integrity hash against the file on disk after the Sentry injection. They cover webpack 5, Vite 4/7/8, Rollup 3/4, Rolldown and esbuild, plus Next.js 16 experimental.sri (Turbopack and webpack) and Nuxt 4 with nuxt-security. The SDK checks run in existing e2e builds, so the e2e matrix does not grow. A shared findSubresourceIntegrityMismatches helper is added to @sentry-internal/test-utils.

A change that moves code injection or debug ID stamping after the point where the hashes are computed would silently break SRI for users. The tests cover only setups that work today. Testing also found these setups that break SRI, which this PR does not fix:

  • React Router with subResourceIntegrity and sentryOnBuildEnd: the CLI inject runs after React Router writes its hashes, in every source map mode.
  • Next.js webpack with useRunAfterProductionCompileHook: true, and Turbopack with turbopack.debugIds: false: the CLI inject runs after Next.js hashes the files.
  • esbuild with sourcemaps.disable: 'disable-upload' when the Sentry plugin comes after an SRI plugin: our onEnd rewrites the files after they were hashed.
  • Bun, when another plugin hashes in onEnd: we replace the debug ID placeholder on disk at that time.

Next.js webpack builds hash _ssgManifest.js before writing the final file, also without Sentry, so the checks skip that file.


Generated by Claude Code

Build real projects with SRI on and check each integrity hash against
the file on disk, after the Sentry code injection.

Bundler plugins: webpack 5 (webpack-subresource-integrity), Vite 4, 7
and 8 (vite-plugin-sri3), Rollup 3 and 4 and Rolldown
(rollup-plugin-sri), and esbuild (an `onEnd` SRI plugin). Each runs
with a source map upload and with `disable-upload`, and with the Sentry
plugin before and after the SRI plugin.

SDKs: Next.js 16 `experimental.sri` (Turbopack and webpack, delete and
manual upload) and Nuxt 4 with `nuxt-security` SRI.
Remove the new Next.js and Nuxt e2e variants. The SRI checks now run
in builds that CI already has:

- `nextjs-16` already sets `experimental.sri`. Its SRI test now also
  compares the hashes with the files, for Turbopack and webpack.
- `nextjs-16-sourcemaps` turns on SRI in the manual upload variants.
- `nuxt-4-sourcemaps` adds `nuxt-security` SRI to the static variant.

Add `findHtmlIntegrities` and `findSubresourceIntegrityMismatches` to
`@sentry-internal/test-utils` for these checks.

Keep the plugin order test only for esbuild, where the order changes
the result. Vite, Rollup and Rolldown keep one test per mode.
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: 5f0fcea (PR test merge using develop at bd4c7df)

Against: bd4c7df (develop) · base run #68361

✅ Baseline matches: this diff contains only this PR's changes.

Path Size % Change Change
@sentry/browser 30.55 kB - -
@sentry/browser - with treeshaking flags 28.74 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.61 kB - -
@sentry/browser (incl. Tracing) 53.69 kB - -
@sentry/browser (incl. Tracing Core) 40.62 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 53.69 kB - -
@sentry/browser (incl. Tracing, Profiling) 56.58 kB - -
@sentry/browser (incl. Tracing, Replay) 93.61 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 82.42 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 98.47 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 111.42 kB - -
@sentry/browser (incl. Feedback) 48.41 kB - -
@sentry/browser (incl. sendFeedback) 31.12 kB - -
@sentry/browser (incl. FeedbackAsync) 36.18 kB - -
@sentry/browser (incl. Metrics) 31.87 kB - -
@sentry/browser (incl. Logs) 32.15 kB - -
@sentry/browser (incl. Metrics & Logs) 32.81 kB - -
@sentry/react 32.58 kB - -
@sentry/react (incl. Tracing) 56.43 kB - -
@sentry/vue 38.76 kB - -
@sentry/vue (incl. Tracing) 56.7 kB - -
@sentry/svelte 30.58 kB - -
@sentry/effect (client) 42.23 kB - -
@sentry/effect (client, incl. Tracing) 54.97 kB - -
@sentry/effect (client, incl. Tracing, Logs, Metrics) 66.32 kB - -
@sentry/remix (Remix 3 client bundle) 59.43 kB - -
CDN Bundle 32.39 kB - -
CDN Bundle (incl. Tracing) 54.07 kB - -
CDN Bundle (incl. Logs, Metrics) 35.14 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 56.53 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 76.1 kB - -
CDN Bundle (incl. Tracing, Replay) 91.86 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 94.39 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 97.33 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 99.8 kB - -
CDN Bundle - uncompressed 94.58 kB - -
CDN Bundle (incl. Tracing) - uncompressed 159.89 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 102.92 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 167.52 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 233.32 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 280.33 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 287.96 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 292.26 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 299.88 kB - -
@sentry/nextjs (client) 60.24 kB - -
@sentry/sveltekit (client) 55.04 kB - -
@sentry/astro (client) - rolldown, without tracing 39.46 kB - -
@sentry/core/server 45.84 kB - -
@sentry/core/browser 14.49 kB - -
@sentry/node 157.92 kB - -
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.59 kB - -
@sentry/node - without tracing 89.95 kB - -
@sentry/node - without channel injection 146.88 kB +0.01% +1 B 🔺
@sentry/aws-serverless 100.6 kB +0.01% +2 B 🔺
@sentry/cloudflare (withSentry) - minified 212.36 kB - -
@sentry/cloudflare (withSentry) 492.5 kB - -
@sentry/cloudflare (withSentry, instrumented CommonJS package) - minified 215.31 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 237.58 kB - -

View base workflow run

@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Optional E2E tests

Some optional checks were not successful. They do not block the merge. 2 not successful, 62 successful. See the run.

Check Status
❌ CI: Optional E2E Tests / E2E gen-ai-libraries (latest) Test (optional) Failing after 4m Details
❌ CI: Optional E2E Tests / E2E cloudflare-flue-send-to-sentry Test (optional) Failing after 4m Details
Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E cloudflare-agent Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-send-to-sentry Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E astro-7 (static trace lifecycle) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E deno (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-think (ai v6) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E hono-5 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E hapi-21 (bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E hapi-21 (deno) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E hono-5 (bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E hono-5 (deno) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E hono-5 (cloudflare) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-14-supabase Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-eve (0.x) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-eve (content off) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v1 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-eve (orchestrion) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 (MCP SDK OpenTelemetry) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry (static trace lifecycle) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-pi-durable (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-flue (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-mastra (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (kv-cache) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (deno) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (development) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-4-sourcemaps (Vite server) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (bun) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (no upload) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (cloudflare) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps enabled by Sentry) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (static / nuxt generate) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-tunnel Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 (delete all) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E react-router-7-framework-instrumentation Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 (no upload) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-tunnel (cloudflare) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 (manual upload) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-cloudflare Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E solidstart-2-tunnel Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps (no upload) Test (optional) Successful in 58s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps (delete all) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps (manual upload) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E vinext-cf-workers (workers cache) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E vue-3 (no Options API) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-without-tracing-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E debug-id-sourcemaps Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E astro-7 Test (optional) Successful in 2m Details

@timfish
timfish marked this pull request as ready for review November 28, 2026 13:31
`rollup-plugin-sri` is archived, and no maintained SRI plugin exists for
Rollup. A small plugin in the fixtures hashes the final entry chunks in
`generateBundle` and emits the HTML, like `rollup-plugin-sri` did. It
also replaces `@rollup/plugin-html` in the Rollup and Rolldown fixtures.

@chargome chargome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I assume for stuff that happens in some onBuildEnd-like hook we do not really have a solution right?

@timfish

timfish commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator Author

for stuff that happens in some onBuildEnd-like hook we do not really have a solution

Correct. I'll look into alterantives!

…ntegrity-tests

# Conflicts:
#	dev-packages/bundler-plugin-integration-tests/fixtures/vite4/package.json
#	dev-packages/bundler-plugin-integration-tests/fixtures/vite7/package.json
#	dev-packages/bundler-plugin-integration-tests/fixtures/vite8/package.json
#	dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/package.json
@timfish
timfish merged commit 19c4139 into develop Nov 30, 2026
930 of 954 checks passed
@timfish
timfish deleted the test/subresource-integrity-tests branch November 30, 2026 16:22
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.

4 participants