Skip to content

Commit d3b3af8

Browse files
committed
Re-adds jump step
Note that this causes FP flow in the call context test cases
1 parent 36ff54b commit d3b3af8

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

java/ql/lib/semmle/code/java/frameworks/InputStream.qll

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,29 @@ private import semmle.code.java.dataflow.FlowSteps
66
private import semmle.code.java.dataflow.SSA
77
private import semmle.code.java.dataflow.TaintTracking
88

9+
/**
10+
* A jump taint step from an update of the `bytes[]` parameter in an override of the `InputStream.read` method
11+
* to a class instance expression of the type extending `InputStream`.
12+
*
13+
* This models how a subtype of `InputStream` could be tainted by the definition of its methods, which will
14+
* normally only happen in nested classes.
15+
*/
16+
private class InputStreamWrapperCapturedJumpStep extends AdditionalTaintStep {
17+
override predicate step(DataFlow::Node n1, DataFlow::Node n2) {
18+
exists(InputStreamRead m, NestedClass wrapper |
19+
m.getDeclaringType() = wrapper and
20+
wrapper.getASourceSupertype+() instanceof TypeInputStream
21+
|
22+
n1.(DataFlow::PostUpdateNode).getPreUpdateNode().asExpr() = m.getParameter(0).getAnAccess() and
23+
n2.asExpr()
24+
.(ClassInstanceExpr)
25+
.getConstructedType()
26+
.getASourceSupertype*()
27+
.getSourceDeclaration() = wrapper
28+
)
29+
}
30+
}
31+
932
/**
1033
* A local taint step from the definition of a captured variable, the capturer of which
1134
* updates the `bytes[]` parameter in an override of the `InputStream.read` method,

java/ql/test/library-tests/dataflow/stream-read/A.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public int read(byte[] b) throws IOException {
9999
}
100100

101101
public static void testWrapCall() {
102-
sink(wrapStream(null)); // no flow
102+
sink(wrapStream(null)); // $ SPURIOUS: hasTaintFlow
103103
sink(wrapStream(source())); // $ hasTaintFlow
104104
}
105105

0 commit comments

Comments
 (0)