mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Java: Improve IncorrectSerializableMethods.ql; address review comments
This commit is contained in:
@@ -15,15 +15,18 @@ import java
|
||||
|
||||
from Method m, TypeSerializable serializable, string reason
|
||||
where
|
||||
m.fromSource() and
|
||||
m.getDeclaringType().hasSupertype+(serializable) and
|
||||
(
|
||||
m.hasStringSignature("readObject(ObjectInputStream)") or
|
||||
m.hasStringSignature("readObjectNoData()") or
|
||||
m.hasName("writeObject(ObjectOutputStream)")
|
||||
m.hasStringSignature("writeObject(ObjectOutputStream)")
|
||||
) and
|
||||
(
|
||||
not m.isPrivate() and reason = "Method must be private"
|
||||
or m.isStatic() and reason = "Method must not be static"
|
||||
or not m.getReturnType() instanceof VoidType and reason = "Return type must be void"
|
||||
or
|
||||
m.isStatic() and reason = "Method must not be static"
|
||||
or
|
||||
not m.getReturnType() instanceof VoidType and reason = "Return type must be void"
|
||||
)
|
||||
select m, reason
|
||||
select m, "Not recognized by Java serialization framework: " + reason
|
||||
|
||||
Reference in New Issue
Block a user