Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive in redos detection when backtracking doesn't occur #14

mschwager opened this issue Jan 10, 2020 · 0 comments


Copy link

In order for catastrophic backtracking to occur there must be a character that forces backtracking to occur. E.g.

>>> re.match('(a+)+', 'a' * 64 + 'c')
<_sre.SRE_Match at 0x7f9106d32430>
>>> re.match('(a+)+b', 'a' * 64 + 'c')

The first expression has nested quantifiers, so Dlint will detect it, but since there's nothing after the nested quantifier to backtrack the match no catastrophic backtracking will occur. Similarly:

$ python -m dlint.redos -p '(a+)+'
('(a+)+', True)
$ python -m dlint.redos -p '(a+)+b'
('(a+)+b', True)

We should avoid detecting the first expression because catastrophic backtracking cannot occur.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

1 participant