diff --git a/test.js b/test.js index ec0abba..703f562 100644 --- a/test.js +++ b/test.js @@ -176,12 +176,15 @@ test('invalid version does not cause catatrophic backtracking', t => { // Note reproduces attack string generated by https://devina.io/redos-checker const start = Date.now(); const fixtures = [ - '0.0.1-i' + '--i-'.repeat(index) + '\x00', + '0.0.1-i' + '--i-'.repeat(index) + '\u0000', '0' + ' 0.1.0-i0'.repeat(index) + '.1.1+1' + '1'.repeat(index) + 'A', - '1.0.1--' + '-'.repeat(index) + '\x00', - 'g' + ' 0.0.1-i+'.repeat(index) + 'a' + 'v0'.repeat(index) + '\x00' - ] - fixtures.forEach((fixture) => semverRegex().test(fixture)); + '1.0.1--' + '-'.repeat(index) + '\u0000', + 'g' + ' 0.0.1-i+'.repeat(index) + 'a' + 'v0'.repeat(index) + '\u0000', + ]; + for (const fixture of fixtures) { + semverRegex().test(fixture); + } + const difference = Date.now() - start; t.true(difference < 20, `Execution time: ${difference}`); }