File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed
java/ql/test/library-tests/dataflow/typepruning Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ public class A {
2+ Object customStep (Object o ) { return null ; }
3+
4+ Object source () { return null ; }
5+
6+ void sink (Object o ) { }
7+
8+ Object through1 (Object o ) {
9+ Object o2 = customStep (o );
10+ String s = (String )o2 ;
11+ return s ;
12+ }
13+
14+ void foo () {
15+ Object x = through1 (source ());
16+ sink (x );
17+ }
18+ }
Original file line number Diff line number Diff line change 1+ | A.java:15:25:15:32 | source(...) | A.java:16:10:16:10 | x | A.java:14:8:14:10 | foo |
Original file line number Diff line number Diff line change 1+ import java
2+ import semmle.code.java.dataflow.DataFlow
3+ import DataFlow
4+
5+ class Conf extends Configuration {
6+ Conf ( ) { this = "test types" }
7+
8+ override predicate isSource ( Node n ) { n .asExpr ( ) .( MethodAccess ) .getMethod ( ) .hasName ( "source" ) }
9+
10+ override predicate isSink ( Node n ) {
11+ exists ( MethodAccess sink |
12+ sink .getAnArgument ( ) = n .asExpr ( ) and sink .getMethod ( ) .hasName ( "sink" )
13+ )
14+ }
15+
16+ override predicate isAdditionalFlowStep ( Node n1 , Node n2 ) {
17+ exists ( MethodAccess ma |
18+ ma .getMethod ( ) .hasName ( "customStep" ) and
19+ ma .getAnArgument ( ) = n1 .asExpr ( ) and
20+ ma = n2 .asExpr ( )
21+ )
22+ }
23+ }
24+
25+ from Node src , Node sink , Conf conf
26+ where conf .hasFlow ( src , sink )
27+ select src , sink , sink .getEnclosingCallable ( )
You can’t perform that action at this time.
0 commit comments