Skip to content

Commit b6b7e15

Browse files
committed
Make taint tracking tests use new API
1 parent c11da5b commit b6b7e15

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

go/ql/test/library-tests/semmle/go/frameworks/Revel/test.ql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ class Sink extends DataFlow::Node {
77
}
88
}
99

10-
class TestConfig extends TaintTracking::Configuration {
11-
TestConfig() { this = "testconfig" }
10+
private module TestConfig implements DataFlow::ConfigSig {
11+
predicate isSource(DataFlow::Node source) { source instanceof UntrustedFlowSource }
1212

13-
override predicate isSource(DataFlow::Node source) { source instanceof UntrustedFlowSource }
14-
15-
override predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
13+
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
1614
}
1715

16+
private module TestFlow = TaintTracking::Global<TestConfig>;
17+
1818
module MissingDataFlowTest implements TestSig {
1919
string getARelevantTag() { result = "noflow" }
2020

2121
predicate hasActualResult(Location location, string element, string tag, string value) {
2222
tag = "noflow" and
2323
value = "" and
2424
exists(Sink sink |
25-
not any(TestConfig c).hasFlow(_, sink) and
25+
not TestFlow::flowTo(sink) and
2626
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
2727
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
2828
element = sink.toString()

go/ql/test/library-tests/semmle/go/frameworks/StdlibTaintFlow/StdlibTaintFlow.ql

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,24 @@ predicate callArgumentisSink(DataFlow::Node sink, DataFlow::CallNode call) {
2525
)
2626
}
2727

28-
class FlowConf extends TaintTracking::Configuration {
29-
FlowConf() { this = "FlowConf" }
28+
module Config implements DataFlow::ConfigSig {
29+
predicate isSource(DataFlow::Node source) { callResultisSource(source, _) }
3030

31-
override predicate isSource(DataFlow::Node source) { callResultisSource(source, _) }
32-
33-
override predicate isSink(DataFlow::Node sink) { callArgumentisSink(sink, _) }
31+
predicate isSink(DataFlow::Node sink) { callArgumentisSink(sink, _) }
3432
}
3533

34+
module Flow = TaintTracking::Global<Config>;
35+
3636
/**
3737
* True if the result of the provided sourceCall flows to the corresponding sink,
3838
* both marked by the same numeric first argument.
3939
*/
4040
predicate flowsToSink(DataFlow::CallNode sourceCall) {
41-
exists(
42-
FlowConf cfg, DataFlow::PathNode source, DataFlow::PathNode sink, DataFlow::CallNode sinkCall
43-
|
44-
cfg.hasFlowPath(source, sink) and
41+
exists(DataFlow::Node source, DataFlow::Node sink, DataFlow::CallNode sinkCall |
42+
Flow::flow(source, sink) and
4543
(
46-
callResultisSource(source.getNode(), sourceCall) and
47-
callArgumentisSink(sink.getNode(), sinkCall) and
44+
callResultisSource(source, sourceCall) and
45+
callArgumentisSink(sink, sinkCall) and
4846
sourceCall.getArgument(0).getIntValue() = sinkCall.getArgument(0).getIntValue()
4947
)
5048
)

0 commit comments

Comments
 (0)