https://codeql.github.com/docs/codeql-language-guides/navigating-the-call-graph/
两个重要的类
Callable
A Callable is something that can be invoked.
Call
A Call is something that invokes a Callable.
点击查看【processon】
代码示例
class Super {int x;// callablepublic Super() {this(23); // call}// callablepublic Super(int x) {this.x = x;}// callablepublic int getX() {return x;}}class Sub extends Super {// callablepublic Sub(int x) {super(x+19); // call}// callablepublic int getX() {return x-19;}}class Client {// callablepublic static void main(String[] args) {Super s = new Sub(42); // calls.getX(); // call}}
成员谓词
Call类
getCallee谓词,Gets the target callable of this call.
Callable Call::getCallee()
getCaller谓词,Gets the callable invoking this call.
Callable Call::getCaller()
代码示例
import javafrom Call sinkselect sink,sink.getCallee(),sink.getCaller()
结果匹配示例
| sink | sink.getCallee() | sink.getCaller() |
|---|---|---|
| request.getHeader(“x-requested-with”) | getHeader | commence |

在如上代码中sink是MethodAccess类型,commence是Method类型
Callable类
calls谓词,Holds if this callable calls target,如果这个Callable调用了target则返回True
predicate Callable::calls(Callable target)
polyCalls谓词,如果这个Callable直接调用了m,或者间接调用(Callable调用的某个方法覆盖了m)了m则返回True
predicate Callable::polyCalls(Callable m)
代码示例
import javafrom Callable caller, Callable calleewhere caller.calls(callee)select caller, callee
匹配结果示例
查找未被调用的方法
寻找已经被定义,但是从未被调用过的方法
