4
4
* Example for a test.ql:
5
5
* ```ql
6
6
* import csharp
7
- * import DataFlow ::PathGraph
7
+ * import DefaultValueFlow ::PathGraph
8
8
* import TestUtilities.InlineFlowTest
9
9
*
10
- * from DataFlow ::PathNode source, DataFlow ::PathNode sink, DefaultValueFlowConf conf
11
- * where conf.hasFlowPath (source, sink)
10
+ * from DefaultValueFlow ::PathNode source, DefaultValueFlow ::PathNode sink
11
+ * where DefaultValueFlow::flowPath (source, sink)
12
12
* select sink, source, sink, "$@", source, source.toString()
13
+ *
13
14
* ```
14
15
*
15
16
* To declare expecations, you can use the $hasTaintFlow or $hasValueFlow comments within the test source files.
@@ -56,25 +57,17 @@ private predicate defaultSink(DataFlow::Node sink) {
56
57
)
57
58
}
58
59
59
- class DefaultValueFlowConf extends DataFlow:: Configuration {
60
- DefaultValueFlowConf ( ) { this = "qltest:defaultValueFlowConf" }
61
-
62
- override predicate isSource ( DataFlow:: Node n ) { defaultSource ( n ) }
60
+ module DefaultFlowConfig implements DataFlow:: ConfigSig {
61
+ predicate isSource ( DataFlow:: Node n ) { defaultSource ( n ) }
63
62
64
- override predicate isSink ( DataFlow:: Node n ) { defaultSink ( n ) }
63
+ predicate isSink ( DataFlow:: Node n ) { defaultSink ( n ) }
65
64
66
- override int fieldFlowBranchLimit ( ) { result = 1000 }
65
+ int fieldFlowBranchLimit ( ) { result = 1000 }
67
66
}
68
67
69
- class DefaultTaintFlowConf extends TaintTracking:: Configuration {
70
- DefaultTaintFlowConf ( ) { this = "qltest:defaultTaintFlowConf" }
68
+ module DefaultValueFlow = DataFlow:: Global< DefaultFlowConfig > ;
71
69
72
- override predicate isSource ( DataFlow:: Node n ) { defaultSource ( n ) }
73
-
74
- override predicate isSink ( DataFlow:: Node n ) { defaultSink ( n ) }
75
-
76
- override int fieldFlowBranchLimit ( ) { result = 1000 }
77
- }
70
+ module DefaultTaintFlow = TaintTracking:: Global< DefaultFlowConfig > ;
78
71
79
72
private string getSourceArgString ( DataFlow:: Node src ) {
80
73
defaultSource ( src ) and
@@ -88,23 +81,19 @@ class InlineFlowTest extends InlineExpectationsTest {
88
81
89
82
override predicate hasActualResult ( Location location , string element , string tag , string value ) {
90
83
tag = "hasValueFlow" and
91
- exists ( DataFlow:: Node src , DataFlow:: Node sink | getValueFlowConfig ( ) . hasFlow ( src , sink ) |
84
+ exists ( DataFlow:: Node src , DataFlow:: Node sink | DefaultValueFlow :: flow ( src , sink ) |
92
85
sink .getLocation ( ) = location and
93
86
element = sink .toString ( ) and
94
87
if exists ( getSourceArgString ( src ) ) then value = getSourceArgString ( src ) else value = ""
95
88
)
96
89
or
97
90
tag = "hasTaintFlow" and
98
91
exists ( DataFlow:: Node src , DataFlow:: Node sink |
99
- getTaintFlowConfig ( ) . hasFlow ( src , sink ) and not getValueFlowConfig ( ) . hasFlow ( src , sink )
92
+ DefaultTaintFlow :: flow ( src , sink ) and not DefaultValueFlow :: flow ( src , sink )
100
93
|
101
94
sink .getLocation ( ) = location and
102
95
element = sink .toString ( ) and
103
96
if exists ( getSourceArgString ( src ) ) then value = getSourceArgString ( src ) else value = ""
104
97
)
105
98
}
106
-
107
- DataFlow:: Configuration getValueFlowConfig ( ) { result = any ( DefaultValueFlowConf config ) }
108
-
109
- DataFlow:: Configuration getTaintFlowConfig ( ) { result = any ( DefaultTaintFlowConf config ) }
110
99
}
0 commit comments