1
1
import java
2
2
import semmle.code.java.dataflow.FlowSources
3
- import TestUtilities.InlineFlowTest
3
+ import TestUtilities.InlineExpectationsTest
4
4
5
5
class LocalSource extends DataFlow:: Node {
6
6
LocalSource ( ) {
@@ -9,28 +9,42 @@ class LocalSource extends DataFlow::Node {
9
9
}
10
10
}
11
11
12
- class LocalValueConf extends DefaultValueFlowConf {
12
+ predicate isTestSink ( DataFlow:: Node n ) {
13
+ exists ( MethodAccess ma | ma .getMethod ( ) .hasName ( "sink" ) | n .asExpr ( ) = ma .getAnArgument ( ) )
14
+ }
15
+
16
+ class LocalValueConf extends DataFlow:: Configuration {
17
+ LocalValueConf ( ) { this = "LocalValueConf" }
18
+
13
19
override predicate isSource ( DataFlow:: Node n ) { n instanceof LocalSource }
20
+
21
+ override predicate isSink ( DataFlow:: Node n ) { isTestSink ( n ) }
14
22
}
15
23
16
- class LocalTaintConf extends DefaultTaintFlowConf {
24
+ class LocalTaintConf extends TaintTracking:: Configuration {
25
+ LocalTaintConf ( ) { this = "LocalTaintConf" }
26
+
17
27
override predicate isSource ( DataFlow:: Node n ) { n instanceof LocalSource }
28
+
29
+ override predicate isSink ( DataFlow:: Node n ) { isTestSink ( n ) }
18
30
}
19
31
20
- class LocalFlowTest extends InlineFlowTest {
32
+ class LocalFlowTest extends InlineExpectationsTest {
33
+ LocalFlowTest ( ) { this = "LocalFlowTest" }
34
+
21
35
override string getARelevantTag ( ) { result = [ "hasLocalValueFlow" , "hasLocalTaintFlow" ] }
22
36
23
37
override predicate hasActualResult ( Location location , string element , string tag , string value ) {
24
38
tag = "hasLocalValueFlow" and
25
- exists ( DataFlow:: Node src , DataFlow:: Node sink | getValueFlowConfig ( ) .hasFlow ( src , sink ) |
39
+ exists ( DataFlow:: Node src , DataFlow:: Node sink | any ( LocalValueConf c ) .hasFlow ( src , sink ) |
26
40
sink .getLocation ( ) = location and
27
41
element = sink .toString ( ) and
28
42
value = ""
29
43
)
30
44
or
31
45
tag = "hasLocalTaintFlow" and
32
46
exists ( DataFlow:: Node src , DataFlow:: Node sink |
33
- getTaintFlowConfig ( ) .hasFlow ( src , sink ) and not getValueFlowConfig ( ) .hasFlow ( src , sink )
47
+ any ( LocalTaintConf c ) .hasFlow ( src , sink ) and not any ( LocalValueConf c ) .hasFlow ( src , sink )
34
48
|
35
49
sink .getLocation ( ) = location and
36
50
element = sink .toString ( ) and
0 commit comments