[Fix] nvm_remote_versions: only consult io.js's version list for majors 1 through 3

io.js only released v1 through v3,
but its version list was downloaded and searched for every pattern,
including ones like `0.12` or `20` that can only ever match node versions.
Besides the needless index.tab download on every such `nvm install`,
io.js's "no match" status was returned even when node had matches,
so `nvm ls-remote 20` printed node's versions and then exited 3.
Patterns whose major is 0 or 4+ now only consult node's list,
so `nvm ls-remote` exits 0 for them when node has matching versions.
The listed and resolved versions are unchanged

Discovered by Anthropic's OSS Scanner, as ANT-2026-AKH0HYWD; the scanner reported it as a vulnerability, but it is not one.
This commit is contained in:
Jordan Harband committed 2026-10-23 08:53:59 -07:00
1 parent 59e008fd62
commit cbd8f8e920
3 files changed
+41

No files matched your search

+4
View File
@@ -1101,6 +1101,10 @@ nvm_remote_versions() {
NVM_FLAVOR="${NVM_NODE_PREFIX}"
unset PATTERN
;;
[04-9]* | [1-9][0-9]* | v[04-9]* | v[1-9][0-9]*)
# io.js only released v1 through v3, so it has no versions matching any other major
NVM_FLAVOR="${NVM_NODE_PREFIX}"
;;
esac
if nvm_validate_implicit_alias "${PATTERN-}" 2>/dev/null; then