Skip to content

feat: bootstrap @socketsecurity/lib + @socketregistry/packageurl-js + @sinclair/typebox via firewall-checked registry fetch#1282

Merged
John-David Dalton (jdalton) merged 3 commits intomainfrom
chore/bootstrap-from-registry
Apr 27, 2026
Merged

feat: bootstrap @socketsecurity/lib + @socketregistry/packageurl-js + @sinclair/typebox via firewall-checked registry fetch#1282
John-David Dalton (jdalton) merged 3 commits intomainfrom
chore/bootstrap-from-registry

Conversation

@jdalton
Copy link
Copy Markdown
Contributor

@jdalton John-David Dalton (jdalton) commented Apr 27, 2026

Self-landable split from #1279.

Adds scripts/bootstrap-firewall-deps.mts that downloads zero-dep Socket-fleet packages from the npm registry tarball directly into node_modules/<scope>/<name>/ BEFORE pnpm install runs. Wired via preinstall lifecycle hook.

Why

setup.mts and other root-script importers fail on a fresh clone because pnpm install hasn't run yet. Pre-seeding from the registry tarball solves the chicken-and-egg.

Bootstrapped packages

In sorted order:

  • @sinclair/typebox — schema runtime used by xport-schema.mts + the setup-security-tools hook
  • @socketregistry/packageurl-js — used by setup tooling
  • @socketsecurity/lib — needed by setup.mts, postinstall hooks, etc.

Firewall verification

Each package version is checked against firewall-api.socket.dev/purl/<encoded-purl> BEFORE the tarball is downloaded. Any alert in the response means malware (the API does not return informational alerts), so we block unconditionally on a populated alerts array. Network failures are non-fatal — a network blip should not break a fresh clone.

This mirrors the check-firewall.mts helper in socket-registry/.github/actions/lib/.

Behavior

  • Reads pinned version from pnpm-workspace.yaml catalog: OR root package.json deps/devDeps — single source of truth.
  • Skips silently if the package is already resolvable at the matching version.
  • Refuses install if the firewall flagged the package.
  • Uses curl + tar (POSIX, no extra tooling).

Test plan

  • Bootstrap runs locally and pre-seeds all 3 packages with firewall checks
  • CI passes

Note

Medium Risk
Adds a new preinstall hook that downloads and extracts npm tarballs into node_modules, which changes install-time behavior and introduces reliance on external network/CLI tools (curl, tar, firewall API). While versions are pinned and malware-checked, failures or environment differences could impact fresh installs.

Overview
Ensures fresh clones can run install-time scripts by pre-seeding a small set of zero-dependency packages into node_modules before pnpm install completes.

Adds scripts/bootstrap-firewall-deps.mts and wires it via package.json preinstall; the script reads pinned versions (from pnpm-workspace.yaml catalog: or root package.json), checks each package/version against firewall-api.socket.dev, then fetches the exact registry tarball and extracts it into node_modules, skipping when the correct version is already present and failing fast when the firewall returns alerts.

Reviewed by Cursor Bugbot for commit a29d513. Configure here.

…tall

Adds scripts/bootstrap-from-registry.mts that downloads zero-dep
Socket packages (currently @socketsecurity/lib) from the npm
registry tarball directly into node_modules/<scope>/<name>/ BEFORE
pnpm install runs. Wired via package.json preinstall lifecycle hook.

Why: setup.mts and other root-script importers of @socketsecurity/lib
fail on a fresh clone because pnpm install hasn't run yet. Pre-
seeding from the registry tarball solves the chicken-and-egg.

Reads pinned version from pnpm-workspace.yaml `catalog:` OR root
package.json deps/devDeps — single source of truth, no hardcoded
version.

Self-landable split from #1279.
@jdalton John-David Dalton (jdalton) changed the title feat: bootstrap @socketsecurity/lib from npm registry before pnpm install feat: bootstrap @socketsecurity/lib + @socketregistry/packageurl-js + @sinclair/typebox via firewall-checked registry fetch Apr 27, 2026
@jdalton
Copy link
Copy Markdown
Contributor Author

bugbot run

Comment thread scripts/bootstrap-firewall-deps.mts
Comment thread scripts/bootstrap-firewall-deps.mts
Comment thread scripts/bootstrap-firewall-deps.mts
Bugbot flagged 3 repo-convention violations on this file:
  - raw fetch() instead of httpJson
  - raw rmSync instead of safeDelete
  - inline e.message instead of errorMessage()

All three are intentional. The script runs BEFORE pnpm install, so
it cannot import @socketsecurity/lib (the very package it
bootstraps). Document the exceptions explicitly in the file header
so future readers (and bots) can see the constraint without
re-deriving it from the code.
…l-deps

The script does more than fetch from the npm registry: it also runs
each pinned tarball through Socket Firewall and refuses to install if
the firewall returns any alert. The new name reflects both halves of
the contract — the firewall verification is the security-critical part
that "from registry" obscured.

- scripts/bootstrap-from-registry.mts → scripts/bootstrap-firewall-deps.mts
- Update package.json preinstall hook to point at the new path
- Update User-Agent string and fileoverview to match
@jdalton
Copy link
Copy Markdown
Contributor Author

bugbot run

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit a29d513. Configure here.

@jdalton John-David Dalton (jdalton) merged commit 19f9af2 into main Apr 27, 2026
14 checks passed
@jdalton John-David Dalton (jdalton) deleted the chore/bootstrap-from-registry branch April 27, 2026 18:55
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.

2 participants