Repository navigation
Refuse a request that names more branch patterns than MaxBranchPatternsPerRequest [patch] - #117
Merged
Merged
Conversation
…nsPerRequest [patch] POST /state and GET /branches capped each pattern's length but not how many patterns one request could send. Every pattern is matched against every mirror branch synchronously, so one request with tens of thousands of patterns could hold a thread for minutes. Add MaxBranchPatternsPerRequest (default 256, validated > 0) and refuse a request over it with a 400 in TryParsePatterns, before any clone or fetch. Fixes #116 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW24ManL6mVAsf34qvT
|
matt-edmondson
pushed a commit
that referenced
this pull request
Nov 3, 2026
Keeps it clear of the lines #117 adds, so the two PRs merge in either order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW24ManL6mVAsf34qvT
matt-edmondson
added a commit
that referenced
this pull request
Nov 4, 2026
…sting [patch] (#118) * Skip a branch whose name is not UTF-8 instead of failing every ref listing [patch] RefResolver.ListAsync read for-each-ref output through GitRunner's strict UTF-8 decoding, so one ref name git allows but UTF-8 cannot read failed the whole listing, and every /state and /branches request for that repository returned 502 refs-unreadable until the branch was deleted. GitInvocation.ReadStandardOutputAsBytes now returns stdout one character per byte. RefResolver decodes each line on its own, skips a line that is not UTF-8, and logs a warning with the hex of the ref name. Every other branch is still served. Fixes #114 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW24ManL6mVAsf34qvT * Move the #114 end-to-end test to the end of StateFlowTests Keeps it clear of the lines #117 adds, so the two PRs merge in either order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW24ManL6mVAsf34qvT --------- Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Fixes #116
What changes
BranchStateHandler.TryParsePatternscapped each pattern's length but not how many patterns a request could send. Every pattern is matched against every mirror branch synchronously, so onePOST /statewith tens of thousands of patterns could hold a request thread for minutes.GitBranchStateCacheOptions.MaxBranchPatternsPerRequest, default 256.GitBranchStateCacheOptionsValidatorrefuses a value of zero or less.TryParsePatternstakes the limit and returns a 400 when the request goes over it. The check runs before the mirror is cloned or fetched, and it covers bothPOST /stateandGET /branches?pattern=.GitBranchStateCache.Tool/appsettings.jsonlist the new setting next toMaxPathsPerRequest. The README also says in a sentence that both limits are refused before anything is fetched.I left out passing the
CancellationTokenintoRefResolver.Match. The issue marks that as optional, and the cap alone bounds the work.Tests
StateFlowTests.Post_State_MoreBranchPatternsThanTheLimit_Is400BeforeAnyFetch: with the limit set to 3, sending 4 patterns returns 400 with "at most 3" in the message, and git never runscloneorfetch.StateFlowTests.Post_State_BranchPatternsAtTheLimit_AreAccepted: a request with exactly the limit still returns 200.StateFlowTests.Get_Branches_MoreBranchPatternsThanTheLimit_Is400: the same check on/branches.GitBranchStateCacheOptionsValidatorTests.Validate_NonPositiveMaxBranchPatternsPerRequest_Failsfor 0 and -1.With the handler check disabled, both over-limit tests fail. With it in place, the full
GitBranchStateCache.Testssuite passes (290/290, net10.0).Generated by Claude Code