[Java] add more defensive version of deserialize(byte, class)

Đang mở
#2,391 6 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
java
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu bằng cách xác định triển khai Java của deserialize(byte, class) và theo dõi cách các marker lớp được mã hóa cùng việc đăng ký lớp được xử lý. Công việc được hoàn tất khi một biến thể phòng vệ xác thực marker và chỉ chấp nhận lớp được yêu cầu hoặc một lớp con trước khi tạo một thực thể; thêm coverage cho dữ liệu khớp, dữ liệu của lớp con và dữ liệu có lớp không mong đợi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement
Feature Request

I debugged the method deserialize(byte, class) and found that it does not check the deserialized data matches the class - that it just info for the compiler to know what the expected return type is.
Would it be possible to add a deserializeWithClassCheck(byte, class) that validates the byte data has a class marker saved into the byte data and that class data relates to a class that is the class expected (the one passed in the parameter list of deserializeWithClassCheck) or a subclass?

Is your feature request related to a problem? Please describe

The idea is that users who have a secure network can avoid registering all the classes that they need on the Fory instance but have the deserializeWithClassCheck call validate the encoded data is not related to some unexpected class.
deserialize(byte, class) will deserialize and you will get a Class Cast Exception but it is good to have a method that avoids creating class instances when the encoded data is of wrong type.

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

Ngôn ngữ chính
Java
Star
4.6k
Fork
470
Merge trung bình
9 giờ 28 phút
Pull request đã merge (30 ngày)
33

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/fory

Tất cả issue của apache/fory

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.