Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Rule: java/missing-no-arg-constructor-on-serializable #18371

Open
ben-manes opened this issue Dec 26, 2024 · 1 comment
Open

Incorrect Rule: java/missing-no-arg-constructor-on-serializable #18371

ben-manes opened this issue Dec 26, 2024 · 1 comment

Comments

@ben-manes
Copy link

ben-manes commented Dec 26, 2024

* @name Serializable but no void constructor
* @description A non-serializable, immediate superclass of a serializable class that does not
* itself declare an accessible, no-argument constructor causes deserialization to
* fail.

This rule does not take into consideration the Serialization Proxy pattern. This approach is recommended in Effective Java, a reference this rule's explanation points to. The proxy pattern is both a simplification and protection from security threats by reconstructing the object from the data elements, using readResolve to replace the output with a new instance, rather than trying to rehydrate the object directly.

While ideally this rule would understand this pattern, it is okay if a false positive yet it recommends that as the solution. A less aware developer might remove this security protection to comply or not be nudged to implement that better approach if a true positive.

@jketema
Copy link
Contributor

jketema commented Dec 27, 2024

Hi @ben-manes,

Thanks for your observation. I've relayed this to the CodeQL Java engineering team.

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

No branches or pull requests

2 participants