Skip to content

Commit bd01336

Browse files
committed
C#: Re-factor the CIL dataflow test to use the new API.
1 parent ededd46 commit bd01336

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

csharp/ql/test/library-tests/cil/dataflow/DataFlow.ql

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,47 @@
33
*/
44

55
import csharp
6-
import DataFlow
6+
import Flow::PathGraph
77

8-
private predicate relevantPathNode(PathNode n) {
8+
private predicate relevantPathNode(Flow::PathNode n) {
99
exists(File f | f = n.getNode().getLocation().getFile() |
1010
f.fromSource()
1111
or
1212
f.getBaseName() = "DataFlow.dll"
1313
)
1414
}
1515

16-
query predicate edges(PathNode a, PathNode b) {
17-
PathGraph::edges(a, b) and
16+
query predicate edges(Flow::PathNode a, Flow::PathNode b) {
17+
Flow::PathGraph::edges(a, b) and
1818
relevantPathNode(a) and
1919
relevantPathNode(b)
2020
}
2121

22-
query predicate nodes(PathNode n, string key, string val) {
23-
PathGraph::nodes(n, key, val) and
22+
query predicate nodes(Flow::PathNode n, string key, string val) {
23+
Flow::PathGraph::nodes(n, key, val) and
2424
relevantPathNode(n)
2525
}
2626

27-
query predicate subpaths(PathNode arg, PathNode par, PathNode ret, PathNode out) {
28-
PathGraph::subpaths(arg, par, ret, out) and
27+
query predicate subpaths(
28+
Flow::PathNode arg, Flow::PathNode par, Flow::PathNode ret, Flow::PathNode out
29+
) {
30+
Flow::PathGraph::subpaths(arg, par, ret, out) and
2931
relevantPathNode(arg) and
3032
relevantPathNode(par) and
3133
relevantPathNode(ret) and
3234
relevantPathNode(out)
3335
}
3436

35-
class FlowConfig extends Configuration {
36-
FlowConfig() { this = "FlowConfig" }
37+
module FlowConfig implements DataFlow::ConfigSig {
38+
predicate isSource(DataFlow::Node source) { source.asExpr() instanceof Literal }
3739

38-
override predicate isSource(Node source) { source.asExpr() instanceof Literal }
39-
40-
override predicate isSink(Node sink) {
40+
predicate isSink(DataFlow::Node sink) {
4141
exists(LocalVariable decl | sink.asExpr() = decl.getInitializer())
4242
}
4343
}
4444

45-
from PathNode source, PathNode sink, FlowConfig config
46-
where config.hasFlowPath(source, sink)
45+
module Flow = DataFlow::Global<FlowConfig>;
46+
47+
from Flow::PathNode source, Flow::PathNode sink
48+
where Flow::flowPath(source, sink)
4749
select source, sink, sink, "$@", sink, sink.toString()

0 commit comments

Comments
 (0)