From 7dc6da74e5334c25c2c99b1c13408c8e90b4d16f Mon Sep 17 00:00:00 2001 From: Outsider Date: Fri, 26 Aug 2022 02:50:01 +0900 Subject: [PATCH] add test for ReDoS Signed-off-by: Outsider --- test/unit/utils.spec.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/unit/utils.spec.js b/test/unit/utils.spec.js index adb36c4cd6..ad423f382c 100644 --- a/test/unit/utils.spec.js +++ b/test/unit/utils.spec.js @@ -142,6 +142,12 @@ describe('lib/utils', function () { var fn = '() => foo()'; expect(utils.clean(fn), 'to be', 'foo()'); }); + + it('should prevent ReDoS attack', function () { + this.timeout(100); + var attackFn = 'function' + ' '.repeat(20000); + expect(utils.clean(attackFn), 'to be', 'function'); + }); }); describe('stringify()', function () {