mirror of
https://github.com/github/codeql.git
synced 2026-01-30 06:42:57 +01:00
Revert getACallee type change
This commit is contained in:
committed by
Owen Mansel-Chan
parent
6110506e02
commit
3cf1459c4f
@@ -371,7 +371,7 @@ class Function extends ValueEntity, @functionobject {
|
||||
DataFlow::CallNode getACall() {
|
||||
this = result.getTarget()
|
||||
or
|
||||
this.(DeclaredFunction).getFuncDecl() = result.getACallee()
|
||||
this = result.getACalleeIncludingExternals().asFunction()
|
||||
}
|
||||
|
||||
/** Gets the declaration of this function, if any. */
|
||||
|
||||
@@ -93,7 +93,7 @@ DataFlowCallable viableCallable(CallExpr ma) {
|
||||
else
|
||||
if isInterfaceMethodCall(call)
|
||||
then result = getRestrictedInterfaceTarget(call)
|
||||
else result.getFuncDef() = call.getACallee()
|
||||
else result = call.getACalleeIncludingExternals()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -449,20 +449,26 @@ module Public {
|
||||
* For virtual calls, we look up possible targets in all types that implement the receiver
|
||||
* interface type.
|
||||
*/
|
||||
FuncDef getACallee() {
|
||||
result = this.getTarget().(DeclaredFunction).getFuncDecl()
|
||||
DataFlowCallable getACalleeIncludingExternals() {
|
||||
result.asFunction() = this.getTarget()
|
||||
or
|
||||
exists(DataFlow::Node calleeSource | calleeSource = this.getACalleeSource() |
|
||||
result = calleeSource.asExpr()
|
||||
result.asFuncLit() = calleeSource.asExpr()
|
||||
or
|
||||
exists(Method declared, Method actual |
|
||||
calleeSource = declared.getARead() and
|
||||
actual.implements(declared) and
|
||||
result = actual.(DeclaredFunction).getFuncDecl()
|
||||
result.asFunction() = actual
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* As `getACalleeIncludingExternals`, except excluding external functions (those for which
|
||||
* we lack a definition, such as standard library functions).
|
||||
*/
|
||||
FuncDef getACallee() { result = this.getACalleeIncludingExternals().getFuncDef() }
|
||||
|
||||
/** Gets the name of the function or method being called, if it can be determined. */
|
||||
string getCalleeName() { result = expr.getTarget().getName() or result = expr.getCalleeName() }
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ module UnsafeUnzipSymlink {
|
||||
* Gets a `CallNode` that may call `node`'s enclosing function.
|
||||
*/
|
||||
private DataFlow::CallNode getACaller(DataFlow::CallNode node) {
|
||||
result.getACallee().getFuncDef() = node.getRoot()
|
||||
result.getACallee() = node.getRoot()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,9 +26,9 @@ predicate isNil(DataFlow::Node node) { node = Builtin::nil().getARead() }
|
||||
* `nil` for the pointer return value at some return site.
|
||||
*/
|
||||
predicate calleeMayReturnNilWithError(DataFlow::CallNode call) {
|
||||
not exists(call.getACallee().getFuncDef())
|
||||
not exists(call.getACallee())
|
||||
or
|
||||
exists(FuncDef callee | callee = call.getACallee().getFuncDef() |
|
||||
exists(FuncDef callee | callee = call.getACallee() |
|
||||
not exists(callee.getBody())
|
||||
or
|
||||
exists(IR::ReturnInstruction ret, DataFlow::Node ptrReturn, DataFlow::Node errReturn |
|
||||
|
||||
@@ -31,7 +31,7 @@ class HostKeyCallbackFunc extends DataFlow::Node {
|
||||
(
|
||||
this instanceof DataFlow::FunctionNode
|
||||
or
|
||||
exists(DataFlow::CallNode call | not exists(call.getACallee().getFuncDef().getBody()) |
|
||||
exists(DataFlow::CallNode call | not exists(call.getACallee().getBody()) |
|
||||
this = call.getAResult()
|
||||
)
|
||||
)
|
||||
|
||||
@@ -54,9 +54,7 @@ predicate isCleaned(DataFlow::Node nd) {
|
||||
isCleaned(nd.getAPredecessor())
|
||||
or
|
||||
exists(FuncDef f, FunctionInput inp | nd = inp.getExitNode(f) |
|
||||
forex(DataFlow::CallNode call | call.getACallee().getFuncDef() = f |
|
||||
isCleaned(inp.getEntryNode(call))
|
||||
)
|
||||
forex(DataFlow::CallNode call | call.getACallee() = f | isCleaned(inp.getEntryNode(call)))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -89,9 +87,7 @@ predicate urlPath(DataFlow::Node nd) {
|
||||
urlPath(nd.getAPredecessor())
|
||||
or
|
||||
exists(FuncDef f, FunctionInput inp | nd = inp.getExitNode(f) |
|
||||
forex(DataFlow::CallNode call | call.getACallee().getFuncDef() = f |
|
||||
urlPath(inp.getEntryNode(call))
|
||||
)
|
||||
forex(DataFlow::CallNode call | call.getACallee() = f | urlPath(inp.getEntryNode(call)))
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import go
|
||||
|
||||
query predicate missingCall(DeclaredFunction f, DataFlow::CallNode call) {
|
||||
call.getACallee().asFunction() = f and
|
||||
call.getACallee() = f.getFuncDecl() and
|
||||
not call = f.getACall()
|
||||
}
|
||||
|
||||
query predicate spuriousCall(DeclaredFunction f, DataFlow::CallNode call) {
|
||||
call = f.getACall() and
|
||||
not call.getACallee().asFunction() = f
|
||||
exists(FuncDecl fd | fd = f.getFuncDecl() | not call.getACallee() = fd)
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@ string metadata(Locatable l, string key) {
|
||||
|
||||
query predicate missingCallee(DataFlow::CallNode call, FuncDef callee) {
|
||||
metadata(call.asExpr(), "callee") = metadata(callee, "name") and
|
||||
not call.getACallee().getFuncDef() = callee
|
||||
not call.getACallee() = callee
|
||||
}
|
||||
|
||||
query predicate spuriousCallee(DataFlow::CallNode call, FuncDef callee) {
|
||||
call.getACallee().getFuncDef() = callee and
|
||||
call.getACallee() = callee and
|
||||
not metadata(call.asExpr(), "callee") = metadata(callee, "name")
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class SummaryModelTest extends SummaryModelCsv {
|
||||
"github.com/nonexistent/test;;false;FunctionWithSliceParameter;;;ArrayElement of Argument[0];ReturnValue;value",
|
||||
"github.com/nonexistent/test;;false;FunctionWithVarArgsParameter;;;ArrayElement of Argument[0];ReturnValue;value",
|
||||
"github.com/nonexistent/test;;false;FunctionWithSliceOfStructsParameter;;;Field[github.com/nonexistent/test.A.Field] of ArrayElement of Argument[0];ReturnValue;value",
|
||||
"github.com/nonexistent/test;;false;FunctionWithVarArgsOfStructsParameter;;;Field[github.com/nonexistent/test.A.Field] of ArrayElement of Argument[0];ReturnValue;value",
|
||||
"github.com/nonexistent/test;;false;FunctionWithVarArgsOfStructsParameter;;;Field[github.com/nonexistent/test.A.Field] of ArrayElement of Argument[0];ReturnValue;value"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user