Skip to content

fix(ng-dev): validate nvmrc-sourced Node.js version before fetch#3738

Merged
josephperrott merged 2 commits into
angular:mainfrom
adilburaksen:fix/nvmrc-node-version-validation
Jun 8, 2026
Merged

fix(ng-dev): validate nvmrc-sourced Node.js version before fetch#3738
josephperrott merged 2 commits into
angular:mainfrom
adilburaksen:fix/nvmrc-node-version-validation

Conversation

@adilburaksen

Copy link
Copy Markdown
Contributor

Summary

#75773923 added semver.valid() validation to the PNPM and TypeScript version strings before they are interpolated into registry fetch URLs (syncPnpm, syncTypeScript), but the Node.js version path was left unguarded.

In processNodeToolchainArgs (ng-dev/misc/sync-module-bazel/sync-module-bazel.ts), effectiveVersion can originate from the .nvmrc file (node_version_from_nvmrc) and is passed to getNodeJsRepositories, which interpolates it into:

fetch(`https://nodejs.org/dist/v${version}/SHASUMS256.txt`)

without the same validation, leaving the URL path open to manipulation via the version string.

Fix

Apply the existing semver.valid() guard to effectiveVersion before it is used, consistent with the PNPM and TypeScript checks added in #75773923.

#75773923 added `semver.valid()` guards to the PNPM and TypeScript version
strings before they are interpolated into registry fetch URLs, but the
Node.js version was left unguarded. In `processNodeToolchainArgs`,
`effectiveVersion` can originate from the `.nvmrc` file and flows into
`getNodeJsRepositories`, which interpolates it into
`fetch(`https://nodejs.org/dist/v${version}/SHASUMS256.txt`)` without
validation.

Apply the same `semver.valid()` check to `effectiveVersion` before it is used,
matching the guards already added for PNPM and TypeScript.

@gemini-code-assist gemini-code-assist 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 pull request introduces validation for the Node.js version using semver.valid in sync-module-bazel.ts to ensure only valid versions are processed. The reviewer identified an issue where using the original effectiveVersion instead of the normalized version returned by semver.valid could result in a double 'v' prefix (e.g., 'vv24.16.0') in URLs, and provided a code suggestion to fix this.

Comment thread ng-dev/misc/sync-module-bazel/sync-module-bazel.ts Outdated
@josephperrott josephperrott added the action: merge The PR is ready for merge by the caretaker label Jun 8, 2026

@josephperrott josephperrott left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@josephperrott josephperrott force-pushed the fix/nvmrc-node-version-validation branch from 0c20293 to 34d6c76 Compare June 8, 2026 14:57
@josephperrott josephperrott merged commit e78f06f into angular:main Jun 8, 2026
16 checks passed
@josephperrott

Copy link
Copy Markdown
Member

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants