Refactor lookup client/server and abstract rpc layer.#2609
Refactor lookup client/server and abstract rpc layer.#2609maobaolong merged 2 commits intoLMCache:devfrom
Conversation
Summary of ChangesHello @maobaolong, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the RPC communication within the LMCache lookup client and server. By introducing an abstract transport layer, the core lookup logic is now decoupled from the specific ZMQ implementation, enhancing modularity and maintainability. This change centralizes ZMQ-specific concerns like socket management, serialization, and error handling into dedicated transport classes, making the client and server components cleaner and more focused on their primary responsibilities. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request significantly refactors the RPC layer for the lookup client and server, improving maintainability and extensibility. However, a critical Denial of Service vulnerability was identified in the RPC server's request processing loop due to a lack of error handling for malformed messages, which can crash the background server thread. Further enhancements are suggested to ensure consistent serialization/deserialization in the transport layer and to fix a potential bug in request validation.
|
@sammshen @chunxiaozheng Would you like to take a look at this PR? Thanks! |
Signed-off-by: baoloongmao <baoloongmao@tencent.com>
Address gemini-bot review comments: 1. Fix critical DoS vulnerability in RPC server request processing - Add comprehensive error handling for malformed messages - Handle JSONDecodeError, UnicodeDecodeError, and other exceptions - Add frame structure and data type validation - Support both bytes and str for backward compatibility 2. Fix request validation bug in transport layer - Change minimum frame count from 2 to 3 - Prevent edge case when data_frames[0] == data_frames[-2] 3. Improve serialization abstraction - Remove redundant UTF-8 encoding in client - Let transport layer handle all serialization - Pass Python strings directly instead of bytes Signed-off-by: maobaolong <maobaolong@tencent.com> Signed-off-by: baoloongmao <baoloongmao@tencent.com>
* Refactor lookup client/server and abstract rpc layer. Signed-off-by: baoloongmao <baoloongmao@tencent.com> * Fix security vulnerabilities and improve RPC robustness Address gemini-bot review comments: 1. Fix critical DoS vulnerability in RPC server request processing - Add comprehensive error handling for malformed messages - Handle JSONDecodeError, UnicodeDecodeError, and other exceptions - Add frame structure and data type validation - Support both bytes and str for backward compatibility 2. Fix request validation bug in transport layer - Change minimum frame count from 2 to 3 - Prevent edge case when data_frames[0] == data_frames[-2] 3. Improve serialization abstraction - Remove redundant UTF-8 encoding in client - Let transport layer handle all serialization - Pass Python strings directly instead of bytes Signed-off-by: maobaolong <maobaolong@tencent.com> Signed-off-by: baoloongmao <baoloongmao@tencent.com> --------- Signed-off-by: baoloongmao <baoloongmao@tencent.com> Signed-off-by: maobaolong <maobaolong@tencent.com> Signed-off-by: shaoxiawjc <wjc2800@163.com>
* Refactor lookup client/server and abstract rpc layer. Signed-off-by: baoloongmao <baoloongmao@tencent.com> * Fix security vulnerabilities and improve RPC robustness Address gemini-bot review comments: 1. Fix critical DoS vulnerability in RPC server request processing - Add comprehensive error handling for malformed messages - Handle JSONDecodeError, UnicodeDecodeError, and other exceptions - Add frame structure and data type validation - Support both bytes and str for backward compatibility 2. Fix request validation bug in transport layer - Change minimum frame count from 2 to 3 - Prevent edge case when data_frames[0] == data_frames[-2] 3. Improve serialization abstraction - Remove redundant UTF-8 encoding in client - Let transport layer handle all serialization - Pass Python strings directly instead of bytes Signed-off-by: maobaolong <maobaolong@tencent.com> Signed-off-by: baoloongmao <baoloongmao@tencent.com> --------- Signed-off-by: baoloongmao <baoloongmao@tencent.com> Signed-off-by: maobaolong <maobaolong@tencent.com> Signed-off-by: Aaron Wu <aaron.wu@dell.com>
* Refactor lookup client/server and abstract rpc layer. Signed-off-by: baoloongmao <baoloongmao@tencent.com> * Fix security vulnerabilities and improve RPC robustness Address gemini-bot review comments: 1. Fix critical DoS vulnerability in RPC server request processing - Add comprehensive error handling for malformed messages - Handle JSONDecodeError, UnicodeDecodeError, and other exceptions - Add frame structure and data type validation - Support both bytes and str for backward compatibility 2. Fix request validation bug in transport layer - Change minimum frame count from 2 to 3 - Prevent edge case when data_frames[0] == data_frames[-2] 3. Improve serialization abstraction - Remove redundant UTF-8 encoding in client - Let transport layer handle all serialization - Pass Python strings directly instead of bytes Signed-off-by: maobaolong <maobaolong@tencent.com> Signed-off-by: baoloongmao <baoloongmao@tencent.com> --------- Signed-off-by: baoloongmao <baoloongmao@tencent.com> Signed-off-by: maobaolong <maobaolong@tencent.com>
* Refactor lookup client/server and abstract rpc layer. Signed-off-by: baoloongmao <baoloongmao@tencent.com> * Fix security vulnerabilities and improve RPC robustness Address gemini-bot review comments: 1. Fix critical DoS vulnerability in RPC server request processing - Add comprehensive error handling for malformed messages - Handle JSONDecodeError, UnicodeDecodeError, and other exceptions - Add frame structure and data type validation - Support both bytes and str for backward compatibility 2. Fix request validation bug in transport layer - Change minimum frame count from 2 to 3 - Prevent edge case when data_frames[0] == data_frames[-2] 3. Improve serialization abstraction - Remove redundant UTF-8 encoding in client - Let transport layer handle all serialization - Pass Python strings directly instead of bytes Signed-off-by: maobaolong <maobaolong@tencent.com> Signed-off-by: baoloongmao <baoloongmao@tencent.com> --------- Signed-off-by: baoloongmao <baoloongmao@tencent.com> Signed-off-by: maobaolong <maobaolong@tencent.com>
What this PR does / why we need it:
This pull request significantly refactors the RPC communication within the LMCache lookup client and server. By introducing an abstract transport layer, the core lookup logic is now decoupled from the specific ZMQ implementation, enhancing modularity and maintainability. This change centralizes ZMQ-specific concerns like socket management, serialization, and error handling into dedicated transport classes, making the client and server components cleaner and more focused on their primary responsibilities.
Special notes for your reviewers:
If applicable: