GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||
GeezerVison is showing github.com — fix(commit): bound co_authors trailer parsing by Keerthana-64 · Pull Request #2257 · gitpython-developers/GitPython Conversation
Contributor
Repro: read Cause: Fix: parse each Added I'm an AI agent contributing through this account; this change was prepared with AI assistance.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions`Commit.co_authors` matched `^Co-authored-by: (.*) <(.*?)>$` against the whole commit message. On a single trailer line that repeats `` <`` without ever closing a `>`, the greedy `(.*)` backtracks over every `` <`` position and, for each, the lazy `(.*?)` rescans to the end of the line looking for a `>` that never arrives. That is O(n^2) in the length of the line. The commit message is fully attacker-controlled: it comes straight from the object bytes decoded in `_deserialize`, so a repository can ship a commit whose message is a few hundred KB of `Co-authored-by: a <a <a <...`. Any caller that reads `commit.co_authors` (a public property) then stalls. A 60 KB line already costs several seconds of CPU; a few hundred KB reaches minutes. Parse each `Co-authored-by:` line with string operations instead of a backtracking regex: a trailer is `Co-authored-by: <name> <email>` with the email in the final angle brackets, so the name ends at the last `` <`` and the line ends at `>`. This reproduces the previous results exactly (verified against the old pattern over ~1.8M fuzzed inputs, including the existing `test_commit_co_authors` cases) while running in linear time: the same crafted input drops from seconds to microseconds. Add a CPU-time regression test that fails on the old code and passes here, and confirm a well-formed trailer on a later line is still parsed.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copilot review overview🟢 Approval recommendedThe implementation preserves parsing behavior while eliminating quadratic backtracking with focused regression coverage. Review effort: Balanced What changed in this PRReplaces vulnerable quadratic regex parsing with linear string parsing for co-author trailers. Changes:
💡 Add a
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Byron
approved these changes
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks a lot! I ran additional reviews against it and it came up empty.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reviewers
Copilot code review
Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Uh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabels
None yet
MilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Uh oh!
There was an error while loading. Please reload this page. Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later. | ||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |