From 8995f8c5fe536fdf1964283993ed5e5ccb8a3695 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 3 Feb 2021 06:26:45 -0800 Subject: [PATCH] fix: eliminate ReDoS This change fixes a regular expression denial of service vulnerability. Fixes: https://github.com/gulpjs/glob-parent/issues/32 Refs: https://app.snyk.io/vuln/SNYK-JS-GLOBPARENT-1016905 --- index.js | 2 +- test/index.test.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 789dbbf..45f1cb9 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ var isWin32 = require('os').platform() === 'win32'; var slash = '/'; var backslash = /\\/g; -var enclosure = /[\{\[].*[\/]*.*[\}\]]$/; +var enclosure = /[\{\[].*[\}\]]$/; var globby = /(^|[^\\])([\{\[]|\([^\)]+$)/; var escaped = /\\([\!\*\?\|\[\]\(\)\{\}])/g; diff --git a/test/index.test.js b/test/index.test.js index c13bf04..0a0291e 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -209,6 +209,13 @@ describe('glob2base test patterns', function() { done(); }); + + it('should not be susceptible to SNYK-JS-GLOBPARENT-1016905', function(done) { + // This will time out if susceptible. + gp('{' + '/'.repeat(5000)); + + done(); + }); }); if (isWin32) {