Repository navigation
chore(npm): enforce seven-day release age - #37
Conversation
Apply npm's project-level minimum release age so dependency resolution avoids newly published package versions during their highest-risk window. Co-Authored-By: Yuri Gui <yugui923@users.noreply.github.com>
📝 WalkthroughWalkthroughThe Changesnpm install policy
Estimated code review effort: 1 (Trivial) | ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.npmrc:
- Around line 1-5: Update the comment above the npm min-release-age
configuration to explicitly state that releases published seven days ago or less
are blocked, clarifying that the seven-day boundary is inclusive; leave the
min-release-age value unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| # Refuse to install npm packages published less than 7 days ago. | ||
| # Defense against compromised-maintainer publishes (typically yanked | ||
| # within hours). Requires npm >= 11.10.0; value is in DAYS (unlike | ||
| # pnpm/Yarn which use minutes, or Bun which uses seconds). | ||
| min-release-age=7 |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
npm min-release-age documentation exact boundary seven days ago more than 7 days
💡 Result:
The npm configuration setting min-release-age is an integer value representing a duration in days [1][2][3]. When set, it instructs npm to exclude any package version that was published within the specified number of days from the current time [2][3][4]. For example, setting min-release-age=7 enforces a "cooldown" period of seven days, meaning npm will only consider versions of a package that were published more than seven days ago [2][3]. Key points regarding the boundary and functionality include: - Inclusive Definition: The setting acts as a relative date filter [1]. If you set min-release-age=7, a version published exactly 7 days ago (or less) is excluded [3][4]. Only versions published more than 7 days ago are eligible for installation [2][3]. - Implementation: It is a configuration option available in npm CLI version 11.10.0 and later [5][2][3]. It works by flattening the relative age value into a specific date (equivalent to the --before configuration) during the resolution process [1][6]. - Exclusivity: The min-release-age setting is mutually exclusive with the --before configuration, as they perform overlapping functions [1][6]. - Scope: The setting applies to package resolution during commands like npm install [1][7]. It does not affect npm ci, as that command installs from the existing package-lock.json file verbatim without performing new resolution [7].
Citations:
- 1: feat: add min-release-age npm/cli#8965
- 2: https://www.stork.ai/blog/this-setting-stops-99-of-npm-attacks
- 3: https://arrangeactassert.com/posts/the-package-manager-settings-that-would-have-blocked-the-axios-attack/
- 4: https://d3creative.uk/blog/npm-min-release-age-install-cooldown
- 5: https://www.brandonpugh.com/til/node/package-version-cooldown/
- 6: https://charpeni.com/blog/protecting-against-compromised-packages-with-minimum-release-age
- 7: [Support]
min-release-agefornpm cinpm/cli#9281
Clarify the seven-day boundary. min-release-age=7 blocks versions published 7 days ago or less, so the comment should say that exactly 7-day-old releases are also excluded.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.npmrc around lines 1 - 5, Update the comment above the npm min-release-age
configuration to explicitly state that releases published seven days ago or less
are blocked, clarifying that the seven-day boundary is inclusive; leave the
min-release-age value unchanged.
Summary
Validation
sfw npm cinpm run typechecknpm run lintnpm run format:checknpm run buildnpm run test:coveragenpm audit --audit-level=high— 0 vulnerabilitiesmin-release-age=7Generated with Agent Navigator
Summary by CodeRabbit