mirror of
https://github.com/actions/setup-dotnet.git
synced 2026-10-23 06:53:05 +01:00
Fix license failures
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: brace-expansion
|
name: brace-expansion
|
||||||
version: 1.1.18
|
version: 1.1.21
|
||||||
type: npm
|
type: npm
|
||||||
summary: Brace expansion as known from sh/bash
|
summary: Brace expansion as known from sh/bash
|
||||||
homepage: https://github.com/juliangruber/brace-expansion
|
homepage: https://github.com/juliangruber/brace-expansion
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: brace-expansion
|
name: brace-expansion
|
||||||
version: 5.0.9
|
version: 5.0.12
|
||||||
type: npm
|
type: npm
|
||||||
summary: Brace expansion as known from sh/bash
|
summary: Brace expansion as known from sh/bash
|
||||||
homepage:
|
homepage:
|
||||||
102
dist/cache-save/index.js
vendored
102
dist/cache-save/index.js
vendored
@@ -7610,6 +7610,26 @@ var EXPANSION_MAX = 100000
|
|||||||
// characters) so legitimate input is unaffected.
|
// characters) so legitimate input is unaffected.
|
||||||
var EXPANSION_MAX_LENGTH = 4000000
|
var EXPANSION_MAX_LENGTH = 4000000
|
||||||
|
|
||||||
|
// `expand` recurses once per level of brace *nesting* - both when expanding a
|
||||||
|
// set's comma members and when re-wrapping a set whose body is a single part.
|
||||||
|
// The CVE-2026-14257 fix made the *tail* iterative (recursion on `m.post`, one
|
||||||
|
// level per chained group), which left nesting depth unbounded: about 3,100
|
||||||
|
// levels of `{{{...a,b...}}}` - only ~6KB of input - exhausted the native stack
|
||||||
|
// and crashed the process. `EXPANSION_MAX_DEPTH` bounds how deep the parser
|
||||||
|
// will follow nesting. It sits far above any realistic pattern and well below
|
||||||
|
// the depth at which the stack runs out.
|
||||||
|
var EXPANSION_MAX_DEPTH = 1000
|
||||||
|
|
||||||
|
// Bash keeps a quirk where a brace group followed by a comma set still expands
|
||||||
|
// (`{a},b}`). The parser implements it by rewriting the string and restarting
|
||||||
|
// the scan, absorbing one `}` per pass. `n` trailing braces therefore cost `n`
|
||||||
|
// full passes over a string that itself grows by one `escClose` sentinel each
|
||||||
|
// time - quadratic in `n`, with a ~26x constant from the sentinel's length.
|
||||||
|
// 128KB of `'{a}' + '}'.repeat(n) + ',z}'` blocked the event loop for 27
|
||||||
|
// seconds to produce two results. `EXPANSION_MAX_REWRITES` bounds how many
|
||||||
|
// times the scan may restart. Real `{a},b}` input needs a handful.
|
||||||
|
var EXPANSION_MAX_REWRITES = 1000
|
||||||
|
|
||||||
function numeric(str) {
|
function numeric(str) {
|
||||||
return parseInt(str, 10) == str
|
return parseInt(str, 10) == str
|
||||||
? parseInt(str, 10)
|
? parseInt(str, 10)
|
||||||
@@ -7633,34 +7653,54 @@ function unescapeBraces(str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Like `target.push(...items)` but doesn't overflow the stack
|
||||||
|
function pushAll(target, items) {
|
||||||
|
for (var i = 0; i < items.length; i++) {
|
||||||
|
target.push(items[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Basically just str.split(","), but handling cases
|
// Basically just str.split(","), but handling cases
|
||||||
// where we have nested braced sections, which should be
|
// where we have nested braced sections, which should be
|
||||||
// treated as individual members, like {a,{b,c},d}
|
// treated as individual members, like {a,{b,c},d}
|
||||||
function parseCommaParts(str) {
|
function parseCommaParts(str) {
|
||||||
if (!str)
|
|
||||||
return [''];
|
|
||||||
|
|
||||||
var parts = [];
|
var parts = [];
|
||||||
var m = balanced('{', '}', str);
|
|
||||||
|
|
||||||
if (!m)
|
// Walk the brace groups iteratively. Recursing on `post` once per group let a
|
||||||
return str.split(',');
|
// chain of them exhaust the stack - the parsing-side counterpart to
|
||||||
|
// the `expand` overflow fixed for CVE-2026-14257, and not something `max` or
|
||||||
|
// `maxLength` can bound, since it happens before expansion.
|
||||||
|
//
|
||||||
|
// The part the next chunk continues
|
||||||
|
var carry = '';
|
||||||
|
|
||||||
var pre = m.pre;
|
for (;;) {
|
||||||
var body = m.body;
|
var m = balanced('{', '}', str);
|
||||||
var post = m.post;
|
|
||||||
var p = pre.split(',');
|
|
||||||
|
|
||||||
p[p.length-1] += '{' + body + '}';
|
if (!m) {
|
||||||
var postParts = parseCommaParts(post);
|
var tail = str.split(',');
|
||||||
if (post.length) {
|
tail[0] = carry + tail[0];
|
||||||
p[p.length-1] += postParts.shift();
|
pushAll(parts, tail);
|
||||||
p.push.apply(p, postParts);
|
return parts;
|
||||||
|
}
|
||||||
|
|
||||||
|
var pre = m.pre;
|
||||||
|
var body = m.body;
|
||||||
|
var post = m.post;
|
||||||
|
var p = pre.split(',');
|
||||||
|
|
||||||
|
p[0] = carry + p[0];
|
||||||
|
p[p.length-1] += '{' + body + '}';
|
||||||
|
|
||||||
|
if (!post.length) {
|
||||||
|
pushAll(parts, p);
|
||||||
|
return parts;
|
||||||
|
}
|
||||||
|
|
||||||
|
carry = p.pop();
|
||||||
|
pushAll(parts, p);
|
||||||
|
str = post;
|
||||||
}
|
}
|
||||||
|
|
||||||
parts.push.apply(parts, p);
|
|
||||||
|
|
||||||
return parts;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function expandTop(str, options) {
|
function expandTop(str, options) {
|
||||||
@@ -7670,6 +7710,8 @@ function expandTop(str, options) {
|
|||||||
options = options || {};
|
options = options || {};
|
||||||
var max = options.max == null ? EXPANSION_MAX : options.max;
|
var max = options.max == null ? EXPANSION_MAX : options.max;
|
||||||
var maxLength = options.maxLength == null ? EXPANSION_MAX_LENGTH : options.maxLength;
|
var maxLength = options.maxLength == null ? EXPANSION_MAX_LENGTH : options.maxLength;
|
||||||
|
var maxDepth = options.maxDepth == null ? EXPANSION_MAX_DEPTH : options.maxDepth;
|
||||||
|
var maxRewrites = options.maxRewrites == null ? EXPANSION_MAX_REWRITES : options.maxRewrites;
|
||||||
|
|
||||||
// I don't know why Bash 4.3 does this, but it does.
|
// I don't know why Bash 4.3 does this, but it does.
|
||||||
// Anything starting with {} will have the first two bytes preserved
|
// Anything starting with {} will have the first two bytes preserved
|
||||||
@@ -7681,7 +7723,7 @@ function expandTop(str, options) {
|
|||||||
str = '\\{\\}' + str.substr(2);
|
str = '\\{\\}' + str.substr(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return expand(escapeBraces(str), max, maxLength, true).map(unescapeBraces);
|
return expand(escapeBraces(str), max, maxLength, maxDepth, 0, maxRewrites, true).map(unescapeBraces);
|
||||||
}
|
}
|
||||||
|
|
||||||
function identity(e) {
|
function identity(e) {
|
||||||
@@ -7805,8 +7847,18 @@ function expand(
|
|||||||
str,
|
str,
|
||||||
max,
|
max,
|
||||||
maxLength,
|
maxLength,
|
||||||
|
maxDepth,
|
||||||
|
depth,
|
||||||
|
maxRewrites,
|
||||||
isTop
|
isTop
|
||||||
) {
|
) {
|
||||||
|
// Too deeply nested to keep following: treat the rest as literal, the same
|
||||||
|
// way a group that cannot expand is already handled. Truncating rather than
|
||||||
|
// throwing keeps expansion total, matching `max` and `maxLength`.
|
||||||
|
if (depth > maxDepth) {
|
||||||
|
return [str];
|
||||||
|
}
|
||||||
|
|
||||||
// Consume the string's top-level brace groups left to right, threading a
|
// Consume the string's top-level brace groups left to right, threading a
|
||||||
// running set of combined prefixes (`acc`). Expanding the tail iteratively -
|
// running set of combined prefixes (`acc`). Expanding the tail iteratively -
|
||||||
// rather than recursing on `m.post` once per group - keeps the native stack
|
// rather than recursing on `m.post` once per group - keeps the native stack
|
||||||
@@ -7827,6 +7879,9 @@ function expand(
|
|||||||
// `accBase[a]` records how much of `acc[a]` predates the current run;
|
// `accBase[a]` records how much of `acc[a]` predates the current run;
|
||||||
// `combine` treats an expansion as empty when it adds nothing past that.
|
// `combine` treats an expansion as empty when it adds nothing past that.
|
||||||
var accBase = [0]
|
var accBase = [0]
|
||||||
|
// How many times the `{a},b}` rewrite below has restarted the scan. Each pass
|
||||||
|
// re-reads the whole string, so leaving this unbounded is quadratic.
|
||||||
|
var rewrites = 0
|
||||||
var dropEmpties = false
|
var dropEmpties = false
|
||||||
var firstGroup = true
|
var firstGroup = true
|
||||||
var nextBase
|
var nextBase
|
||||||
@@ -7858,7 +7913,8 @@ function expand(
|
|||||||
var isOptions = m.body.indexOf(',') >= 0;
|
var isOptions = m.body.indexOf(',') >= 0;
|
||||||
if (!isSequence && !isOptions) {
|
if (!isSequence && !isOptions) {
|
||||||
// {a},b}
|
// {a},b}
|
||||||
if (m.post.match(/,(?!,).*\}/)) {
|
if (rewrites < maxRewrites && m.post.match(/,(?!,).*\}/)) {
|
||||||
|
rewrites++;
|
||||||
str = m.pre + '{' + m.body + escClose + m.post;
|
str = m.pre + '{' + m.body + escClose + m.post;
|
||||||
// The rewritten string is expanded as if it were a fresh top-level one,
|
// The rewritten string is expanded as if it were a fresh top-level one,
|
||||||
// so start a new empty-drop run: anchor the baseline at what `acc`
|
// so start a new empty-drop run: anchor the baseline at what `acc`
|
||||||
@@ -7897,7 +7953,7 @@ function expand(
|
|||||||
var n = parseCommaParts(m.body);
|
var n = parseCommaParts(m.body);
|
||||||
if (n.length === 1 && n[0] !== undefined) {
|
if (n.length === 1 && n[0] !== undefined) {
|
||||||
// x{{a,b}}y ==> x{a}y x{b}y
|
// x{{a,b}}y ==> x{a}y x{b}y
|
||||||
n = expand(n[0], max, maxLength, false).map(embrace);
|
n = expand(n[0], max, maxLength, maxDepth, depth + 1, maxRewrites, false).map(embrace);
|
||||||
//XXX is this necessary? Can't seem to hit it in tests.
|
//XXX is this necessary? Can't seem to hit it in tests.
|
||||||
/* c8 ignore start */
|
/* c8 ignore start */
|
||||||
if (n.length === 1) {
|
if (n.length === 1) {
|
||||||
@@ -7936,7 +7992,7 @@ function expand(
|
|||||||
values = []
|
values = []
|
||||||
var valuesLength = 0
|
var valuesLength = 0
|
||||||
outer: for (var j = 0; j < n.length; j++) {
|
outer: for (var j = 0; j < n.length; j++) {
|
||||||
var expanded = expand(n[j], max, maxLength, false)
|
var expanded = expand(n[j], max, maxLength, maxDepth, depth + 1, maxRewrites, false)
|
||||||
for (var k = 0; k < expanded.length; k++) {
|
for (var k = 0; k < expanded.length; k++) {
|
||||||
var v = expanded[k]
|
var v = expanded[k]
|
||||||
if (dropsEmpties && !v) continue
|
if (dropsEmpties && !v) continue
|
||||||
|
|||||||
194
dist/setup/index.js
vendored
194
dist/setup/index.js
vendored
@@ -9911,6 +9911,26 @@ var EXPANSION_MAX = 100000
|
|||||||
// characters) so legitimate input is unaffected.
|
// characters) so legitimate input is unaffected.
|
||||||
var EXPANSION_MAX_LENGTH = 4000000
|
var EXPANSION_MAX_LENGTH = 4000000
|
||||||
|
|
||||||
|
// `expand` recurses once per level of brace *nesting* - both when expanding a
|
||||||
|
// set's comma members and when re-wrapping a set whose body is a single part.
|
||||||
|
// The CVE-2026-14257 fix made the *tail* iterative (recursion on `m.post`, one
|
||||||
|
// level per chained group), which left nesting depth unbounded: about 3,100
|
||||||
|
// levels of `{{{...a,b...}}}` - only ~6KB of input - exhausted the native stack
|
||||||
|
// and crashed the process. `EXPANSION_MAX_DEPTH` bounds how deep the parser
|
||||||
|
// will follow nesting. It sits far above any realistic pattern and well below
|
||||||
|
// the depth at which the stack runs out.
|
||||||
|
var EXPANSION_MAX_DEPTH = 1000
|
||||||
|
|
||||||
|
// Bash keeps a quirk where a brace group followed by a comma set still expands
|
||||||
|
// (`{a},b}`). The parser implements it by rewriting the string and restarting
|
||||||
|
// the scan, absorbing one `}` per pass. `n` trailing braces therefore cost `n`
|
||||||
|
// full passes over a string that itself grows by one `escClose` sentinel each
|
||||||
|
// time - quadratic in `n`, with a ~26x constant from the sentinel's length.
|
||||||
|
// 128KB of `'{a}' + '}'.repeat(n) + ',z}'` blocked the event loop for 27
|
||||||
|
// seconds to produce two results. `EXPANSION_MAX_REWRITES` bounds how many
|
||||||
|
// times the scan may restart. Real `{a},b}` input needs a handful.
|
||||||
|
var EXPANSION_MAX_REWRITES = 1000
|
||||||
|
|
||||||
function numeric(str) {
|
function numeric(str) {
|
||||||
return parseInt(str, 10) == str
|
return parseInt(str, 10) == str
|
||||||
? parseInt(str, 10)
|
? parseInt(str, 10)
|
||||||
@@ -9934,34 +9954,54 @@ function unescapeBraces(str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Like `target.push(...items)` but doesn't overflow the stack
|
||||||
|
function pushAll(target, items) {
|
||||||
|
for (var i = 0; i < items.length; i++) {
|
||||||
|
target.push(items[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Basically just str.split(","), but handling cases
|
// Basically just str.split(","), but handling cases
|
||||||
// where we have nested braced sections, which should be
|
// where we have nested braced sections, which should be
|
||||||
// treated as individual members, like {a,{b,c},d}
|
// treated as individual members, like {a,{b,c},d}
|
||||||
function parseCommaParts(str) {
|
function parseCommaParts(str) {
|
||||||
if (!str)
|
|
||||||
return [''];
|
|
||||||
|
|
||||||
var parts = [];
|
var parts = [];
|
||||||
var m = balanced('{', '}', str);
|
|
||||||
|
|
||||||
if (!m)
|
// Walk the brace groups iteratively. Recursing on `post` once per group let a
|
||||||
return str.split(',');
|
// chain of them exhaust the stack - the parsing-side counterpart to
|
||||||
|
// the `expand` overflow fixed for CVE-2026-14257, and not something `max` or
|
||||||
|
// `maxLength` can bound, since it happens before expansion.
|
||||||
|
//
|
||||||
|
// The part the next chunk continues
|
||||||
|
var carry = '';
|
||||||
|
|
||||||
var pre = m.pre;
|
for (;;) {
|
||||||
var body = m.body;
|
var m = balanced('{', '}', str);
|
||||||
var post = m.post;
|
|
||||||
var p = pre.split(',');
|
|
||||||
|
|
||||||
p[p.length-1] += '{' + body + '}';
|
if (!m) {
|
||||||
var postParts = parseCommaParts(post);
|
var tail = str.split(',');
|
||||||
if (post.length) {
|
tail[0] = carry + tail[0];
|
||||||
p[p.length-1] += postParts.shift();
|
pushAll(parts, tail);
|
||||||
p.push.apply(p, postParts);
|
return parts;
|
||||||
|
}
|
||||||
|
|
||||||
|
var pre = m.pre;
|
||||||
|
var body = m.body;
|
||||||
|
var post = m.post;
|
||||||
|
var p = pre.split(',');
|
||||||
|
|
||||||
|
p[0] = carry + p[0];
|
||||||
|
p[p.length-1] += '{' + body + '}';
|
||||||
|
|
||||||
|
if (!post.length) {
|
||||||
|
pushAll(parts, p);
|
||||||
|
return parts;
|
||||||
|
}
|
||||||
|
|
||||||
|
carry = p.pop();
|
||||||
|
pushAll(parts, p);
|
||||||
|
str = post;
|
||||||
}
|
}
|
||||||
|
|
||||||
parts.push.apply(parts, p);
|
|
||||||
|
|
||||||
return parts;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function expandTop(str, options) {
|
function expandTop(str, options) {
|
||||||
@@ -9971,6 +10011,8 @@ function expandTop(str, options) {
|
|||||||
options = options || {};
|
options = options || {};
|
||||||
var max = options.max == null ? EXPANSION_MAX : options.max;
|
var max = options.max == null ? EXPANSION_MAX : options.max;
|
||||||
var maxLength = options.maxLength == null ? EXPANSION_MAX_LENGTH : options.maxLength;
|
var maxLength = options.maxLength == null ? EXPANSION_MAX_LENGTH : options.maxLength;
|
||||||
|
var maxDepth = options.maxDepth == null ? EXPANSION_MAX_DEPTH : options.maxDepth;
|
||||||
|
var maxRewrites = options.maxRewrites == null ? EXPANSION_MAX_REWRITES : options.maxRewrites;
|
||||||
|
|
||||||
// I don't know why Bash 4.3 does this, but it does.
|
// I don't know why Bash 4.3 does this, but it does.
|
||||||
// Anything starting with {} will have the first two bytes preserved
|
// Anything starting with {} will have the first two bytes preserved
|
||||||
@@ -9982,7 +10024,7 @@ function expandTop(str, options) {
|
|||||||
str = '\\{\\}' + str.substr(2);
|
str = '\\{\\}' + str.substr(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return expand(escapeBraces(str), max, maxLength, true).map(unescapeBraces);
|
return expand(escapeBraces(str), max, maxLength, maxDepth, 0, maxRewrites, true).map(unescapeBraces);
|
||||||
}
|
}
|
||||||
|
|
||||||
function identity(e) {
|
function identity(e) {
|
||||||
@@ -10106,8 +10148,18 @@ function expand(
|
|||||||
str,
|
str,
|
||||||
max,
|
max,
|
||||||
maxLength,
|
maxLength,
|
||||||
|
maxDepth,
|
||||||
|
depth,
|
||||||
|
maxRewrites,
|
||||||
isTop
|
isTop
|
||||||
) {
|
) {
|
||||||
|
// Too deeply nested to keep following: treat the rest as literal, the same
|
||||||
|
// way a group that cannot expand is already handled. Truncating rather than
|
||||||
|
// throwing keeps expansion total, matching `max` and `maxLength`.
|
||||||
|
if (depth > maxDepth) {
|
||||||
|
return [str];
|
||||||
|
}
|
||||||
|
|
||||||
// Consume the string's top-level brace groups left to right, threading a
|
// Consume the string's top-level brace groups left to right, threading a
|
||||||
// running set of combined prefixes (`acc`). Expanding the tail iteratively -
|
// running set of combined prefixes (`acc`). Expanding the tail iteratively -
|
||||||
// rather than recursing on `m.post` once per group - keeps the native stack
|
// rather than recursing on `m.post` once per group - keeps the native stack
|
||||||
@@ -10128,6 +10180,9 @@ function expand(
|
|||||||
// `accBase[a]` records how much of `acc[a]` predates the current run;
|
// `accBase[a]` records how much of `acc[a]` predates the current run;
|
||||||
// `combine` treats an expansion as empty when it adds nothing past that.
|
// `combine` treats an expansion as empty when it adds nothing past that.
|
||||||
var accBase = [0]
|
var accBase = [0]
|
||||||
|
// How many times the `{a},b}` rewrite below has restarted the scan. Each pass
|
||||||
|
// re-reads the whole string, so leaving this unbounded is quadratic.
|
||||||
|
var rewrites = 0
|
||||||
var dropEmpties = false
|
var dropEmpties = false
|
||||||
var firstGroup = true
|
var firstGroup = true
|
||||||
var nextBase
|
var nextBase
|
||||||
@@ -10159,7 +10214,8 @@ function expand(
|
|||||||
var isOptions = m.body.indexOf(',') >= 0;
|
var isOptions = m.body.indexOf(',') >= 0;
|
||||||
if (!isSequence && !isOptions) {
|
if (!isSequence && !isOptions) {
|
||||||
// {a},b}
|
// {a},b}
|
||||||
if (m.post.match(/,(?!,).*\}/)) {
|
if (rewrites < maxRewrites && m.post.match(/,(?!,).*\}/)) {
|
||||||
|
rewrites++;
|
||||||
str = m.pre + '{' + m.body + escClose + m.post;
|
str = m.pre + '{' + m.body + escClose + m.post;
|
||||||
// The rewritten string is expanded as if it were a fresh top-level one,
|
// The rewritten string is expanded as if it were a fresh top-level one,
|
||||||
// so start a new empty-drop run: anchor the baseline at what `acc`
|
// so start a new empty-drop run: anchor the baseline at what `acc`
|
||||||
@@ -10198,7 +10254,7 @@ function expand(
|
|||||||
var n = parseCommaParts(m.body);
|
var n = parseCommaParts(m.body);
|
||||||
if (n.length === 1 && n[0] !== undefined) {
|
if (n.length === 1 && n[0] !== undefined) {
|
||||||
// x{{a,b}}y ==> x{a}y x{b}y
|
// x{{a,b}}y ==> x{a}y x{b}y
|
||||||
n = expand(n[0], max, maxLength, false).map(embrace);
|
n = expand(n[0], max, maxLength, maxDepth, depth + 1, maxRewrites, false).map(embrace);
|
||||||
//XXX is this necessary? Can't seem to hit it in tests.
|
//XXX is this necessary? Can't seem to hit it in tests.
|
||||||
/* c8 ignore start */
|
/* c8 ignore start */
|
||||||
if (n.length === 1) {
|
if (n.length === 1) {
|
||||||
@@ -10237,7 +10293,7 @@ function expand(
|
|||||||
values = []
|
values = []
|
||||||
var valuesLength = 0
|
var valuesLength = 0
|
||||||
outer: for (var j = 0; j < n.length; j++) {
|
outer: for (var j = 0; j < n.length; j++) {
|
||||||
var expanded = expand(n[j], max, maxLength, false)
|
var expanded = expand(n[j], max, maxLength, maxDepth, depth + 1, maxRewrites, false)
|
||||||
for (var k = 0; k < expanded.length; k++) {
|
for (var k = 0; k < expanded.length; k++) {
|
||||||
var v = expanded[k]
|
var v = expanded[k]
|
||||||
if (dropsEmpties && !v) continue
|
if (dropsEmpties && !v) continue
|
||||||
@@ -103630,6 +103686,24 @@ const EXPANSION_MAX = 100_000;
|
|||||||
// realistic expansion (100k results hitting `EXPANSION_MAX` measure ~1M
|
// realistic expansion (100k results hitting `EXPANSION_MAX` measure ~1M
|
||||||
// characters) so legitimate input is unaffected.
|
// characters) so legitimate input is unaffected.
|
||||||
const EXPANSION_MAX_LENGTH = 4_000_000;
|
const EXPANSION_MAX_LENGTH = 4_000_000;
|
||||||
|
// `expand_` recurses once per level of brace *nesting* - both when expanding a
|
||||||
|
// set's comma members and when re-wrapping a set whose body is a single part.
|
||||||
|
// The CVE-2026-14257 fix made the *tail* iterative (recursion on `m.post`, one
|
||||||
|
// level per chained group), which left nesting depth unbounded: about 3,100
|
||||||
|
// levels of `{{{...a,b...}}}` - only ~6KB of input - exhausted the native stack
|
||||||
|
// and crashed the process. `EXPANSION_MAX_DEPTH` bounds how deep the parser
|
||||||
|
// will follow nesting. It sits far above any realistic pattern and well below
|
||||||
|
// the depth at which the stack runs out.
|
||||||
|
const EXPANSION_MAX_DEPTH = 1_000;
|
||||||
|
// Bash keeps a quirk where a brace group followed by a comma set still expands
|
||||||
|
// (`{a},b}`). The parser implements it by rewriting the string and restarting
|
||||||
|
// the scan, absorbing one `}` per pass. `n` trailing braces therefore cost `n`
|
||||||
|
// full passes over a string that itself grows by one `escClose` sentinel each
|
||||||
|
// time - quadratic in `n`, with a ~26x constant from the sentinel's length.
|
||||||
|
// 128KB of `'{a}' + '}'.repeat(n) + ',z}'` blocked the event loop for 27
|
||||||
|
// seconds to produce two results. `EXPANSION_MAX_REWRITES` bounds how many
|
||||||
|
// times the scan may restart. Real `{a},b}` input needs a handful.
|
||||||
|
const EXPANSION_MAX_REWRITES = 1_000;
|
||||||
function numeric(str) {
|
function numeric(str) {
|
||||||
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
|
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
|
||||||
}
|
}
|
||||||
@@ -103649,37 +103723,52 @@ function unescapeBraces(str) {
|
|||||||
.replace(escCommaPattern, ',')
|
.replace(escCommaPattern, ',')
|
||||||
.replace(escPeriodPattern, '.');
|
.replace(escPeriodPattern, '.');
|
||||||
}
|
}
|
||||||
|
// Like `target.push(...items)` but doesn't overflow the stack
|
||||||
|
function pushAll(target, items) {
|
||||||
|
for (let i = 0; i < items.length; i++) {
|
||||||
|
target.push(items[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Basically just str.split(","), but handling cases
|
* Basically just str.split(","), but handling cases
|
||||||
* where we have nested braced sections, which should be
|
* where we have nested braced sections, which should be
|
||||||
* treated as individual members, like {a,{b,c},d}
|
* treated as individual members, like {a,{b,c},d}
|
||||||
*/
|
*/
|
||||||
function parseCommaParts(str) {
|
function parseCommaParts(str) {
|
||||||
if (!str) {
|
|
||||||
return [''];
|
|
||||||
}
|
|
||||||
const parts = [];
|
const parts = [];
|
||||||
const m = balanced('{', '}', str);
|
// Walk the brace groups iteratively. Recursing on `post` once per group let a
|
||||||
if (!m) {
|
// chain of them exhaust the stack - the parsing-side counterpart to
|
||||||
return str.split(',');
|
// the `expand_` overflow fixed for CVE-2026-14257, and not something `max` or
|
||||||
|
// `maxLength` can bound, since it happens before expansion.
|
||||||
|
//
|
||||||
|
// The part the next chunk continues
|
||||||
|
let carry = '';
|
||||||
|
for (;;) {
|
||||||
|
const m = balanced('{', '}', str);
|
||||||
|
if (!m) {
|
||||||
|
const tail = str.split(',');
|
||||||
|
tail[0] = carry + tail[0];
|
||||||
|
pushAll(parts, tail);
|
||||||
|
return parts;
|
||||||
|
}
|
||||||
|
const { pre, body, post } = m;
|
||||||
|
const p = pre.split(',');
|
||||||
|
p[0] = carry + p[0];
|
||||||
|
p[p.length - 1] += '{' + body + '}';
|
||||||
|
if (!post.length) {
|
||||||
|
pushAll(parts, p);
|
||||||
|
return parts;
|
||||||
|
}
|
||||||
|
carry = p.pop();
|
||||||
|
pushAll(parts, p);
|
||||||
|
str = post;
|
||||||
}
|
}
|
||||||
const { pre, body, post } = m;
|
|
||||||
const p = pre.split(',');
|
|
||||||
p[p.length - 1] += '{' + body + '}';
|
|
||||||
const postParts = parseCommaParts(post);
|
|
||||||
if (post.length) {
|
|
||||||
;
|
|
||||||
p[p.length - 1] += postParts.shift();
|
|
||||||
p.push.apply(p, postParts);
|
|
||||||
}
|
|
||||||
parts.push.apply(parts, p);
|
|
||||||
return parts;
|
|
||||||
}
|
}
|
||||||
function esm_expand(str, options = {}) {
|
function esm_expand(str, options = {}) {
|
||||||
if (!str) {
|
if (!str) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH } = options;
|
const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH, maxDepth = EXPANSION_MAX_DEPTH, maxRewrites = EXPANSION_MAX_REWRITES, } = options;
|
||||||
// I don't know why Bash 4.3 does this, but it does.
|
// I don't know why Bash 4.3 does this, but it does.
|
||||||
// Anything starting with {} will have the first two bytes preserved
|
// Anything starting with {} will have the first two bytes preserved
|
||||||
// but *only* at the top level, so {},a}b will not expand to anything,
|
// but *only* at the top level, so {},a}b will not expand to anything,
|
||||||
@@ -103689,7 +103778,7 @@ function esm_expand(str, options = {}) {
|
|||||||
if (str.slice(0, 2) === '{}') {
|
if (str.slice(0, 2) === '{}') {
|
||||||
str = '\\{\\}' + str.slice(2);
|
str = '\\{\\}' + str.slice(2);
|
||||||
}
|
}
|
||||||
return expand_(escapeBraces(str), max, maxLength, true).map(unescapeBraces);
|
return expand_(escapeBraces(str), max, maxLength, maxDepth, 0, maxRewrites, true).map(unescapeBraces);
|
||||||
}
|
}
|
||||||
function embrace(str) {
|
function embrace(str) {
|
||||||
return '{' + str + '}';
|
return '{' + str + '}';
|
||||||
@@ -103784,7 +103873,13 @@ function expandSequence(body, isAlphaSequence, max, maxLength) {
|
|||||||
}
|
}
|
||||||
return N;
|
return N;
|
||||||
}
|
}
|
||||||
function expand_(str, max, maxLength, isTop) {
|
function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
|
||||||
|
// Too deeply nested to keep following: treat the rest as literal, the same
|
||||||
|
// way a group that cannot expand is already handled. Truncating rather than
|
||||||
|
// throwing keeps `expand` total, matching `max` and `maxLength`.
|
||||||
|
if (depth > maxDepth) {
|
||||||
|
return [str];
|
||||||
|
}
|
||||||
// Consume the string's top-level brace groups left to right, threading a
|
// Consume the string's top-level brace groups left to right, threading a
|
||||||
// running set of combined prefixes (`acc`). Expanding the tail iteratively -
|
// running set of combined prefixes (`acc`). Expanding the tail iteratively -
|
||||||
// rather than recursing on `m.post` once per group - keeps the native stack
|
// rather than recursing on `m.post` once per group - keeps the native stack
|
||||||
@@ -103796,6 +103891,9 @@ function expand_(str, max, maxLength, isTop) {
|
|||||||
// comma set - a sequence like `{a..\}` may legitimately yield ''. The drop
|
// comma set - a sequence like `{a..\}` may legitimately yield ''. The drop
|
||||||
// is on the final strings, so it is applied to whichever `combine` produces
|
// is on the final strings, so it is applied to whichever `combine` produces
|
||||||
// them (the one with no brace set left in the tail).
|
// them (the one with no brace set left in the tail).
|
||||||
|
// How many times the `{a},b}` rewrite below has restarted the scan. Each pass
|
||||||
|
// re-reads the whole string, so leaving this unbounded is quadratic.
|
||||||
|
let rewrites = 0;
|
||||||
let dropEmpties = false;
|
let dropEmpties = false;
|
||||||
let firstGroup = true;
|
let firstGroup = true;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -103820,7 +103918,8 @@ function expand_(str, max, maxLength, isTop) {
|
|||||||
const isOptions = m.body.indexOf(',') >= 0;
|
const isOptions = m.body.indexOf(',') >= 0;
|
||||||
if (!isSequence && !isOptions) {
|
if (!isSequence && !isOptions) {
|
||||||
// {a},b}
|
// {a},b}
|
||||||
if (m.post.match(/,(?!,).*\}/)) {
|
if (rewrites < maxRewrites && m.post.match(/,(?!,).*\}/)) {
|
||||||
|
rewrites++;
|
||||||
str = m.pre + '{' + m.body + escClose + m.post;
|
str = m.pre + '{' + m.body + escClose + m.post;
|
||||||
isTop = true;
|
isTop = true;
|
||||||
continue;
|
continue;
|
||||||
@@ -103840,7 +103939,7 @@ function expand_(str, max, maxLength, isTop) {
|
|||||||
let n = parseCommaParts(m.body);
|
let n = parseCommaParts(m.body);
|
||||||
if (n.length === 1 && n[0] !== undefined) {
|
if (n.length === 1 && n[0] !== undefined) {
|
||||||
// x{{a,b}}y ==> x{a}y x{b}y
|
// x{{a,b}}y ==> x{a}y x{b}y
|
||||||
n = expand_(n[0], max, maxLength, false).map(embrace);
|
n = expand_(n[0], max, maxLength, maxDepth, depth + 1, maxRewrites, false).map(embrace);
|
||||||
//XXX is this necessary? Can't seem to hit it in tests.
|
//XXX is this necessary? Can't seem to hit it in tests.
|
||||||
/* c8 ignore start */
|
/* c8 ignore start */
|
||||||
if (n.length === 1) {
|
if (n.length === 1) {
|
||||||
@@ -103866,12 +103965,13 @@ function expand_(str, max, maxLength, isTop) {
|
|||||||
values = [];
|
values = [];
|
||||||
let valuesLength = 0;
|
let valuesLength = 0;
|
||||||
outer: for (let j = 0; j < n.length; j++) {
|
outer: for (let j = 0; j < n.length; j++) {
|
||||||
const expanded = expand_(n[j], max, maxLength, false);
|
const expanded = expand_(n[j], max, maxLength, maxDepth, depth + 1, maxRewrites, false);
|
||||||
for (let k = 0; k < expanded.length; k++) {
|
for (let k = 0; k < expanded.length; k++) {
|
||||||
const v = expanded[k];
|
const v = expanded[k];
|
||||||
if (dropsEmpties && !v)
|
if (dropsEmpties && !v)
|
||||||
continue;
|
continue;
|
||||||
if (values.length >= max || valuesLength + v.length > maxLength) {
|
if (values.length >= max ||
|
||||||
|
valuesLength + v.length > maxLength) {
|
||||||
break outer;
|
break outer;
|
||||||
}
|
}
|
||||||
values.push(v);
|
values.push(v);
|
||||||
|
|||||||
Reference in New Issue
Block a user