Skip to content

Instantly share code, notes, and snippets.

@watson
Last active December 15, 2022 17:11
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save watson/7682ee718b9cf4aa2a5a605a3fb4a552 to your computer and use it in GitHub Desktop.
Save watson/7682ee718b9cf4aa2a5a605a3fb4a552 to your computer and use it in GitHub Desktop.
Node.js ReDoS example
// for more info about ReDoS, see:
// https://en.wikipedia.org/wiki/ReDoS
var r = /([a-z]+)+$/
var s = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaa!'
console.log('Running regular expression... please wait')
console.time('benchmark')
r.test(s)
console.timeEnd('benchmark')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment