Skip to content

npm: allow git dependencies only in the root package.json#66

Merged
amezin merged 1 commit intomainfrom
npm-allow-git
May 5, 2026
Merged

npm: allow git dependencies only in the root package.json#66
amezin merged 1 commit intomainfrom
npm-allow-git

Conversation

@amezin
Copy link
Copy Markdown
Member

@amezin amezin commented May 3, 2026

https://github.blog/changelog/2026-02-18-npm-bulk-trusted-publishing-config-and-script-security-now-generally-available/

Git dependencies-direct or transitive-can include .npmrc files that override the git executable path. This enables arbitrary code execution during install even when using --ignore-scripts.

https://github.blog/changelog/2026-02-18-npm-bulk-trusted-publishing-config-and-script-security-now-generally-available/

Git dependencies-direct or transitive-can include .npmrc files
that override the git executable path. This enables arbitrary
code execution during install even when using --ignore-scripts.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 3, 2026

📝 Walkthrough

Summary by CodeRabbit

  • Chores
    • Updated npm configuration to adjust git operation permissions during package installation.

Walkthrough

The .npmrc configuration file is updated to include allow-git = root, which explicitly permits npm to perform git operations under the root user. The existing ignore-scripts = true setting remains unchanged.

Changes

npm Configuration Update

Layer / File(s) Summary
Configuration
.npmrc
Adds allow-git = root to permit npm git operations under root user context.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding allow-git=root to .npmrc to restrict git dependencies to the root package.json, addressing a security concern.
Description check ✅ Passed The description is directly related to the changeset, referencing a GitHub security advisory about git dependencies enabling arbitrary code execution and explaining the rationale for the configuration change.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch npm-allow-git

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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@amezin amezin marked this pull request as ready for review May 3, 2026 07:41
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.npmrc:
- Line 6: The .npmrc uses allow-git which is ignored by npm < 11.9.0; ensure CI
and developer environments run npm ≥ 11.9.0 by adding an explicit npm version
pin — e.g., add an engines field to package.json ("npm": ">=11.9.0"), or add a
.nvmrc / .node-version with a Node release that ships npm ≥ 11.9.0, or configure
your GitHub Actions setup-node step to install npm >= 11.9.0; update whichever
of package.json, .nvmrc, .node-version or the CI setup-node action you prefer so
that the allow-git setting in .npmrc is honored.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: fc0ed3ad-5e87-4bbb-afc9-97984cab2484

📥 Commits

Reviewing files that changed from the base of the PR and between 979465a and 72cf9f2.

📒 Files selected for processing (1)
  • .npmrc

Comment thread .npmrc
# SPDX-License-Identifier: CC0-1.0

ignore-scripts = true
allow-git = root
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Check npm/node version pinning in repo metadata =="
fd -HI '(^|/)(package.json|.nvmrc|.node-version|Dockerfile|dockerfile|compose\.ya?ml|ci\.yml|.*workflow.*\.ya?ml)$' \
  | xargs -r rg -n -C2 --iglob '*package.json' --iglob '*.yml' --iglob '*.yaml' --iglob 'Dockerfile*' \
    '("engines"\s*:\s*\{|"npm"\s*:\s*|node-version|setup-node|npm@|corepack|npm ci|npm install)'

echo
echo "== Check for npm config usage related to allow-git =="
rg -n -C2 --iglob '*.yml' --iglob '*.yaml' --iglob '*.sh' --iglob '*.md' --iglob '.npmrc' \
  '(allow-git|npm ci|npm install|--allow-git)'

echo
echo "Expected: all execution paths that run npm are pinned to npm >= 11.9.0 (or explicitly pass --allow-git=root)."

Repository: ddterm/gjs-typelib-installer

Length of output: 886


🏁 Script executed:

# Check package.json for engines field
cat package.json | head -50

# Check if .nvmrc or .node-version files exist
fd -type f -name '.nvmrc' -o -name '.node-version'

# Check GitHub Actions workflow for node-version input
cat .github/workflows/ci.yml | grep -A5 -B5 'setup-node\|node-version' || echo "No setup-node or node-version found"

Repository: ddterm/gjs-typelib-installer

Length of output: 1580


🏁 Script executed:

cat .github/workflows/ci.yml

Repository: ddterm/gjs-typelib-installer

Length of output: 3811


🌐 Web query:

GitHub Actions ubuntu-24.04 default Node.js npm version

💡 Result:

On GitHub Actions ubuntu-24.04 runner (current as of 2026-05-03), the default Node.js version is 20.20.2. This is the version available on PATH without using actions/setup-node. The corresponding default npm version is the one bundled with Node.js 20.20.2, which is npm 10.8.3 (confirmed from Node.js release notes and standard bundling). Multiple Node.js versions are pre-cached (20.x, 22.x, 24.x), but 20.20.2 is listed first under Language and Runtime as the primary/default installation. Note: Node.js 20 reaches EOL on 2026-04-30, and there is an open issue discussing updating the default to 22 or 24 post-EOL, but as of current sources (main branch Readme and March/April 2026 image releases), it remains 20.20.2.

Citations:


Pin npm to version ≥ 11.9.0 to enforce allow-git restriction.

The allow-git config is silently ignored by npm < 11.9.0. Current GitHub Actions ubuntu-24.04 default is npm 10.8.3, which does not support this feature. Add version pinning via engines field in package.json, .nvmrc, .node-version, or setup-node action in CI to ensure npm ≥ 11.9.0 runs in all execution contexts.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.npmrc at line 6, The .npmrc uses allow-git which is ignored by npm <
11.9.0; ensure CI and developer environments run npm ≥ 11.9.0 by adding an
explicit npm version pin — e.g., add an engines field to package.json ("npm":
">=11.9.0"), or add a .nvmrc / .node-version with a Node release that ships npm
≥ 11.9.0, or configure your GitHub Actions setup-node step to install npm >=
11.9.0; update whichever of package.json, .nvmrc, .node-version or the CI
setup-node action you prefer so that the allow-git setting in .npmrc is honored.

@amezin amezin merged commit 72cf9f2 into main May 5, 2026
22 checks passed
@amezin amezin temporarily deployed to github-pages May 5, 2026 22:17 — with GitHub Actions Inactive
@amezin amezin deleted the npm-allow-git branch May 5, 2026 22:27
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.

1 participant