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

Regex ReDos test answer is incomplete/incorrect #127

Open
wdoekes opened this issue May 9, 2023 · 0 comments
Open

Regex ReDos test answer is incomplete/incorrect #127

wdoekes opened this issue May 9, 2023 · 0 comments

Comments

@wdoekes
Copy link

wdoekes commented May 9, 2023

The question about resolving the ReDos requests a change from ^(PATTERN+)*$ to ^PATTERN+$, but that is not entirely correct.

The correct option would be: ^(PATTERN+)$ because it keeps the capture group that part of the software could rely on.

Compare these:

>>> re.match(r'^([a-z]+)*$', 'zzz').groups()[0]
'zzz'

>>> re.match(r'^([a-z]+)$', 'zzz').groups()[0]
'zzz'

>>> re.match(r'^[a-z]+$', 'zzz').groups()[0]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: tuple index out of range

(I realise just now that this might not be the correct place to file this. I was checking the developing-secure-software-lfd121 content. If I'm in the wrong place, I am sorry.)

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

No branches or pull requests

1 participant