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(core): fix git url regex matching taking too long #3213

Merged
merged 1 commit into from Nov 17, 2022

Conversation

Panaetius
Copy link
Member

The gitlab_re that we build has an issue with catastropic backtracking.

essentially, we matched a path like /~something/owner/repo and the part that matches ~something, the part that matches owner and the part that matches repo were greedy matches for a variable number of path fragments separated by / so there's a ton of valid match combinations which regex searches exhaustively.

with this change, it only matches a single part with ~ in front, owner matches a variable path like a/b/c/d and repo only matches the last part. so the only variable-length thing is owner (in the case of subgroups in gitlab). This makes it run fast again.

I also added a test case that, with the old regex, takes 14 seconds and the duration check fails, with the new regex takes 2.3 seconds (for 14 tests) and passes.

@olevski
Copy link
Member

olevski commented Nov 16, 2022

Awesome that we have a test for this now!

@Panaetius Panaetius merged commit 8245ce3 into develop Nov 17, 2022
@Panaetius Panaetius deleted the fix/catastrophic-git-regexes branch November 17, 2022 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants