Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions go/ql/lib/semmle/go/dataflow/internal/DataFlowDispatch.qll
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,10 @@ predicate golangSpecificParamArgFilter(
// Interface methods calls may be passed strictly to that exact method's model receiver:
arg.getPosition() != -1
or
exists(Function callTarget | callTarget = call.getNode().(DataFlow::CallNode).getTarget() |
not isInterfaceMethod(callTarget)
or
callTarget = p.getCallable().asSummarizedCallable().asFunction()
)
p instanceof DataFlow::SummarizedParameterNode
or
not isInterfaceMethod(call.getNode()
.(DataFlow::CallNode)
.getACalleeWithoutVirtualDispatch()
.asFunction())
}
19 changes: 14 additions & 5 deletions go/ql/lib/semmle/go/dataflow/internal/DataFlowNodes.qll
Original file line number Diff line number Diff line change
Expand Up @@ -489,13 +489,9 @@ module Public {
* interface type.
*/
Callable getACalleeIncludingExternals() {
result.asFunction() = this.getTarget()
result = this.getACalleeWithoutVirtualDispatch()
or
exists(DataFlow::Node calleeSource | calleeSource = this.getACalleeSource() |
result.asFuncLit() = calleeSource.asExpr()
or
calleeSource = result.asFunction().getARead()
or
exists(Method declared, Method actual |
calleeSource = declared.getARead() and
actual.implements(declared) and
Expand All @@ -510,6 +506,19 @@ module Public {
*/
FuncDef getACallee() { result = this.getACalleeIncludingExternals().getFuncDef() }

/**
* Gets the definition of a possible target of this call, excluding targets reachable via virtual dispatch.
*/
Callable getACalleeWithoutVirtualDispatch() {
result.asFunction() = this.getTarget()
or
exists(DataFlow::Node calleeSource | calleeSource = this.getACalleeSource() |
result.asFuncLit() = calleeSource.asExpr()
or
calleeSource = result.asFunction().getARead()
)
}

/**
* Gets the name of the function, method or variable that is being called.
*
Expand Down