Skip to content

refactor: consolidate pkt-line pack boundary parsing on PacketLineIn#153

Merged
coopernetes merged 1 commit intomainfrom
refactor/packetlinein-pack-boundary
Apr 15, 2026
Merged

refactor: consolidate pkt-line pack boundary parsing on PacketLineIn#153
coopernetes merged 1 commit intomainfrom
refactor/packetlinein-pack-boundary

Conversation

@coopernetes
Copy link
Copy Markdown
Owner

Summary

  • Replace the duplicated hand-rolled pkt-line length parser in GitReceivePackParser and EnrichPushCommitsFilter with a single shared helper that uses JGit's PacketLineIn to walk the pkt-line framing.
  • Both call sites now go through GitReceivePackParser.findPackDataOffset.
  • Net -53 lines; two copies of parsePacketLength and two copies of the pkt-line walker removed.

Context

ParseGitRequestFilter already consumes the initial pkt-lines via PacketLineIn. This PR finishes the job of replacing in-tree pkt-line framing code with the JGit primitive wherever we still had it.

CVE-2025-54584 protection is preserved — walking real pkt-line framing via PacketLineIn is inherently safe against spoofed PACK bytes in ref names (e.g. refs/heads/PACK-evil), which was the original motivation for the hardened byte-walking code.

Test plan

  • ./gradlew :git-proxy-java-core:test :git-proxy-java-core:jacocoTestCoverageVerification --rerun passes
  • Existing GitReceivePackParserTest cases covering spoofed-PACK-in-ref and pkt-line prefix walking still pass unchanged
  • EnrichPushCommitsFilterTest and ParseGitRequestFilterTest unaffected

Replace the duplicated hand-rolled pkt-line length parser in
GitReceivePackParser and EnrichPushCommitsFilter with a single shared
helper that uses JGit's PacketLineIn to walk the pkt-line framing. Both
call sites now go through GitReceivePackParser.findPackDataOffset.

ParseGitRequestFilter already consumes the initial pkt-lines via
PacketLineIn, so this finishes the job of replacing the in-tree pkt-line
framing code with the JGit primitive. The CVE-2025-54584 protection is
preserved — walking real pkt-line framing is inherently safe against
spoofed PACK bytes in ref names.
@coopernetes coopernetes merged commit 8f47813 into main Apr 15, 2026
12 checks passed
@coopernetes coopernetes deleted the refactor/packetlinein-pack-boundary branch April 15, 2026 13:09
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

Successfully merging this pull request may close these issues.

1 participant