5
0
mirror of https://gitea.com/actions/setup-java.git synced 2026-08-05 02:31:18 +00:00

Update brace-expansion security fix

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Bruno Borges
2026-08-04 19:47:45 -04:00
parent c4ba924625
commit b5c6639b25
3 changed files with 63 additions and 11 deletions
+30 -4
View File
@@ -59543,7 +59543,7 @@ function combine(acc, pre, values, max, maxLength, dropEmpties) {
} }
// The expansion values of a single numeric (`1..5`) or alphabetic (`a..e..2`) // The expansion values of a single numeric (`1..5`) or alphabetic (`a..e..2`)
// sequence body. // sequence body.
function expandSequence(body, isAlphaSequence, max) { function expandSequence(body, isAlphaSequence, max, maxLength) {
const n = body.split(/\.\./); const n = body.split(/\.\./);
const N = []; const N = [];
// A sequence body always splits into two or three parts, but the compiler // A sequence body always splits into two or three parts, but the compiler
@@ -59566,6 +59566,7 @@ function expandSequence(body, isAlphaSequence, max) {
test = gte; test = gte;
} }
const pad = n.some(isPadded); const pad = n.some(isPadded);
let length = 0;
for (let i = x; test(i, y) && N.length < max; i += incr) { for (let i = x; test(i, y) && N.length < max; i += incr) {
let c; let c;
if (isAlphaSequence) { if (isAlphaSequence) {
@@ -59589,7 +59590,10 @@ function expandSequence(body, isAlphaSequence, max) {
} }
} }
} }
if (length + c.length > maxLength)
break;
N.push(c); N.push(c);
length += c.length;
} }
return N; return N;
} }
@@ -59643,7 +59647,7 @@ function expand_(str, max, maxLength, isTop) {
} }
let values; let values;
if (isSequence) { if (isSequence) {
values = expandSequence(m.body, isAlphaSequence, max); values = expandSequence(m.body, isAlphaSequence, max, maxLength);
} }
else { else {
let n = parseCommaParts(m.body); let n = parseCommaParts(m.body);
@@ -59661,9 +59665,31 @@ function expand_(str, max, maxLength, isTop) {
} }
/* c8 ignore stop */ /* c8 ignore stop */
} }
// Values that `combine` is going to drop as empty produce no result, so
// they must not count against `max` - otherwise `{a,,b}` with `max: 2`
// would stop at `['a', '']` and yield one result instead of two. Skipping
// them outright keeps `values` bounded while leaving `max` a bound on
// *kept* results.
let dropsEmpties = dropEmpties && !m.post.length && !pre;
for (let d = 0; dropsEmpties && d < acc.length; d++) {
if (acc[d]) {
dropsEmpties = false;
}
}
values = []; values = [];
for (let j = 0; j < n.length; j++) { let valuesLength = 0;
values.push.apply(values, expand_(n[j], max, maxLength, false)); outer: for (let j = 0; j < n.length; j++) {
const expanded = expand_(n[j], max, maxLength, false);
for (let k = 0; k < expanded.length; k++) {
const v = expanded[k];
if (dropsEmpties && !v)
continue;
if (values.length >= max || valuesLength + v.length > maxLength) {
break outer;
}
values.push(v);
valuesLength += v.length;
}
} }
} }
acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length); acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length);
+30 -4
View File
@@ -52531,7 +52531,7 @@ function combine(acc, pre, values, max, maxLength, dropEmpties) {
} }
// The expansion values of a single numeric (`1..5`) or alphabetic (`a..e..2`) // The expansion values of a single numeric (`1..5`) or alphabetic (`a..e..2`)
// sequence body. // sequence body.
function expandSequence(body, isAlphaSequence, max) { function expandSequence(body, isAlphaSequence, max, maxLength) {
const n = body.split(/\.\./); const n = body.split(/\.\./);
const N = []; const N = [];
// A sequence body always splits into two or three parts, but the compiler // A sequence body always splits into two or three parts, but the compiler
@@ -52554,6 +52554,7 @@ function expandSequence(body, isAlphaSequence, max) {
test = gte; test = gte;
} }
const pad = n.some(isPadded); const pad = n.some(isPadded);
let length = 0;
for (let i = x; test(i, y) && N.length < max; i += incr) { for (let i = x; test(i, y) && N.length < max; i += incr) {
let c; let c;
if (isAlphaSequence) { if (isAlphaSequence) {
@@ -52577,7 +52578,10 @@ function expandSequence(body, isAlphaSequence, max) {
} }
} }
} }
if (length + c.length > maxLength)
break;
N.push(c); N.push(c);
length += c.length;
} }
return N; return N;
} }
@@ -52631,7 +52635,7 @@ function expand_(str, max, maxLength, isTop) {
} }
let values; let values;
if (isSequence) { if (isSequence) {
values = expandSequence(m.body, isAlphaSequence, max); values = expandSequence(m.body, isAlphaSequence, max, maxLength);
} }
else { else {
let n = parseCommaParts(m.body); let n = parseCommaParts(m.body);
@@ -52649,9 +52653,31 @@ function expand_(str, max, maxLength, isTop) {
} }
/* c8 ignore stop */ /* c8 ignore stop */
} }
// Values that `combine` is going to drop as empty produce no result, so
// they must not count against `max` - otherwise `{a,,b}` with `max: 2`
// would stop at `['a', '']` and yield one result instead of two. Skipping
// them outright keeps `values` bounded while leaving `max` a bound on
// *kept* results.
let dropsEmpties = dropEmpties && !m.post.length && !pre;
for (let d = 0; dropsEmpties && d < acc.length; d++) {
if (acc[d]) {
dropsEmpties = false;
}
}
values = []; values = [];
for (let j = 0; j < n.length; j++) { let valuesLength = 0;
values.push.apply(values, expand_(n[j], max, maxLength, false)); outer: for (let j = 0; j < n.length; j++) {
const expanded = expand_(n[j], max, maxLength, false);
for (let k = 0; k < expanded.length; k++) {
const v = expanded[k];
if (dropsEmpties && !v)
continue;
if (values.length >= max || valuesLength + v.length > maxLength) {
break outer;
}
values.push(v);
valuesLength += v.length;
}
} }
} }
acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length); acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length);
+3 -3
View File
@@ -2635,9 +2635,9 @@
} }
}, },
"node_modules/brace-expansion": { "node_modules/brace-expansion": {
"version": "5.0.8", "version": "5.0.9",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.8.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz",
"integrity": "sha512-JZyDyq3D4AUifKTPOB7DELf6XsB3WdPuNxCtob1vFXPsSXhdAiHBWJ/tJ8HAc9aH84BK+5JFZLNkJKx3G9kzQg==", "integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"balanced-match": "^4.0.2" "balanced-match": "^4.0.2"