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
66private import semmle.code.java.dataflow.SSA
77private 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,
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments