Java: Fix tests.

This commit is contained in:
Anders Schack-Mulligen
2021-09-13 16:04:11 +02:00
parent 12aeaeed56
commit ab862276fc
2 changed files with 8 additions and 4 deletions

View File

@@ -115,12 +115,12 @@ public class B {
}
{
// "java.util;Map;true;computeIfAbsent;;;ReturnValue of Argument[1];ReturnValue;value",
Object out = ((Map)null).computeIfAbsent(null,k -> source()); sink(out);
Object out = ((Map)null).computeIfAbsent(null,k -> source()); sink(out); // $ hasValueFlow
}
{
// "java.util;Map;true;computeIfAbsent;;;ReturnValue of Argument[1];MapValue of Argument[-1];value",
Map out = null;
out.computeIfAbsent(null,k -> source()); sink(readMapValue(out));
out.computeIfAbsent(null,k -> source()); sink(readMapValue(out)); // $ hasValueFlow
}
{
// "java.util;Map;true;entrySet;;;MapValue of Argument[-1];MapValue of Element of ReturnValue;value",

View File

@@ -1,4 +1,5 @@
import semmle.code.java.dataflow.DataFlow
import semmle.code.java.dataflow.internal.DataFlowPrivate
import semmle.code.java.dataflow.internal.TaintTrackingUtil
import semmle.code.java.dataflow.internal.DataFlowNodes::Private
import semmle.code.java.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
@@ -24,13 +25,16 @@ where
exists(ArgumentNode arg, MethodAccess call, DataFlow::ParameterNode p, int i |
src = arg and
p.isParameterOf(call.getMethod().getSourceDeclaration(), i) and
arg.argumentOf(call, i)
arg.argumentOf(any(DataFlowCall c | c.asCall() = call), i)
|
sink.asExpr() = call and
taintFlowThrough(p)
or
exists(DataFlow::ParameterNode p2, int j |
sink.(DataFlow::PostUpdateNode).getPreUpdateNode().(ArgumentNode).argumentOf(call, j) and
sink.(DataFlow::PostUpdateNode)
.getPreUpdateNode()
.(ArgumentNode)
.argumentOf(any(DataFlowCall c | c.asCall() = call), j) and
taintFlowUpdate(p, p2) and
p2.isParameterOf(_, j)
)