| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 5d737124-0bf4-4532-a638-17ea84e3a008 📥 CommitsReviewing files that changed from the base of the PR and between e303e22 and 2300c6b. 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 Walkthrough WalkthroughPyMySQL now supports MySQL protocol compression with zlib and optional zstd. The connection negotiates compression during authentication and uses compressed framing for later traffic. The change adds codec and connection tests, an optional zstd dependency, and installation and changelog documentation. ChangesMySQL protocol compression
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~45 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant Connection
participant MySQLServer
participant CompressedStream
Connection->>MySQLServer: Negotiate zlib or zstd capability
Connection->>MySQLServer: Complete authentication with normal framing
Connection->>CompressedStream: Create stream after authentication
Connection->>CompressedStream: Pass subsequent writes for framing
CompressedStream->>MySQLServer: Send compressed protocol frames
MySQLServer->>CompressedStream: Return compressed protocol frames
CompressedStream->>Connection: Provide decoded packet bytes
Merge Risk: ⚪ Minimal · up to 2300c No concrete merge-blocking issue was identified. Compression support appears ready to merge subject to normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to 2300c Compression preserves the inspected authentication and TLS ordering and rejects malformed streams with bounded output. The main remaining concern is connection reuse after an unexpected interruption during compressed decoding. Exposure is limited to connections using compression; no credential bypass or broader privilege gain was established. Retained concerns
Security Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
❌ Failed checks (1 warning)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. ❤️ ShareComment @coderabbitai help to get the list of available commands. |
Sorry, something went wrong.
|
|
||
|
|
||
| def _pack_int24(value): | ||
| return struct.pack("<I", value)[:3] |
There was a problem hiding this comment.
value.to_bytes(3, "little") の方が速いしoverflow errorになって安全だからそっちにして。
Sorry, something went wrong.
| header = ( | ||
| _pack_int24(len(payload)) | ||
| + bytes([self.sequence]) | ||
| + _pack_int24(original_length) | ||
| ) | ||
| write_bytes(header + payload) |
There was a problem hiding this comment.
header の一時オブジェクトが無駄だから一気に header + payload まで全部作って write_bytes して。
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PyMySQL currently rejects compress=True. This change enables MySQL protocol compression with zlib and zstd, including zstd on Python 3.9–3.13 through the optional PyMySQL[zstd] extra.
compress=True prefers zstd when available and supported by the server, then falls back to zlib or an uncompressed connection. compress="zlib" and compress="zstd" require the selected algorithm. Outgoing payloads below 400 bytes, or those that do not shrink, remain uncompressed within the compressed protocol.
The framing follows the MySQL protocol and the approach used by go-sql-driver/mysql: compression starts after authentication, supports packets split across frames and sequence wraparound, and handles large requests and responses. Decompression is bounded by the declared length and rejects corrupt or incomplete streams. Python 3.14+ uses compression.zstd; earlier versions use backports.zstd>=1.3.0, installed only when python_version < "3.14". CI installs the extra, and the README and changelog document the API.
Compressed-frame lengths use int.to_bytes(3, "little") so overflow is rejected, and the complete header and payload are assembled in one join. Decoder contexts remain independent per frame: the supported stateful decoder APIs stop at EOF and provide no reset operation. Sharing one global decoder would therefore fail on later frames even if calls were serialized. The standard-library one-shot zstd helper also constructs a new decoder internally and does not provide the bounded-output check used here. The code documents this constraint and the concurrent-stream tests verify isolation.
Validation:
Summary by CodeRabbit