Skip to content

[FSSDK-13494] Harden npm supply chain - #1193

Open
Raju Ahmed (raju-opti) wants to merge 4 commits into
masterfrom
harden-npm-supply-chain
Open

Raju Ahmed (raju-opti) wants to merge 4 commits into
masterfrom
harden-npm-supply-chain

Conversation

@raju-opti

@raju-opti Raju Ahmed (raju-opti) commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Reduces the risk of a compromised npm package or GitHub Action running in CI or ending up in a published release.

  • npm: .npmrc refuses versions published less than 7 days ago, git and URL dependencies, and unknown config keys. allowScripts in each package.json lists which dependencies may run install scripts. These settings need npm 12, so a shared setup action (.github/actions/setup-node-npm) installs it and applies them to every npm command in CI.
  • Workflows: every job uses that action and npm ci. Release and GHR backfill skip the npm cache, and release verifies registry signatures before building. Checkouts don't keep credentials on disk, and the Coveralls action is pinned to a commit SHA.

Tests still run on Node 18–24 (jobs install with npm 12, then switch Node to run tests). Nothing changes for SDK users.

Test plan

  • node scripts/pick-npm-version.js 12 picks 12.2.3, with and without min-release-age in .npmrc.
  • CI on this PR runs every job in javascript.yml.
  • release.yml not run yet. workflow_dispatch runs it with DRY_RUN=true.

Issues

  • FSSDK-13494

🤖 Generated with Claude Code

- Add .npmrc (min-release-age, allow-git/allow-remote=none, strict-npmrc),
  symlinked into every sub-project.
- Add the setup-node-npm composite action: Node from .nvmrc, npm 12 chosen
  by scripts/pick-npm-version.js, repo .npmrc applied to every npm command,
  strict-allow-scripts, public registry forced.
- Use it in all workflows; npm install -> npm ci; checkout/setup-node -> v7;
  pin the Coveralls action to a commit SHA.
- release.yml: no npm cache; verify registry signatures before building.
- Add devEngines and allowScripts to the package.json files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread .github/workflows/integration_test.yml Resolved
Comment thread .github/workflows/javascript.yml Resolved
Comment thread .github/workflows/javascript.yml Resolved
Comment thread .github/workflows/javascript.yml Resolved
Comment thread .github/workflows/javascript.yml Resolved
Comment thread .github/workflows/javascript.yml Resolved
Comment thread .github/workflows/javascript.yml Resolved
Comment thread .github/workflows/javascript.yml Resolved
Comment thread .github/workflows/lint_markdown.yml Resolved
@coveralls

Coveralls (coveralls) commented Nov 26, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 77.435%. remained the same — harden-npm-supply-chain into master

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Release and backfill jobs still restore npm caches because setup-node v7’s automatic package-manager caching remains enabled despite an empty cache input, violating their explicit no-cache requirement.

1 open issue
1 file not reviewed
  • examples/typescript/package-lock.json: Generated file
What changed in this PR

This PR hardens the SDK’s npm supply chain by centralizing CI setup and restricting dependency sources, release age, and install scripts, while preserving Node 18 runtime support.

Changes:

  • Adds shared Node 22/npm 12 setup with age-based npm version selection and repository-wide npm settings.
  • Updates workflows to use locked installs, safer checkout settings, pinned Coveralls, and release signature verification.
  • Adds development-tool requirements and install-script policies, refreshes the TypeScript lockfile, and separates CommonJS installation from runtime testing.
File Description
tests/​react-native-metro/​fixtures/​rn-0.87/​package.json Adds development Node/npm requirements.
tests/​react-native-metro/​fixtures/​rn-0.73/​package.json Adds tool requirements and denies fsevents scripts.
tests/​browser/​package.json Adds tool requirements and denies driver/fsevents scripts.
scripts/​run-cjs-example.js Adds --skip-run for separate installation and runtime testing.
scripts/​README.md Documents age-based npm version selection.
scripts/​pick-npm-version.js Selects an eligible, sufficiently old npm release.
package.json Adds development requirements and install-script restrictions.
examples/​typescript/​package.json Adds development Node/npm requirements.
examples/​typescript/​package-lock.json Adds registry integrity metadata and updates Node types.
examples/​node-commonjs/​package.json Adds the development npm requirement.
.nvmrc Selects Node 22 for development and CI setup.
.npmrc Restricts dependency age and sources; enables strict config validation.
.github/​workflows/​release.yml Uses shared setup and verifies signatures before building.
.github/​workflows/​lint_markdown.yml Updates checkout and disables credential persistence.
.github/​workflows/​javascript.yml Adopts hardened setup, locked installs, and pinned Coveralls.
.github/​workflows/​integration_test.yml Updates checkout and disables token persistence.
.github/​workflows/​ghr_backfill.yml Adopts shared setup with caching requested off.
.github/​actions/​setup-node-npm/​action.yml Centralizes Node/npm installation and CI supply-chain settings.

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Empty cache inputs still trigger setup-node’s automatic npm caching through the new package-manager metadata, so release and backfill jobs restore/save caches despite explicitly requesting no cache.

1 open issue
1 file not reviewed
  • examples/typescript/package-lock.json: Generated file

Review effort: Balanced

@raju-opti
Raju Ahmed (raju-opti) requested a balanced review from Copilot November 27, 2026 12:55
@raju-opti Raju Ahmed (raju-opti) changed the title [FSSDK-13494] Harden npm supply chain in CI [FSSDK-13494] Harden npm supply chain Nov 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The TypeScript CI helper still uses npm install for dependencies, allowing stale example lockfiles to be silently updated despite the new npm ci step.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Replace helper npm install calls with npm ci

.github/​workflows/​javascript.yml:47

The TypeScript job still runs npm install twice through scripts/run-ts-example.js (lines 106 and 114), including for the example's dev dependencies, so the new npm ci step does not deliver the PR's stated switch to frozen-lockfile installs for this job. A stale example lockfile can still be updated silently instead of failing CI. Use npm ci for the helper's dependency-install steps, or install both projects with npm ci here and let the helper skip those steps; keep the local SDK tarball installation separate.

1 resolved since last review
1 file not reviewed
  • examples/typescript/package-lock.json: Generated file

Review effort: Balanced

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human assessment is needed because the CI and release npm selector lacks automated coverage for filtering and version ordering, leaving potential regressions in this supply-chain gate unverified.

No open issues 🎉

1 file not reviewed
  • examples/typescript/package-lock.json: Generated file

Review effort: Balanced

This branch has not been deployed

No deployments
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.

3 participants