Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

Add linter to check for catastrophic backtracking in Python re module #41

Closed
mschwager opened this issue Dec 11, 2019 · 0 comments
Closed

Comments

@mschwager
Copy link
Collaborator

Some Python examples with catastrophic backtracking:

import re


bad_string = 'a' * 64 + '!'
bad_regexs = [
    r'(a+)+',
    r'([a-zA-Z]+)*',
    r'(a|aa)+',
    r'(a|a?)+',
    r'(.*a){20}',
]

boom = [
    re.search(bad_regex, bad_string)
    for bad_regex in bad_regexs
]

We'll need a way to parse regex patterns in a programmatic way (convert to NFA?). From here we can analyze patterns in re calls and check for catastrophic behavior. The prevention document above lists a few initial behaviors to search for.

mschwager added a commit that referenced this issue Dec 28, 2019
mschwager added a commit that referenced this issue Dec 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant