diff --git a/.changeset/graphiql-cdn-integrity.md b/.changeset/graphiql-cdn-integrity.md new file mode 100644 index 00000000000..c8a5ca5f4f5 --- /dev/null +++ b/.changeset/graphiql-cdn-integrity.md @@ -0,0 +1,6 @@ +--- +'@shopify/cli-kit': patch +'@shopify/theme': patch +--- + +Add subresource integrity to the CDN assets used by the GraphiQL and theme error pages, and pin the React CDN URLs to the exact version their existing hashes describe diff --git a/eslint.config.js b/eslint.config.js index ca4372edc03..69367b34850 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,6 +1,7 @@ import nxPlugin from '@nx/eslint-plugin' import cliPlugin from '@shopify/eslint-plugin-cli' import jsdocPlugin from 'eslint-plugin-jsdoc' +import nodeSecurity from 'eslint-plugin-node-security' // Spread the CLI plugin's base config which includes all necessary plugins const config = [ @@ -32,6 +33,25 @@ const config = [ }, }, + // The three templates that build HTML around assets fetched from a public + // CDN. Without an `integrity` attribute, whatever the CDN returns is what the + // page runs — `graphiql.min.js` is three megabytes of executed script — and a + // hash pinned against a floating version range breaks silently the day the + // range resolves further. + // + // Scoped to those files, which are clean under the rule after this PR and + // were not before, so it turns CI red only on a new one. Pinned to 4.13.1, + // published nine days ago, so it clears the `cooldown: default-days: 7` in + // .github/dependabot.yml rather than asking for an exception. + { + files: [ + 'packages/cli-kit/src/public/node/graphiql/templates/*.tsx', + 'packages/theme/src/cli/utilities/theme-environment/hot-reload/error-page.ts', + ], + plugins: {'node-security': nodeSecurity}, + rules: {'node-security/require-dependency-integrity': 'error'}, + }, + // NX module boundaries { files: ['**/*.ts', '**/*.tsx'], diff --git a/package.json b/package.json index bc631cb5d68..475cbbf2084 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,7 @@ "esbuild": "0.28.1", "eslint": "^9.39.5", "eslint-plugin-jsdoc": "50.8.0", + "eslint-plugin-node-security": "4.13.1", "execa": "^7.2.0", "fast-glob": "3.3.3", "find-up": "^6.3.0", diff --git a/packages/cli-kit/src/public/node/graphiql/templates/graphiql.tsx b/packages/cli-kit/src/public/node/graphiql/templates/graphiql.tsx index 36ee7cbedb4..f6caa5493c9 100644 --- a/packages/cli-kit/src/public/node/graphiql/templates/graphiql.tsx +++ b/packages/cli-kit/src/public/node/graphiql/templates/graphiql.tsx @@ -73,7 +73,12 @@ export function graphiqlTemplate({ GraphiQL - + - +
@@ -243,6 +253,8 @@ export function graphiqlTemplate({