Skip to content

chore: harden pnpm supply-chain config - #1068

Merged
ascorbic merged 5 commits into
mainfrom
chore/harden-supply-chain
May 18, 2026
Merged

ascorbic merged 5 commits into
mainfrom
chore/harden-supply-chain

Conversation

@ascorbic

Copy link
Copy Markdown
Member

What does this PR do?

Hardens the monorepo's pnpm config against supply-chain attacks (motivated by the recent major npm worm/compromised-publish incidents). This is our own repo, so it runs tight and absorbs the maintenance.

Pin pnpm (packageManager: "[email protected]") so the build-script/trust schema is deterministic (pnpm 10 vs 11 differ materially: allowBuilds vs onlyBuiltDependencies). .npmrc removed (enable-pre-post-scripts moved to pnpm-workspace.yaml as enablePrePostScripts: true — canonical location, also silences the npm "unknown config" warning; provenance is implied by OIDC trusted publishing).

pnpm-workspace.yaml hardening:

  • minimumReleaseAge: 1440 — 24h publish cooldown (core defense vs fresh malicious publishes). @rolldown/* / @emnapi/* excluded: vite8/rolldown-rc exact-pins these per-arch binaries on a release cadence that structurally conflicts with the cooldown.
  • strictDepBuilds: true + explicit allowBuilds — build scripts run only for @parcel/watcher, sharp, better-sqlite3, esbuild, workerd; core-js-pure: false (donation postinstall, unneeded). dangerouslyAllowAllBuilds: false.
  • blockExoticSubdeps: true + an @astrojs/telemetry → 3.3.0 override (infra/cache-demo pins the pkg.pr.new Astro cache-support preview, which pulls telemetry via URL; override keeps the guard on without dropping the load-bearing preview).
  • trustPolicy: no-downgrade + a reviewed, version-pinned trustPolicyExclude: [email protected], [email protected], [email protected], @portabletext/[email protected], [email protected] — each a benign publish-method change or old pre-provenance pin in a deep transitive chain, individually reviewed (not takeovers). The guard stays active for everything else.
  • verifyStoreIntegrity, strictStorePkgContentCheck, verifyDepsBeforeRun: error.

Lockfile regenerated under the hardened config with pnpm 11.1.2 (bounded delta — mostly the telemetry override + minor cooldown nudges).

No related issue.

Type of change

  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes — not run locally (no source changed; deps/config only; CI covers it)
  • pnpm lint passes — not run locally; CI covers it
  • pnpm test passes — verification is the full hardened pnpm install resolving + building clean under pinned [email protected] (resolution, strictDepBuilds, blockExoticSubdeps, trustPolicy, integrity, verifyDepsBeforeRun all pass)
  • pnpm format has been run — N/A: no formatted source changed
  • I have added/updated tests — N/A (pnpm config)
  • User-visible strings wrapped for translation — N/A
  • I have added a changeset — N/A: no published package changed
  • New features link to an approved Discussion — N/A

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Claude Opus 4.7 (Claude Code)

Screenshots / test output

npx [email protected] install --no-frozen-lockfile → Done in 36.4s, exit 0, no trust/exotic/cooldown/build-script errors; lockfile delta +378/-299.

Notes

  • trustPolicyExclude is a maintained list: a new entry is needed when a dependency legitimately changes publish method (industry trend is provenance → trusted-OIDC, an upgrade no-downgrade ignores, so growth should be slow). Each entry is version-pinned and self-expires on the next bump.

Pin pnpm (packageManager: [email protected]) so the build-script/trust schema
is deterministic, and add supply-chain hardening to pnpm-workspace.yaml:

- minimumReleaseAge 1440 (24h publish cooldown); @rolldown/* and
  @emnapi/* excluded (vite8/rolldown-rc exact-pins these per-arch
  binaries; their release cadence structurally conflicts with the
  cooldown and they are not an attack surface worth the friction)
- strictDepBuilds + explicit allowBuilds: build scripts run only for
  @parcel/watcher, sharp, better-sqlite3, esbuild, workerd;
  core-js-pure denied (donation postinstall, not needed)
- dangerouslyAllowAllBuilds false
- blockExoticSubdeps true, with an @astrojs/telemetry -> 3.3.0 override
  (infra/cache-demo's pkg.pr.new Astro cache-support preview pulls
  telemetry via URL; the override keeps the guard on)
- trustPolicy no-downgrade with a reviewed, version-pinned
  trustPolicyExclude ([email protected], [email protected], [email protected],
  @portabletext/[email protected], [email protected] -- all benign
  publish-method changes / old pre-provenance pins, not takeovers)
- verifyStoreIntegrity, strictStorePkgContentCheck, verifyDepsBeforeRun
  error

Move enable-pre-post-scripts from .npmrc to pnpm-workspace.yaml
(enablePrePostScripts: true; canonical location, also silences the
npm "unknown config" warning). Remove .npmrc entirely -- provenance
is implied by OIDC trusted publishing.

Lockfile regenerated under the hardened config with pnpm 11.1.2.
Copilot AI review requested due to automatic review settings May 16, 2026 19:48
@changeset-bot

changeset-bot Bot commented May 16, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 3db236c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

PR template validation failed

Please fix the following issues by editing your PR description:

  • Check the "I have read CONTRIBUTING.md" checkbox.

See CONTRIBUTING.md for the full contribution policy.

@github-actions

Copy link
Copy Markdown
Contributor

Scope check

This PR changes 677 lines across 4 files. Large PRs are harder to review and more likely to be closed without review.

If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs.

See CONTRIBUTING.md for contribution guidelines.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 16, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-perf-coordinator 6ef112d May 18 2026, 10:20 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 16, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-i18n 6ef112d May 18 2026, 10:20 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 16, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
docs 6ef112d May 18 2026, 10:21 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 16, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-demo-cache 6ef112d May 18 2026, 10:21 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 16, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-playground 6ef112d May 18 2026, 10:21 AM

@pkg-pr-new

pkg-pr-new Bot commented May 16, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@1068

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@1068

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@1068

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@1068

emdash

npm i https://pkg.pr.new/emdash@1068

create-emdash

npm i https://pkg.pr.new/create-emdash@1068

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@1068

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@1068

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@1068

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@1068

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@1068

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@1068

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@1068

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@1068

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@1068

commit: 6ef112d

Copilot AI 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.

Pull request overview

This PR hardens the monorepo’s pnpm supply-chain configuration by pinning pnpm, enabling stricter install/build safeguards, and regenerating the lockfile under the new policy.

Changes:

  • Pins the workspace package manager to [email protected].
  • Adds pnpm workspace hardening settings for release-age gating, build-script allowlisting, trust policy checks, and exotic subdependency blocking.
  • Regenerates the lockfile with the new override and pnpm metadata changes.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 5 comments.

File Description
pnpm-workspace.yaml Adds pnpm supply-chain hardening settings, build/trust policy config, telemetry override, and broadens infra workspace matching.
pnpm-lock.yaml Regenerated lockfile reflecting pnpm 11 resolution, telemetry override, metadata changes, and dependency snapshot updates.
package.json Updates packageManager from pnpm 10 to pnpm 11.
.npmrc Removes previous pnpm/npm config now intended to live elsewhere or be implied by publishing setup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pnpm-lock.yaml Outdated
@@ -2387,7 +2390,7 @@ packages:
wrangler: ^4.61.1

'@astrojs/cloudflare@https://pkg.pr.new/@astrojs/cloudflare@94d342d':
resolution: {integrity: sha512-Bt+G512Dr1SqYdsza6HOLP2azfHg0m5UE0s6SBGX77g+ThFV95Nai5boyM8HO3jVpqwVPPh+5ycMptjrtzv7Yg==, tarball: https://pkg.pr.new/@astrojs/cloudflare@94d342d}
resolution: {tarball: https://pkg.pr.new/@astrojs/cloudflare@94d342d}
Comment thread package.json
"typescript": "6.0.0-beta"
},
"packageManager": "pnpm@10.28.0",
"packageManager": "pnpm@11.1.2",
Comment thread pnpm-workspace.yaml Outdated
Comment on lines +4 to +5
- "@rolldown/*"
- "@emnapi/*"
Comment thread pnpm-workspace.yaml Outdated
@@ -1,3 +1,37 @@
# Supply-chain hardening. allowBuilds/trustPolicyExclude policy: CONTRIBUTING.md
Comment thread pnpm-lock.yaml Outdated
Comment on lines +6195 to +6197
'@ungap/[email protected]':
resolution: {integrity: sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==}
deprecated: Potential CWE-502 - Update to 1.3.1 or higher
- Remove stale root pnpm.onlyBuiltDependencies (dead under pinned
  pnpm 11; allowBuilds in pnpm-workspace.yaml is the single source)
- Narrow cooldown excludes: @rolldown/* -> @rolldown/binding-*, and
  @emnapi/* -> @emnapi/core/@emnapi/runtime, so the cooldown stays
  active for JS like @rolldown/pluginutils / @emnapi/wasi-threads
- Drop the dangling CONTRIBUTING.md pointer (no such policy doc)
- Override @ungap/structured-clone to ^1.3.1 (1.3.0 deprecated,
  CWE-502)
- Regenerate the lockfile from a clean store so the astro pkg.pr.new
  tarball regains its SRI integrity (the earlier warm-store regen
  dropped it; @astrojs/cloudflare and @lunariajs/core never had SRI,
  pre-PR included -- pnpm doesn't record it for those URLs)

Re-resolved clean under pnpm 11.1.2 with the narrowed excludes.
@ascorbic

Copy link
Copy Markdown
Member Author

Thanks — addressed all five in 59758697:

  1. URL dep integrity — Valid, and fixed for the one that regressed. Checked against pre-PR origin/main: only [email protected] ever had an SRI hash; @astrojs/cloudflare and @lunariajs/core had none even before this PR (pnpm doesn't record integrity for those particular pkg.pr.new tarballs, even on a forced clean-store re-download). The warm-store regen had dropped astro's hash; regenerating from a clean store restores it. Net vs main: integrity is now equal-or-better, not weakened. The remaining two are a pre-existing pnpm limitation for those URLs, not introduced here.
  2. Stale root pnpm.onlyBuiltDependencies — Removed. allowBuilds in pnpm-workspace.yaml is now the single source (pinned pnpm 11 ignores onlyBuiltDependencies anyway).
  3. Over-broad cooldown excludes — Narrowed to @rolldown/binding-*, @emnapi/core, @emnapi/runtime (the exact-pinned binaries/runtime that actually deadlock the cooldown). @rolldown/pluginutils, @rolldown/plugin-babel, @emnapi/wasi-threads etc. stay under minimumReleaseAge. Re-resolved clean with the narrower patterns.
  4. Dangling CONTRIBUTING pointer — Removed (no such policy doc; the settings + inline notes are self-describing).
  5. @ungap/[email protected] (CWE-502) — Added an overrides entry pinning ^1.3.1; lockfile now resolves 1.3.1.

@ascorbic

Copy link
Copy Markdown
Member Author

/bonk resolve the conflicts

Resolves lockfile conflict by regenerating under pnpm 11.1.2 with the
merged hardened config + main's TypeScript 6 catalog. Frozen install
verified clean.
@ask-bonk

ask-bonk Bot commented May 17, 2026

Copy link
Copy Markdown
Contributor

Merge commit looks clean. The branch now has main merged in, with the lockfile cleanly regenerated under the hardened config.


Resolved the conflict with origin/main (PR #1068 was behind 3 commits, including #1074's TypeScript 6 upgrade which also touched the lockfile and pnpm-workspace.yaml's catalog).

Resolution:

  • pnpm-workspace.yaml, package.json — auto-merged cleanly (the TS 6 catalog updates from main slotted in alongside the hardening config from this branch).
  • pnpm-lock.yaml — only real conflict. Took main's side as a base and regenerated with [email protected] install --no-frozen-lockfile so the hardened config (minimumReleaseAge, allowBuilds, blockExoticSubdeps, trustPolicy: no-downgrade, integrity checks, @astrojs/telemetry and @ungap/structured-clone overrides) is enforced against main's current dep graph (TS 6, typescript: ^6.0.3, etc.).
  • Verified with pnpm install --frozen-lockfile → clean, no resolution drift.

Merge commit pushed as 9911780a.

github run

@github-actions

github-actions Bot commented May 17, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

ascorbic and others added 2 commits May 17, 2026 13:02
* fix: resolve #1053 type errors for strict consumers

Closes #1053.

Two parts:

1. wordpress-plugin.ts: the analyze-endpoint error body from
   response.json() is unknown under @cloudflare/workers-types; narrow
   it before reading .message (was the reported TS18046). The other
   reported error (byline.ts kysely Transaction variance) was TS5.x
   behaviour, resolved by the TS6 upgrade in #1074.

2. Stop shipping raw .ts for the source-exported subpaths
   (emdash/routes/*, emdash/api/route-utils, emdash/api/schemas,
   emdash/auth/providers/*). They are compiled to dist (.mjs +
   .d.mts), so a strict consumer's tsc only ever sees declarations
   (skipLibCheck covers them), eliminating the dual-package Database
   identity wall that is #1053's root cause. ./ui and .astro stay
   source (the consumer's Astro build must process them).

   - tsdown: route entrypoints fed via inputOptions.input (literal
     object, not entry globs -- [param] dirs are glob char-classes).
     entryFileNames + resolveRoute share one routeArtifactName() so
     rolldown's reserved [name]/[hash] placeholders cannot mangle
     dynamic-route artifacts.
   - A fast static guard (scripts/typecheck-public-source.mjs, wired
     into CI) fails if any subpath export ships raw .ts/.tsx again.

Verified: pnpm build, pnpm typecheck, demos+templates typecheck,
demo build (route injection e2e), lint baseline unchanged.

* style: format

* fix(build): externalize self/optional deps so route entries don't bundle them

Compiling the route/admin entries made tsdown try to bundle deps it
could not resolve at build time -- 'emdash' (the package importing
itself) and '@cloudflare/kumo' (admin-only, not an emdash dep). CI
escalates tsdown's bundling advisory to a fatal error.

- Externalize 'emdash' (self): compiled routes import it; resolved at
  the consumer's runtime where the package is installed.
- Externalize @aws-sdk/* (optional S3 deps, runtime-only).
- Keep the *-admin.tsx providers as source (bridge the admin React +
  @cloudflare/kumo runtime, like .astro/./ui); revert their exports.
- inlineOnly: false -- nothing is unintentionally bundled (all deps
  external, only our own src is); silences the CI-escalated advisory.

Guard's allowlist generalized to RUNTIME_COUPLED (Astro + admin React).

* test: route-injection entrypoint now resolves to compiled artifact

resolveRoute resolves emdash/routes/* to the compiled dist artifact
with routeArtifactName applied ([ ] -> _), so the media catch-all
route's entrypoint is api/media/file/_...key_ not [...key].ts. The
catch-all pattern assertion (the actual guarantee) is unchanged.

---------

Co-authored-by: emdashbot[bot] <emdashbot[bot]@users.noreply.github.com>
@ascorbic
ascorbic force-pushed the chore/harden-supply-chain branch from 3db236c to 6ef112d Compare May 18, 2026 10:19
@ascorbic
ascorbic enabled auto-merge (squash) May 18, 2026 10:27
@ascorbic
ascorbic merged commit 5051274 into main May 18, 2026
37 of 38 checks passed
@ascorbic
ascorbic deleted the chore/harden-supply-chain branch May 18, 2026 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants