Skip to content

Commit 6f23382

Browse files
Kevin-layerVclaudejustin-layerv
authored
chore: enforce supply chain age gating (#16)
## Summary - Adds `.npmrc` with `min-release-age=7` to reject npm packages published less than 7 days ago - Enables `ignore-scripts=true` to block arbitrary install scripts from packages ## Why Newly published or hijacked packages are typically detected and removed within days. A 7-day quarantine ensures compromised packages never enter our dependency tree. ## Override for critical updates ```sh npm install <pkg>@<version> --min-release-age=0 ``` ## Test plan - [ ] `npm config get min-release-age --location=project` returns `7` - [ ] `npm install` still resolves existing dependencies from lock file - [ ] `npm install --min-release-age=0 <pkg>` bypasses the restriction --------- Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]> Co-authored-by: Justin <[email protected]>
1 parent 00f73c1 commit 6f23382

3 files changed

Lines changed: 25 additions & 0 deletions

File tree

.npmrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Supply-chain hardening: reject packages published <7 days ago.
2+
# Requires npm 11+ (Node 22+). Silently ignored on older versions.
3+
# CI enforces this (Node 22); local dev on older Node is not gated.
4+
min-release-age=7
5+
6+
# Block arbitrary install/lifecycle scripts from dependencies.
7+
# Note: this also suppresses prepublishOnly during local `npm publish`.
8+
# CI runs `npm run build` explicitly before publish, so this is safe.
9+
# If a dependency ever legitimately requires a postinstall hook (e.g. a
10+
# native module using node-gyp), re-enable per-package with
11+
# `npm install <pkg> --ignore-scripts=false`.
12+
ignore-scripts=true

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22

CONTRIBUTING.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ Releases are automated via [Release Please](https://github.com/googleapis/releas
4040
- `fix:` → patch version bump
4141
- `feat!:` or `BREAKING CHANGE:` → major version bump
4242

43+
### Always publish via CI
44+
45+
**Do not run `npm publish` locally.** The project's `.npmrc` sets
46+
`ignore-scripts=true` as a supply-chain defense, which (as a side effect)
47+
suppresses the `prepublishOnly` lifecycle hook. A local publish would ship
48+
whatever is currently in `dist/` without re-running the build. The release
49+
workflow (`.github/workflows/release-please.yml`) explicitly runs
50+
`npm run build` before `npm publish`, so publishing via CI is safe.
51+
52+
If you need to verify a build artifact locally, run `npm run build` directly
53+
rather than invoking `npm publish` with `--dry-run`.
54+
4355
## License
4456

4557
By contributing, you agree that your contributions will be licensed under the MIT License.

0 commit comments

Comments
 (0)