Skip to content

Add .npmrc with security hardening settings#258

Open
danmcc-admin wants to merge 1 commit into
masterfrom
security/add-npmrc
Open

Add .npmrc with security hardening settings#258
danmcc-admin wants to merge 1 commit into
masterfrom
security/add-npmrc

Conversation

@danmcc-admin

Copy link
Copy Markdown

Summary

  • Adds .npmrc with ignore-scripts=true and save-exact=true
  • ignore-scripts=true prevents arbitrary code execution during npm install (supply chain defense)
  • save-exact=true pins exact dependency versions for reproducible builds

If a package requires install scripts

Add a per-package allowlist in .npmrc:

lifecycle-script-allowed[]=sharp
lifecycle-script-allowed[]=esbuild

Or run one-off with:

npm install --ignore-scripts=false <package-name>

Context

Part of an org-wide security hardening initiative for all npm-based repositories.

Security hardening: ignore-scripts prevents malicious install scripts
from running during npm install, and save-exact pins dependency versions.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 10, 2026 01:48
@danmcc-admin danmcc-admin requested a review from a team as a code owner June 10, 2026 01:48

@constructor-claude-bedrock constructor-claude-bedrock Bot 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.

Code Review

This PR adds a .npmrc file with ignore-scripts=true and save-exact=true for supply chain security hardening, but ignore-scripts=true breaks the existing prepare lifecycle script that installs Husky git hooks.

Inline comments: 2 discussions added

Overall Assessment: ⚠️ Needs Work

Comment thread .npmrc
@@ -0,0 +1,2 @@
ignore-scripts=true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Critical Issue: Setting ignore-scripts=true will break the existing prepare script ("prepare": "husky install" in package.json). When any contributor runs npm install, Husky will no longer be set up automatically, meaning the pre-push lint hook (.husky/pre-push) won't be installed and will silently stop working.

The PR description mentions using a per-package allowlist (lifecycle-script-allowed[]=<pkg>) as a workaround, but that syntax is not supported by standard npm — it is specific to pnpm. For npm, there is no built-in per-package script allowlist.

Practical options to resolve this:

  1. Remove ignore-scripts=true and rely on package-lock.json integrity + npm audit for supply chain defense instead.
  2. Replace prepare with a manual step: Remove the prepare script and document that contributors must run npx husky install once after cloning. Update the README accordingly.
  3. Use a .husky-aware workaround: Keep the setting but add a note in the README and CI configuration reminding contributors/CI to run npm run prepare explicitly after npm install --ignore-scripts.

Comment thread .npmrc
@@ -0,0 +1,2 @@
ignore-scripts=true
save-exact=true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: save-exact=true only affects packages added via npm install <pkg> going forward — it does not pin the existing range-specifier dependencies already in package.json (e.g., "chai": "^4.3.4", "node-fetch": "^3.3.2", etc.). The existing devDependencies and dependencies still use ^ ranges, so reproducibility relies entirely on package-lock.json being committed and respected.

Consider updating the existing entries in package.json to exact versions to make the intent consistent, or document that package-lock.json is the primary reproducibility mechanism and save-exact=true is just a forward-looking guardrail.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds repository-level npm configuration to harden installs against supply-chain risks and improve reproducibility for dependency versioning in this Node.js client library.

Changes:

  • Adds .npmrc with ignore-scripts=true to disable npm lifecycle scripts by default.
  • Adds .npmrc with save-exact=true so newly added dependencies are saved with exact versions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .npmrc
Comment on lines +1 to +2
ignore-scripts=true
save-exact=true
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