Skip to content

console: enable npmMinimalAgeGate (3d) and bump Yarn to 4.14.1#36196

Open
jasonhernandez wants to merge 3 commits intomainfrom
console/yarn-min-age-gate
Open

console: enable npmMinimalAgeGate (3d) and bump Yarn to 4.14.1#36196
jasonhernandez wants to merge 3 commits intomainfrom
console/yarn-min-age-gate

Conversation

@jasonhernandez
Copy link
Copy Markdown
Contributor

@jasonhernandez jasonhernandez commented Apr 21, 2026

Motivation

Harden the console's npm supply chain against zero-day compromised package releases. Several recent npm malware events (dependency takeovers, postinstall exploits) have been caught by the community within days of publication, but a CI/dev install that happens to run during that window can pull in the bad version before detection. Yarn 4.10+ ships npmMinimalAgeGate, which blocks installation of packages published more recently than a configurable cooldown. This adopts it.

Description

  • Set npmMinimalAgeGate: "3d" in console/.yarnrc.yml. Packages published within the last 3 days will be excluded from resolution.
  • Seed npmPreapprovedPackages: [] with a comment explaining its purpose — the documented escape hatch if we ever need to bypass the gate for a specific descriptor or scope.
  • Bump packageManager / volta.yarn from 4.3.14.14.1 (current stable 4.x). The gate requires Yarn 4.10+.
  • Leave enableScripts at its default (false). This is a second supply-chain win: no third-party package lifecycle scripts run on install. The four packages that declare scripts (@sentry/cli, msw, esbuild, core-js) are all functional without them — binary tools ship via platform-specific optional deps, msw is used only in node-mode in our tests, and core-js's postinstall is just a support message.

yarn.lock metadata bumps version: 89 (Yarn 4.14 lockfile format). The only other line inside is a TypeScript compat-patch hash rotation — internal to Yarn's patching, harmless. No CI scripts or Dockerfiles need updating; every install site already runs corepack enable + yarn install --immutable and follows packageManager from package.json.

Risks / watch-outs for reviewers:

  1. Lockfile v8 → v9 is incompatible with older Yarn clients. Any dev on Yarn <~4.9 will fail to read the lockfile until they corepack enable to pick up the new pin. CI is fine (already runs corepack enable). Worth a team heads-up.
  2. Silent-failure UX on the age gate. If someone runs yarn add foo@latest on a package published within the last 3 days, Yarn reports "not found" rather than "blocked by age gate." Confusing but not damaging. Escape hatch is npmPreapprovedPackages.
  3. Dependabot alignment. Bump bots may propose versions the gate refuses. Dependabot v2 has a matching cooldown field — we should keep these aligned at 3 days.
  4. Future deps that actually need postinstall. If a new dependency is added later whose binary/assets truly require a lifecycle script, the install will skip it silently (YN0004 warning). Fix is per-package allowlist via dependenciesMeta in package.json, not a global enableScripts: true.

Verification

Locally on this branch, with enableScripts at the default (off) and no dependenciesMeta allowlist:

  • yarn install (fresh, empty node_modules/) — completes. YN0004 warns that build scripts are disabled for @sentry/cli, msw, esbuild, core-js, but nothing downstream actually needs them (see below).
  • yarn install --immutable (CI-style) — clean.
  • yarn typecheck — passes.
  • yarn lint — passes.
  • yarn test --run — 6 tests fail, same 6 fail on main baseline with Yarn 4.3.1. Failures are a pre-existing Set.prototype.difference is not a function issue (requires Node 22+, volta.node is pinned to 20.12.2). Not caused by this PR.
  • yarn build:local — succeeds (esbuild works without postinstall; platform binary from @esbuild/darwin-arm64).
  • yarn build (with SENTRY_RELEASE=test-build) — succeeds. sentry-cli binary is present and callable via @sentry/cli-darwin optional dep; @sentry/vite-plugin can invoke it.
  • node .../node_modules/@sentry/cli/bin/sentry-cli --versionsentry-cli 2.58.5. Works without the postinstall having run.
  • grep across the repo confirms msw's service worker (setupWorker / msw/browser / mockServiceWorker) is not referenced anywhere in console/src. msw is used exclusively in node mode for unit tests.

Still to confirm:

  • CI green on this PR.
  • Manual: yarn add <package>@<fresh-version> rejects as expected.

jasonhernandez and others added 3 commits April 21, 2026 16:45
Adds a 3-day publish-age cooldown on npm installs to reduce exposure
to zero-day supply chain attacks. Requires Yarn 4.10+, so this also
bumps the pinned Yarn from 4.3.1 to 4.14.1 (current stable 4.x).

`enableScripts: true` is set explicitly — it was implicit under 4.3
and postinstall is required for @sentry/cli and msw. `npmPreapprovedPackages`
is seeded empty as the documented escape hatch for future exceptions.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Tightens the supply-chain posture set up in the previous commit. The
earlier claim that @sentry/cli and msw strictly required postinstall
scripts turned out to be wrong:

- @sentry/cli ships its binary via platform-specific optional deps
  (@sentry/cli-darwin, @sentry/cli-linux-x64, etc), not postinstall.
  sentry-cli --version works without any script ever running.
- esbuild uses the same optional-deps pattern.
- msw's postinstall only copies a browser service worker. The console
  uses msw/node exclusively (no setupWorker / msw/browser references
  anywhere in src/), so the service worker file is unused.
- core-js's postinstall is a support-message console.log, never required.

Verified: yarn install --immutable, yarn typecheck, yarn lint, yarn test
--run, yarn build (with SENTRY_RELEASE set) all succeed without any
package lifecycle scripts executing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jasonhernandez jasonhernandez marked this pull request as ready for review April 22, 2026 02:48
@jasonhernandez jasonhernandez requested a review from a team as a code owner April 22, 2026 02:48
@jasonhernandez jasonhernandez requested review from SangJunBak and leedqin and removed request for a team April 22, 2026 02:48
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.

1 participant