Skip to content

Commit 4dd3ea3

Browse files
RasmusWLaschackmull
authored andcommitted
Python: Update tests to new dataflow lib
Avoids some deprecation warnings :)
1 parent 67f0529 commit 4dd3ea3

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

python/ql/test/experimental/dataflow/basic/callGraph.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import experimental.dataflow.callGraphConfig
22

33
from DataFlow::Node source, DataFlow::Node sink
44
where
5-
exists(CallGraphConfig cfg | cfg.hasFlow(source, sink)) and
5+
CallGraphFlow::flow(source, sink) and
66
exists(source.getLocation().getFile().getRelativePath()) and
77
exists(sink.getLocation().getFile().getRelativePath())
88
select source, sink

python/ql/test/experimental/dataflow/basic/callGraphSinks.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import experimental.dataflow.callGraphConfig
22

33
from DataFlow::Node sink
44
where
5-
exists(CallGraphConfig cfg | cfg.isSink(sink)) and
5+
CallGraphConfig::isSink(sink) and
66
exists(sink.getLocation().getFile().getRelativePath())
77
select sink

python/ql/test/experimental/dataflow/basic/callGraphSources.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import experimental.dataflow.callGraphConfig
22

33
from DataFlow::Node source
44
where
5-
exists(CallGraphConfig cfg | cfg.isSource(source)) and
5+
CallGraphConfig::isSource(source) and
66
exists(source.getLocation().getFile().getRelativePath())
77
select source

python/ql/test/experimental/dataflow/callGraphConfig.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ private import semmle.python.dataflow.new.internal.DataFlowPrivate as DataFlowPr
55
/**
66
* A configuration to find the call graph edges.
77
*/
8-
class CallGraphConfig extends DataFlow::Configuration {
9-
CallGraphConfig() { this = "CallGraphConfig" }
10-
11-
override predicate isSource(DataFlow::Node node) {
8+
module CallGraphConfig implements DataFlow::ConfigSig {
9+
predicate isSource(DataFlow::Node node) {
1210
node instanceof DataFlowPrivate::ReturnNode
1311
or
1412
node instanceof DataFlow::ArgumentNode
1513
}
1614

17-
override predicate isSink(DataFlow::Node node) {
15+
predicate isSink(DataFlow::Node node) {
1816
node instanceof DataFlowPrivate::OutNode
1917
or
2018
node instanceof DataFlow::ParameterNode
2119
}
2220
}
21+
22+
module CallGraphFlow = DataFlow::Global<CallGraphConfig>;

python/ql/test/library-tests/frameworks/modeling-example/NaiveModel.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
private import python
66
private import semmle.python.dataflow.new.DataFlow
77
private import semmle.python.dataflow.new.TaintTracking
8-
import DataFlow::PathGraph
8+
import SharedFlow::PathGraph
99
import SharedCode
1010

1111
class MyClassGetValueAdditionalTaintStep extends TaintTracking::AdditionalTaintStep {
@@ -18,7 +18,7 @@ class MyClassGetValueAdditionalTaintStep extends TaintTracking::AdditionalTaintS
1818
}
1919
}
2020

21-
from SharedConfig config, DataFlow::PathNode source, DataFlow::PathNode sink
22-
where config.hasFlowPath(source, sink)
21+
from SharedFlow::PathNode source, SharedFlow::PathNode sink
22+
where SharedFlow::flowPath(source, sink)
2323
select sink.getNode(), source, sink,
2424
"test flow (naive): " + source.getNode().asCfgNode().getScope().getName()

python/ql/test/library-tests/frameworks/modeling-example/ProperModel.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
private import python
66
private import semmle.python.dataflow.new.DataFlow
77
private import semmle.python.dataflow.new.TaintTracking
8-
import DataFlow::PathGraph
8+
import SharedFlow::PathGraph
99
import SharedCode
1010

1111
class MyClassGetValueAdditionalTaintStep extends TaintTracking::AdditionalTaintStep {
@@ -20,7 +20,7 @@ class MyClassGetValueAdditionalTaintStep extends TaintTracking::AdditionalTaintS
2020
}
2121
}
2222

23-
from SharedConfig config, DataFlow::PathNode source, DataFlow::PathNode sink
24-
where config.hasFlowPath(source, sink)
23+
from SharedFlow::PathNode source, SharedFlow::PathNode sink
24+
where SharedFlow::flowPath(source, sink)
2525
select sink.getNode(), source, sink,
2626
"test flow (proper): " + source.getNode().asCfgNode().getScope().getName()

python/ql/test/library-tests/frameworks/modeling-example/SharedCode.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ class SourceCall extends DataFlow::Node, MyClass {
2222
SourceCall() { this.asCfgNode().(CallNode).getFunction().(NameNode).getId() = "source" }
2323
}
2424

25-
class SharedConfig extends TaintTracking::Configuration {
26-
SharedConfig() { this = "SharedConfig" }
25+
private module SharedConfig implements DataFlow::ConfigSig {
26+
predicate isSource(DataFlow::Node source) { source instanceof SourceCall }
2727

28-
override predicate isSource(DataFlow::Node source) { source instanceof SourceCall }
29-
30-
override predicate isSink(DataFlow::Node sink) {
28+
predicate isSink(DataFlow::Node sink) {
3129
exists(CallNode call |
3230
call.getFunction().(NameNode).getId() = "sink" and
3331
call.getArg(0) = sink.asCfgNode()
3432
)
3533
}
3634
}
35+
36+
module SharedFlow = TaintTracking::Global<SharedConfig>;

0 commit comments

Comments
 (0)