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

未关闭
#2,391 6 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
java
领域
backend

调研方向

首先定位 Java 的 deserialize(byte, class) 实现,并跟踪编码的类标记和类注册是如何处理的。完成的标准是:防御性变体会验证标记,并且在创建实例之前只接受请求的类或其子类;为匹配数据、子类数据和意外类数据添加覆盖。

由索引模型根据 Issue 内容生成。

描述

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

主要语言
Java
星标
4.6k
派生
470
平均合并
9 小时 28 分钟
30 天内合并 PR
33

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/fory 的其他 Issue

查看 apache/fory 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。