mirror of
https://github.com/actions/setup-node.git
synced 2026-08-22 08:32:54 +00:00
Harden action metadata parsing
This commit is contained in:
parent
d0cafc58c4
commit
a0ff657b74
9
dist/cache-save/index.js
vendored
9
dist/cache-save/index.js
vendored
@ -92709,6 +92709,7 @@ function getNodeVersionFromFile(versionFilePath) {
|
||||
catch {
|
||||
core.info('Node version file is not JSON file');
|
||||
}
|
||||
const nodePrefix = 'node';
|
||||
let inRunsSection = false;
|
||||
for (const line of contents.split(/\r?\n/)) {
|
||||
const trimmedLine = line.trim();
|
||||
@ -92724,7 +92725,8 @@ function getNodeVersionFromFile(versionFilePath) {
|
||||
break;
|
||||
}
|
||||
const separatorIndex = trimmedLine.indexOf(':');
|
||||
if (trimmedLine.slice(0, separatorIndex) !== 'using') {
|
||||
if (separatorIndex <= 0 ||
|
||||
trimmedLine.slice(0, separatorIndex) !== 'using') {
|
||||
continue;
|
||||
}
|
||||
let runtime = trimmedLine.slice(separatorIndex + 1).trim();
|
||||
@ -92733,8 +92735,9 @@ function getNodeVersionFromFile(versionFilePath) {
|
||||
(runtime.startsWith('"') && runtime.endsWith('"'))) {
|
||||
runtime = runtime.slice(1, -1);
|
||||
}
|
||||
if (runtime.startsWith('node') && /^\d+$/.test(runtime.slice(4))) {
|
||||
return runtime.slice(4);
|
||||
if (runtime.startsWith(nodePrefix) &&
|
||||
/^\d+$/.test(runtime.slice(nodePrefix.length))) {
|
||||
return runtime.slice(nodePrefix.length);
|
||||
}
|
||||
}
|
||||
const found = contents.match(/^(?:node(js)?\s+)?v?(?<version>[^\s]+)$/m);
|
||||
|
||||
9
dist/setup/index.js
vendored
9
dist/setup/index.js
vendored
@ -98103,6 +98103,7 @@ function getNodeVersionFromFile(versionFilePath) {
|
||||
catch {
|
||||
core_info('Node version file is not JSON file');
|
||||
}
|
||||
const nodePrefix = 'node';
|
||||
let inRunsSection = false;
|
||||
for (const line of contents.split(/\r?\n/)) {
|
||||
const trimmedLine = line.trim();
|
||||
@ -98118,7 +98119,8 @@ function getNodeVersionFromFile(versionFilePath) {
|
||||
break;
|
||||
}
|
||||
const separatorIndex = trimmedLine.indexOf(':');
|
||||
if (trimmedLine.slice(0, separatorIndex) !== 'using') {
|
||||
if (separatorIndex <= 0 ||
|
||||
trimmedLine.slice(0, separatorIndex) !== 'using') {
|
||||
continue;
|
||||
}
|
||||
let runtime = trimmedLine.slice(separatorIndex + 1).trim();
|
||||
@ -98127,8 +98129,9 @@ function getNodeVersionFromFile(versionFilePath) {
|
||||
(runtime.startsWith('"') && runtime.endsWith('"'))) {
|
||||
runtime = runtime.slice(1, -1);
|
||||
}
|
||||
if (runtime.startsWith('node') && /^\d+$/.test(runtime.slice(4))) {
|
||||
return runtime.slice(4);
|
||||
if (runtime.startsWith(nodePrefix) &&
|
||||
/^\d+$/.test(runtime.slice(nodePrefix.length))) {
|
||||
return runtime.slice(nodePrefix.length);
|
||||
}
|
||||
}
|
||||
const found = contents.match(/^(?:node(js)?\s+)?v?(?<version>[^\s]+)$/m);
|
||||
|
||||
13
src/util.ts
13
src/util.ts
@ -68,6 +68,7 @@ export function getNodeVersionFromFile(versionFilePath: string): string | null {
|
||||
core.info('Node version file is not JSON file');
|
||||
}
|
||||
|
||||
const nodePrefix = 'node';
|
||||
let inRunsSection = false;
|
||||
for (const line of contents.split(/\r?\n/)) {
|
||||
const trimmedLine = line.trim();
|
||||
@ -85,7 +86,10 @@ export function getNodeVersionFromFile(versionFilePath: string): string | null {
|
||||
}
|
||||
|
||||
const separatorIndex = trimmedLine.indexOf(':');
|
||||
if (trimmedLine.slice(0, separatorIndex) !== 'using') {
|
||||
if (
|
||||
separatorIndex <= 0 ||
|
||||
trimmedLine.slice(0, separatorIndex) !== 'using'
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -97,8 +101,11 @@ export function getNodeVersionFromFile(versionFilePath: string): string | null {
|
||||
) {
|
||||
runtime = runtime.slice(1, -1);
|
||||
}
|
||||
if (runtime.startsWith('node') && /^\d+$/.test(runtime.slice(4))) {
|
||||
return runtime.slice(4);
|
||||
if (
|
||||
runtime.startsWith(nodePrefix) &&
|
||||
/^\d+$/.test(runtime.slice(nodePrefix.length))
|
||||
) {
|
||||
return runtime.slice(nodePrefix.length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user