mirror of
https://github.com/github/codeql.git
synced 2026-04-26 17:25:19 +02:00
Exclude classes with a writeReplace method from serializability checks
This commit is contained in:
@@ -24,6 +24,16 @@ where
|
||||
c.hasNoParameters() and
|
||||
not c.isPrivate()
|
||||
) and
|
||||
// Assume if an object replaces itself prior to serialization,
|
||||
// then it is unlikely to be directly deserialized.
|
||||
// That means it won't need to comply with default serialization rules,
|
||||
// such as non-serializable super-classes having a no-argument constructor.
|
||||
not exists(Method m |
|
||||
m = serial.getAMethod() and
|
||||
m.hasName("writeReplace") and
|
||||
m.getReturnType() instanceof TypeObject and
|
||||
m.hasNoParameters()
|
||||
) and
|
||||
serial.fromSource()
|
||||
select serial,
|
||||
"This class is serializable, but its non-serializable " +
|
||||
|
||||
Reference in New Issue
Block a user