mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Java: Explicitly tie ReturnNode to TargetApi before calling returnNodeAsOutput.
This commit is contained in:
@@ -44,7 +44,8 @@ string captureSource(TargetAPI api) {
|
||||
config.hasFlow(source, sink) and
|
||||
sourceNode(source, kind) and
|
||||
api = source.getEnclosingCallable() and
|
||||
result = asSourceModel(api, returnNodeAsOutput(api, sink), kind)
|
||||
api = sink.getEnclosingCallable() and
|
||||
result = asSourceModel(api, returnNodeAsOutput(sink), kind)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ string captureThroughFlow(TargetAPI api) {
|
||||
config.hasFlow(p, returnNodeExt) and
|
||||
returnNodeExt.getEnclosingCallable() = api and
|
||||
input = parameterNodeAsInput(p) and
|
||||
output = returnNodeAsOutput(api, returnNodeExt) and
|
||||
output = returnNodeAsOutput(returnNodeExt) and
|
||||
input != output and
|
||||
result = asTaintModel(api, input, output)
|
||||
)
|
||||
|
||||
@@ -165,13 +165,12 @@ string parameterNodeAsInput(DataFlow::ParameterNode p) {
|
||||
result = "Argument[-1]" and p instanceof DataFlow::InstanceParameterNode
|
||||
}
|
||||
|
||||
bindingset[api]
|
||||
string returnNodeAsOutput(TargetAPI api, ReturnNodeExt node) {
|
||||
string returnNodeAsOutput(ReturnNodeExt node) {
|
||||
if node.getKind() instanceof ValueReturnKind
|
||||
then result = "ReturnValue"
|
||||
else
|
||||
exists(int pos | pos = node.getKind().(ParamUpdateReturnKind).getPosition() |
|
||||
result = parameterAccess(api.getParameter(pos))
|
||||
result = parameterAccess(node.getEnclosingCallable().getParameter(pos))
|
||||
or
|
||||
result = "Argument[-1]" and pos = -1
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user