From 6e62e1e8df7b907beaa37a3182752d310314589f Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 30 Aug 2018 22:33:55 -0700 Subject: [PATCH] Cleanup ReDoS test. --- test/test.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/test.js b/test/test.js index 149653f512..e57b3db477 100644 --- a/test/test.js +++ b/test/test.js @@ -25359,21 +25359,21 @@ assert.deepEqual(actual, [['a'], ['b'], ['c']]); }); - var maxMs = 5; - QUnit.test(`should take less than ${maxMs} ms to prevent ReDoS`, function(assert) { - assert.expect(3); + QUnit.test('should prevent ReDoS', function(assert) { + assert.expect(2); - var hugeWordLen = 50000; - var hugeWord = 'A'.repeat(hugeWordLen); - var startTime = Date.now(); - assert.deepEqual(_.words(hugeWord+'AeiouAreVowels'), [hugeWord, 'Aeiou', 'Are', 'Vowels']); - assert.deepEqual(_.words(hugeWord+'ÆiouAreVowels'), [hugeWord, 'Æiou', 'Are', 'Vowels']); - var endTime = Date.now(); - var timeSpent = endTime - startTime; + var largeWordLen = 50000, + largeWord = 'A'.repeat(largeWordLen), + maxMs = 1000, + startTime = lodashStable.now(); - assert.ok(timeSpent < maxMs, `operation took ${timeSpent} ms`); - }); + assert.deepEqual(_.words(largeWord + 'ÆiouAreVowels'), [largeWord, 'Æiou', 'Are', 'Vowels']); + var endTime = lodashStable.now(), + timeSpent = endTime - startTime; + + assert.ok(timeSpent < maxMs, 'operation took ' + timeSpent + 'ms'); + }); }()); /*--------------------------------------------------------------------------*/