mirror of
https://github.com/astral-sh/ruff-action.git
synced 2026-11-10 08:40:38 +00:00
Update brace-expansion dependencies (#432)
Update the locked `brace-expansion` dependencies to `1.1.21`, `2.1.7`, and `5.0.12` in `package-lock.json`. This addresses Dependabot alerts [#73](https://github.com/astral-sh/ruff-action/security/dependabot/73), [#72](https://github.com/astral-sh/ruff-action/security/dependabot/72), and [#71](https://github.com/astral-sh/ruff-action/security/dependabot/71), among other alerts for this dependency.
This commit is contained in:
+154
-86
@@ -28880,6 +28880,9 @@ var closePattern = /\\}/g;
|
||||
var commaPattern = /\\,/g;
|
||||
var periodPattern = /\\\./g;
|
||||
var EXPANSION_MAX = 1e5;
|
||||
var EXPANSION_MAX_LENGTH = 4e6;
|
||||
var EXPANSION_MAX_DEPTH = 1e3;
|
||||
var EXPANSION_MAX_REWRITES = 1e3;
|
||||
function numeric(str) {
|
||||
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
|
||||
}
|
||||
@@ -28889,36 +28892,44 @@ function escapeBraces(str) {
|
||||
function unescapeBraces(str) {
|
||||
return str.replace(escSlashPattern, "\\").replace(escOpenPattern, "{").replace(escClosePattern, "}").replace(escCommaPattern, ",").replace(escPeriodPattern, ".");
|
||||
}
|
||||
function pushAll(target, items) {
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
target.push(items[i]);
|
||||
}
|
||||
}
|
||||
function parseCommaParts(str) {
|
||||
if (!str) {
|
||||
return [""];
|
||||
}
|
||||
const parts = [];
|
||||
const m = balanced("{", "}", str);
|
||||
if (!m) {
|
||||
return str.split(",");
|
||||
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 expand(str, options = {}) {
|
||||
if (!str) {
|
||||
return [];
|
||||
}
|
||||
const { max = EXPANSION_MAX } = options;
|
||||
const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH, maxDepth = EXPANSION_MAX_DEPTH, maxRewrites = EXPANSION_MAX_REWRITES } = options;
|
||||
if (str.slice(0, 2) === "{}") {
|
||||
str = "\\{\\}" + str.slice(2);
|
||||
}
|
||||
return expand_(escapeBraces(str), max, true).map(unescapeBraces);
|
||||
return expand_(escapeBraces(str), max, maxLength, maxDepth, 0, maxRewrites, true).map(unescapeBraces);
|
||||
}
|
||||
function embrace(str) {
|
||||
return "{" + str + "}";
|
||||
@@ -28932,95 +28943,152 @@ function lte2(i, y) {
|
||||
function gte2(i, y) {
|
||||
return i >= y;
|
||||
}
|
||||
function expand_(str, max, isTop) {
|
||||
const expansions = [];
|
||||
const m = balanced("{", "}", str);
|
||||
if (!m)
|
||||
function combine(acc, pre, values, max, maxLength, dropEmpties) {
|
||||
const out = [];
|
||||
let length = 0;
|
||||
for (let a = 0; a < acc.length; a++) {
|
||||
for (let v = 0; v < values.length; v++) {
|
||||
if (out.length >= max)
|
||||
return out;
|
||||
const expansion = acc[a] + pre + values[v];
|
||||
if (dropEmpties && !expansion)
|
||||
continue;
|
||||
if (length + expansion.length > maxLength)
|
||||
return out;
|
||||
out.push(expansion);
|
||||
length += expansion.length;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
function expandSequence(body, isAlphaSequence, max, maxLength) {
|
||||
const n = body.split(/\.\./);
|
||||
const N = [];
|
||||
if (n[0] === void 0 || n[1] === void 0) {
|
||||
return N;
|
||||
}
|
||||
const x = numeric(n[0]);
|
||||
const y = numeric(n[1]);
|
||||
const width = Math.max(n[0].length, n[1].length);
|
||||
let incr = n.length === 3 && n[2] !== void 0 ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
|
||||
let test = lte2;
|
||||
const reverse = y < x;
|
||||
if (reverse) {
|
||||
incr *= -1;
|
||||
test = gte2;
|
||||
}
|
||||
const pad = n.some(isPadded);
|
||||
let length = 0;
|
||||
for (let i = x; test(i, y) && N.length < max; i += incr) {
|
||||
let c;
|
||||
if (isAlphaSequence) {
|
||||
c = String.fromCharCode(i);
|
||||
if (c === "\\") {
|
||||
c = "";
|
||||
}
|
||||
} else {
|
||||
c = String(i);
|
||||
if (pad) {
|
||||
const need = width - c.length;
|
||||
if (need > 0) {
|
||||
const z = new Array(need + 1).join("0");
|
||||
if (i < 0) {
|
||||
c = "-" + z + c.slice(1);
|
||||
} else {
|
||||
c = z + c;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (length + c.length > maxLength)
|
||||
break;
|
||||
N.push(c);
|
||||
length += c.length;
|
||||
}
|
||||
return N;
|
||||
}
|
||||
function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
|
||||
if (depth > maxDepth) {
|
||||
return [str];
|
||||
const pre = m.pre;
|
||||
const post = m.post.length ? expand_(m.post, max, false) : [""];
|
||||
if (/\$$/.test(m.pre)) {
|
||||
for (let k = 0; k < post.length && k < max; k++) {
|
||||
const expansion = pre + "{" + m.body + "}" + post[k];
|
||||
expansions.push(expansion);
|
||||
}
|
||||
let acc = [""];
|
||||
let rewrites = 0;
|
||||
let dropEmpties = false;
|
||||
let firstGroup = true;
|
||||
for (; ; ) {
|
||||
const m = balanced("{", "}", str);
|
||||
if (!m) {
|
||||
return combine(acc, str, [""], max, maxLength, dropEmpties);
|
||||
}
|
||||
const pre = m.pre;
|
||||
if (/\$$/.test(pre)) {
|
||||
acc = combine(acc, pre + "{" + m.body + "}", [""], max, maxLength, dropEmpties && !m.post.length);
|
||||
firstGroup = false;
|
||||
if (!m.post.length)
|
||||
break;
|
||||
str = m.post;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
||||
const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
||||
const isSequence = isNumericSequence || isAlphaSequence;
|
||||
const isOptions = m.body.indexOf(",") >= 0;
|
||||
if (!isSequence && !isOptions) {
|
||||
if (m.post.match(/,(?!,).*\}/)) {
|
||||
if (rewrites < maxRewrites && m.post.match(/,(?!,).*\}/)) {
|
||||
rewrites++;
|
||||
str = m.pre + "{" + m.body + escClose + m.post;
|
||||
return expand_(str, max, true);
|
||||
isTop = true;
|
||||
continue;
|
||||
}
|
||||
return [str];
|
||||
return combine(acc, pre + "{" + m.body + "}" + m.post, [""], max, maxLength, dropEmpties);
|
||||
}
|
||||
let n;
|
||||
if (firstGroup) {
|
||||
dropEmpties = isTop && !isSequence;
|
||||
firstGroup = false;
|
||||
}
|
||||
let values;
|
||||
if (isSequence) {
|
||||
n = m.body.split(/\.\./);
|
||||
values = expandSequence(m.body, isAlphaSequence, max, maxLength);
|
||||
} else {
|
||||
n = parseCommaParts(m.body);
|
||||
let n = parseCommaParts(m.body);
|
||||
if (n.length === 1 && n[0] !== void 0) {
|
||||
n = expand_(n[0], max, false).map(embrace);
|
||||
n = expand_(n[0], max, maxLength, maxDepth, depth + 1, maxRewrites, false).map(embrace);
|
||||
if (n.length === 1) {
|
||||
return post.map((p) => m.pre + n[0] + p);
|
||||
acc = combine(acc, pre + n[0], [""], max, maxLength, dropEmpties && !m.post.length);
|
||||
if (!m.post.length)
|
||||
break;
|
||||
str = m.post;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
let N;
|
||||
if (isSequence && n[0] !== void 0 && n[1] !== void 0) {
|
||||
const x = numeric(n[0]);
|
||||
const y = numeric(n[1]);
|
||||
const width = Math.max(n[0].length, n[1].length);
|
||||
let incr = n.length === 3 && n[2] !== void 0 ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
|
||||
let test = lte2;
|
||||
const reverse = y < x;
|
||||
if (reverse) {
|
||||
incr *= -1;
|
||||
test = gte2;
|
||||
let dropsEmpties = dropEmpties && !m.post.length && !pre;
|
||||
for (let d = 0; dropsEmpties && d < acc.length; d++) {
|
||||
if (acc[d]) {
|
||||
dropsEmpties = false;
|
||||
}
|
||||
}
|
||||
const pad = n.some(isPadded);
|
||||
N = [];
|
||||
for (let i = x; test(i, y); i += incr) {
|
||||
let c;
|
||||
if (isAlphaSequence) {
|
||||
c = String.fromCharCode(i);
|
||||
if (c === "\\") {
|
||||
c = "";
|
||||
values = [];
|
||||
let valuesLength = 0;
|
||||
outer: for (let j = 0; j < n.length; j++) {
|
||||
const expanded = expand_(n[j], max, maxLength, maxDepth, depth + 1, maxRewrites, 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;
|
||||
}
|
||||
} else {
|
||||
c = String(i);
|
||||
if (pad) {
|
||||
const need = width - c.length;
|
||||
if (need > 0) {
|
||||
const z = new Array(need + 1).join("0");
|
||||
if (i < 0) {
|
||||
c = "-" + z + c.slice(1);
|
||||
} else {
|
||||
c = z + c;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
N.push(c);
|
||||
}
|
||||
} else {
|
||||
N = [];
|
||||
for (let j = 0; j < n.length; j++) {
|
||||
N.push.apply(N, expand_(n[j], max, false));
|
||||
}
|
||||
}
|
||||
for (let j = 0; j < N.length; j++) {
|
||||
for (let k = 0; k < post.length && expansions.length < max; k++) {
|
||||
const expansion = pre + N[j] + post[k];
|
||||
if (!isTop || isSequence || expansion) {
|
||||
expansions.push(expansion);
|
||||
values.push(v);
|
||||
valuesLength += v.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length);
|
||||
if (!m.post.length)
|
||||
break;
|
||||
str = m.post;
|
||||
}
|
||||
return expansions;
|
||||
return acc;
|
||||
}
|
||||
|
||||
// node_modules/@actions/glob/node_modules/minimatch/dist/esm/assert-valid-pattern.js
|
||||
|
||||
Reference in New Issue
Block a user