Files
codeql/java/ql/lib/semmle/code/java/frameworks/XStream.qll
Andrew Eisenberg 8e750f18ad Packaging: Java refactoring
Split java pack into `codeql/java-all` and `codeql/java-queries`.
2021-08-19 14:09:35 -07:00

45 lines
1.1 KiB
Plaintext

/**
* Provides classes and predicates for working with the XStream XML serialization framework.
*/
import java
/**
* The type `com.thoughtworks.xstream.XStream`.
*/
class XStream extends RefType {
XStream() { this.hasQualifiedName("com.thoughtworks.xstream", "XStream") }
}
/**
* An XStream method that deserializes an object.
*/
class XStreamReadObjectMethod extends Method {
XStreamReadObjectMethod() {
this.getDeclaringType() instanceof XStream and
(
this.hasName("fromXML") or
this.hasName("unmarshal")
)
}
}
/**
* A call to `XStream.addPermission(NoTypePermission.NONE)`, which enables white-listing.
*/
class XStreamEnableWhiteListing extends MethodAccess {
XStreamEnableWhiteListing() {
exists(Method m |
m = this.getMethod() and
m.getDeclaringType() instanceof XStream and
m.hasName("addPermission") and
exists(Field f |
this.getAnArgument() = f.getAnAccess() and
f.hasName("NONE") and
f.getDeclaringType()
.hasQualifiedName("com.thoughtworks.xstream.security", "NoTypePermission")
)
)
}
}