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

fix(metrics): adjust regex to avoid exponential backtracking #34881

Merged
merged 3 commits into from
May 24, 2022

Conversation

mdtro
Copy link
Member

@mdtro mdtro commented May 20, 2022

Adjust regex to avoid exponential backtracking when fed a string containing a lot of underscores.

The \w token is effectively [a-zA-Z0-9_] so I've excluded the explicit _ in the regex as well.

The original FIELD_REGEX had 3 capture groups, but I don't think they are actually needed. I condensed this down to two. Could I have the reviewer double check that for me? 🙂

FIELD_REGEX: (left: old regex | right: new regex)
image

@mdtro mdtro force-pushed the mdtro/fix-metrics-utils-regex branch from 5b13528 to 668a627 Compare May 20, 2022 22:12
@mdtro mdtro marked this pull request as ready for review May 20, 2022 22:19
@mdtro mdtro requested a review from a team as a code owner May 20, 2022 22:19
@mdtro mdtro requested a review from ahmedetefy May 20, 2022 22:20
@mdtro mdtro changed the title fix(redos): adjust regex to avoid exponential backtracking fix(metrics): adjust regex to avoid exponential backtracking May 20, 2022
@ahmedetefy
Copy link
Contributor

@mdtro Thanks for opening this PR! The change makes sense!
However we are re-visiting these regexes at the moment to make them more restrictive based on the recent developments in the API so will hold off on merging this until we have requirements cleared out

@ahmedetefy ahmedetefy merged commit 5aa0283 into master May 24, 2022
@ahmedetefy ahmedetefy deleted the mdtro/fix-metrics-utils-regex branch May 24, 2022 07:54
@github-actions github-actions bot locked and limited conversation to collaborators Jun 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants