Files
DataStack/patches/cloudcmd-minimatch-security.patch
T

152 lines
7.6 KiB
Diff
Raw Normal View History

diff --git a/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js b/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js
--- a/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js
+++ b/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js
@@ -445,13 +445,17 @@
//
// **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
// this WOULD be allowed if ** did follow symlinks, or * didn't
- firstPhasePreProcess(globParts) {
- let didSomething = false;
+ firstPhasePreProcess(globParts) {
+ const { braceExpandMax = 100000 } = this.options;
+ let didSomething = false;
do {
didSomething = false;
// <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
- for (let parts of globParts) {
- let gs = -1;
+ for (let parts of globParts) {
+ // Upstream GHSA-g3hv-75wg-m249: bound iterative globparts expansion.
+ if (globParts.length >= braceExpandMax)
+ return globParts;
+ let gs = -1;
while (-1 !== (gs = parts.indexOf('**', gs + 1))) {
let gss = gs;
while (parts[gss + 1] === '**') {
@@ -529,8 +533,10 @@
//
// {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
// ^-- not valid because ** doens't follow symlinks
- secondPhasePreProcess(globParts) {
- for (let i = 0; i < globParts.length - 1; i++) {
+ secondPhasePreProcess(globParts) {
+ if (globParts.length > 1000)
+ return globParts;
+ for (let i = 0; i < globParts.length - 1; i++) {
for (let j = i + 1; j < globParts.length; j++) {
const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
if (matched) {
diff --git a/node_modules/glob/node_modules/minimatch/dist/esm/index.js b/node_modules/glob/node_modules/minimatch/dist/esm/index.js
--- a/node_modules/glob/node_modules/minimatch/dist/esm/index.js
+++ b/node_modules/glob/node_modules/minimatch/dist/esm/index.js
@@ -433,13 +433,17 @@
//
// **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
// this WOULD be allowed if ** did follow symlinks, or * didn't
- firstPhasePreProcess(globParts) {
- let didSomething = false;
+ firstPhasePreProcess(globParts) {
+ const { braceExpandMax = 100000 } = this.options;
+ let didSomething = false;
do {
didSomething = false;
// <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
- for (let parts of globParts) {
- let gs = -1;
+ for (let parts of globParts) {
+ // Upstream GHSA-g3hv-75wg-m249: bound iterative globparts expansion.
+ if (globParts.length >= braceExpandMax)
+ return globParts;
+ let gs = -1;
while (-1 !== (gs = parts.indexOf('**', gs + 1))) {
let gss = gs;
while (parts[gss + 1] === '**') {
@@ -517,8 +521,10 @@
//
// {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
// ^-- not valid because ** doens't follow symlinks
- secondPhasePreProcess(globParts) {
- for (let i = 0; i < globParts.length - 1; i++) {
+ secondPhasePreProcess(globParts) {
+ if (globParts.length > 1000)
+ return globParts;
+ for (let i = 0; i < globParts.length - 1; i++) {
for (let j = i + 1; j < globParts.length; j++) {
const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
if (matched) {
diff --git a/node_modules/onezip/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js b/node_modules/onezip/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js
--- a/node_modules/onezip/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js
+++ b/node_modules/onezip/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js
@@ -452,13 +452,17 @@
//
// **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
// this WOULD be allowed if ** did follow symlinks, or * didn't
- firstPhasePreProcess(globParts) {
- let didSomething = false;
+ firstPhasePreProcess(globParts) {
+ const { braceExpandMax = 100000 } = this.options;
+ let didSomething = false;
do {
didSomething = false;
// <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
- for (let parts of globParts) {
- let gs = -1;
+ for (let parts of globParts) {
+ // Upstream GHSA-g3hv-75wg-m249: bound iterative globparts expansion.
+ if (globParts.length >= braceExpandMax)
+ return globParts;
+ let gs = -1;
while (-1 !== (gs = parts.indexOf('**', gs + 1))) {
let gss = gs;
while (parts[gss + 1] === '**') {
@@ -536,8 +540,10 @@
//
// {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
// ^-- not valid because ** doens't follow symlinks
- secondPhasePreProcess(globParts) {
- for (let i = 0; i < globParts.length - 1; i++) {
+ secondPhasePreProcess(globParts) {
+ if (globParts.length > 1000)
+ return globParts;
+ for (let i = 0; i < globParts.length - 1; i++) {
for (let j = i + 1; j < globParts.length; j++) {
const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
if (matched) {
diff --git a/node_modules/onezip/node_modules/glob/node_modules/minimatch/dist/esm/index.js b/node_modules/onezip/node_modules/glob/node_modules/minimatch/dist/esm/index.js
--- a/node_modules/onezip/node_modules/glob/node_modules/minimatch/dist/esm/index.js
+++ b/node_modules/onezip/node_modules/glob/node_modules/minimatch/dist/esm/index.js
@@ -443,13 +443,17 @@
//
// **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
// this WOULD be allowed if ** did follow symlinks, or * didn't
- firstPhasePreProcess(globParts) {
- let didSomething = false;
+ firstPhasePreProcess(globParts) {
+ const { braceExpandMax = 100000 } = this.options;
+ let didSomething = false;
do {
didSomething = false;
// <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
- for (let parts of globParts) {
- let gs = -1;
+ for (let parts of globParts) {
+ // Upstream GHSA-g3hv-75wg-m249: bound iterative globparts expansion.
+ if (globParts.length >= braceExpandMax)
+ return globParts;
+ let gs = -1;
while (-1 !== (gs = parts.indexOf('**', gs + 1))) {
let gss = gs;
while (parts[gss + 1] === '**') {
@@ -527,8 +531,10 @@
//
// {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
// ^-- not valid because ** doens't follow symlinks
- secondPhasePreProcess(globParts) {
- for (let i = 0; i < globParts.length - 1; i++) {
+ secondPhasePreProcess(globParts) {
+ if (globParts.length > 1000)
+ return globParts;
+ for (let i = 0; i < globParts.length - 1; i++) {
for (let j = i + 1; j < globParts.length; j++) {
const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
if (matched) {