8000 Cleanup ReDoS test. · lodash/lodash@6e62e1e · GitHub
[go: up one dir, main page]

Skip to content

Commit 6e62e1e

Browse files
committed
Cleanup ReDoS test.
1 parent 5c08f18 commit 6e62e1e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

test/test.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25359,21 +25359,21 @@
2535925359
assert.deepEqual(actual, [['a'], ['b'], ['c']]);
2536025360
});
2536125361

25362-
var maxMs = 5;
25363-
QUnit.test(`should take less than ${maxMs} ms to prevent ReDoS`, function(assert) {
25364-
assert.expect(3);
25362+
QUnit.test('should prevent ReDoS', function(assert) {
25363+
assert.expect(2);
2536525364

25366-
var hugeWordLen = 50000;
25367-
var hugeWord = 'A'.repeat(hugeWordLen);
25368-
var startTime = Date.now();
25369-
assert.deepEqual(_.words(hugeWord+'AeiouAreVowels'), [hugeWord, 'Aeiou', 'Are', 'Vowels']);
25370-
assert.deepEqual(_.words(hugeWord+'ÆiouAreVowels'), [hugeWord, 'Æiou', 'Are', 'Vowels']);
25371-
var endTime = Date.now();
25372-
var timeSpent = endTime - startTime;
25365+
var largeWordLen = 50000,
25366+
largeWord = 'A'.repeat(largeWordLen),
25367+
maxMs = 1000,
25368+
startTime = lodashStable.now();
2537325369

25374-
assert.ok(timeSpent < maxMs, `operation took ${timeSpent} ms`);
25375-
});
25370+
assert.deepEqual(_.words(largeWord + 'ÆiouAreVowels'), [largeWord, 'Æiou', 'Are', 'Vowels']);
2537625371

25372+
var endTime = lodashStable.now(),
25373+
timeSpent = endTime - startTime;
25374+
25375+
assert.ok(timeSpent < maxMs, 'operation took ' + timeSpent + 'ms');
25376+
});
2537725377
}());
2537825378

2537925379
/*--------------------------------------------------------------------------*/

0 commit comments

Comments
 (0)
0