diff --git a/ql/src/semmle/go/dataflow/internal/CompareDispatch.qhelp b/ql/src/semmle/go/dataflow/internal/CompareDispatch.qhelp new file mode 100644 index 00000000000..2fd9f957002 --- /dev/null +++ b/ql/src/semmle/go/dataflow/internal/CompareDispatch.qhelp @@ -0,0 +1 @@ +TBD \ No newline at end of file diff --git a/ql/src/semmle/go/dataflow/internal/CompareDispatch.ql b/ql/src/semmle/go/dataflow/internal/CompareDispatch.ql new file mode 100644 index 00000000000..8cccbce8d4e --- /dev/null +++ b/ql/src/semmle/go/dataflow/internal/CompareDispatch.ql @@ -0,0 +1,20 @@ +/** + * @kind problem + * @problem.severity warning + * @precision very-high + * @id go/compare-dispatch + */ + +import go +import DataFlowDispatch + +FuncDef viableCallableOld(CallExpr c) { + exists(DataFlow::CallNode call | call.asExpr() = c | result = call.getACallee()) +} + +from CallExpr c, FuncDef fn, string msg +where + fn = viableCallableOld(c) and not fn = viableCallable(c) and msg = "Missing" + or + not fn = viableCallableOld(c) and fn = viableCallable(c) and msg = "New" +select c, msg + " $@.", fn, "callee" diff --git a/ql/src/semmle/go/dataflow/internal/DispatchStats.ql b/ql/src/semmle/go/dataflow/internal/DispatchStats.ql new file mode 100644 index 00000000000..74eabe44bb5 --- /dev/null +++ b/ql/src/semmle/go/dataflow/internal/DispatchStats.ql @@ -0,0 +1,18 @@ +/** + * @kind table + * @id go/dispatch-stats + */ + +import go +import DataFlowDispatch + +FuncDef viableCallableOld(CallExpr c) { + exists(DataFlow::CallNode call | call.asExpr() = c | result = call.getACallee()) +} + +from CallExpr c, int old, int new +where + old = count(viableCallableOld(c)) and + new = count(viableCallable(c)) and + old != new +select c, old + " -> " + new