class XXXSetMethod extends Method{ XXXSetMethod(){ this.getName().indexOf("set") = 0 and this.getName().length() > 3 and this.getNumberOfParameters() = 1 and this.getAParamType().hasName("String") and this.getDeclaringType().getASupertype*().hasQualifiedName("java.awt", "Component") } }
class JNDIMethod extends Method{ JNDIMethod(){ this.getDeclaringType().getAnAncestor().hasQualifiedName("javax.naming", "Context") and this.hasName("lookup") } } class InvokeMethod extends Method { InvokeMethod() { this.hasName("invoke") } }
class NewInstanceMethod extends Method { NewInstanceMethod() { exists(RefType type, Method m| this.getACallee() = m and m.hasName("newInstance") and m.getDeclaringType*().getErasure() = type ) } } class CommandInjectMethod extends Method { CommandInjectMethod() { this.getACallee() instanceof ExecCallable } } class RuntimeMethod extends Method { RuntimeMethod() { this.getDeclaringType().hasQualifiedName("java.lang", "Runtime") and this.hasName("exec") } }
class TargetMethod extends Method { TargetMethod() { this instanceof JNDIMethod or // this instanceof InvokeMethod or // this instanceof NewInstanceMethod or this instanceof CommandInjectMethod or this instanceof MethodRuntimeExec or this instanceof MethodProcessBuilderCommand } }
query predicate edges(Method a, Method b) { a.polyCalls(b) }
from XXXSetMethod entryPoint, TargetMethod end where edges*(entryPoint, end) select entryPoint, entryPoint, end, "Found a path from start to target."