c37788
From 03b97db840718e36aaa091f95a98a0b81764093b Mon Sep 17 00:00:00 2001
c37788
From: Takayuki Sato <sttk.xslet@gmail.com>
c37788
Date: Tue, 20 Jul 2021 14:46:33 +0900
c37788
Subject: [PATCH] deps(glob-parent): Resolve ReDoS vulnerability from
c37788
 CVE-2021-35065 (#49)
c37788
c37788
Signed-off-by: rpm-build <rpm-build>
c37788
---
c37788
 node_modules/glob-parent/index.js | 27 +++++++++++++++++++++++++--
c37788
 1 file changed, 25 insertions(+), 2 deletions(-)
c37788
c37788
diff --git a/node_modules/glob-parent/index.js b/node_modules/glob-parent/index.js
c37788
index 09e257e..b182190 100644
c37788
--- a/node_modules/glob-parent/index.js
c37788
+++ b/node_modules/glob-parent/index.js
c37788
@@ -6,7 +6,6 @@ var isWin32 = require('os').platform() === 'win32';
c37788
 
c37788
 var slash = '/';
c37788
 var backslash = /\\/g;
c37788
-var enclosure = /[\{\[].*[\}\]]$/;
c37788
 var globby = /(^|[^\\])([\{\[]|\([^\)]+$)/;
c37788
 var escaped = /\\([\!\*\?\|\[\]\(\)\{\}])/g;
c37788
 
c37788
@@ -25,7 +24,7 @@ module.exports = function globParent(str, opts) {
c37788
   }
c37788
 
c37788
   // special case for strings ending in enclosure containing path separator
c37788
-  if (enclosure.test(str)) {
c37788
+  if (isEnclosure(str)) {
c37788
     str += slash;
c37788
   }
c37788
 
c37788
@@ -40,3 +39,27 @@ module.exports = function globParent(str, opts) {
c37788
   // remove escape chars and return result
c37788
   return str.replace(escaped, '$1');
c37788
 };
c37788
+
c37788
+
c37788
+function isEnclosure(str) {
c37788
+  var lastChar = str.slice(-1)
c37788
+
c37788
+  var enclosureStart;
c37788
+  switch (lastChar) {
c37788
+    case '}':
c37788
+      enclosureStart = '{';
c37788
+      break;
c37788
+    case ']':
c37788
+      enclosureStart = '[';
c37788
+      break;
c37788
+    default:
c37788
+      return false;
c37788
+  }
c37788
+
c37788
+  var foundIndex = str.indexOf(enclosureStart);
c37788
+  if (foundIndex < 0) {
c37788
+    return false;
c37788
+  }
c37788
+
c37788
+  return str.slice(foundIndex + 1, -1).includes(slash);
c37788
+}
c37788
-- 
c37788
2.39.2
c37788