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