Java: Explicitly tie ReturnNode to TargetApi before calling returnNodeAsOutput.

This commit is contained in:
Michael Nebel
2022-02-25 13:32:12 +01:00
parent 44949b6353
commit 4a0b2b64b3
3 changed files with 5 additions and 5 deletions

View File

@@ -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)
)
}

View File

@@ -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)
)

View File

@@ -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
)