File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
lib/semmle/code/java/frameworks
test/library-tests/dataflow/stream-read Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,29 @@ private import semmle.code.java.dataflow.FlowSteps
6
6
private import semmle.code.java.dataflow.SSA
7
7
private import semmle.code.java.dataflow.TaintTracking
8
8
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
+
9
32
/**
10
33
* A local taint step from the definition of a captured variable, the capturer of which
11
34
* updates the `bytes[]` parameter in an override of the `InputStream.read` method,
Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ public int read(byte[] b) throws IOException {
99
99
}
100
100
101
101
public static void testWrapCall () {
102
- sink (wrapStream (null )); // no flow
102
+ sink (wrapStream (null )); // $ SPURIOUS: hasTaintFlow
103
103
sink (wrapStream (source ())); // $ hasTaintFlow
104
104
}
105
105
You can’t perform that action at this time.
0 commit comments