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