Skip to content

Commit 40aed29

Browse files
committed
Refactor Java Integration tests to new API
1 parent 4bf03e7 commit 40aed29

File tree

3 files changed

+20
-20
lines changed
  • java/ql/integration-tests/all-platforms/kotlin
    • default-parameter-mad-flow
    • kotlin-interface-inherited-default
    • kotlin_java_static_fields

3 files changed

+20
-20
lines changed

java/ql/integration-tests/all-platforms/kotlin/default-parameter-mad-flow/test.ql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@ import semmle.code.java.dataflow.TaintTracking
33
import TestUtilities.InlineExpectationsTest
44
private import semmle.code.java.dataflow.ExternalFlow
55

6-
class Config extends TaintTracking::Configuration {
7-
Config() { this = "Config" }
8-
9-
override predicate isSource(DataFlow::Node n) {
6+
module Config implements DataFlow::ConfigSig {
7+
predicate isSource(DataFlow::Node n) {
108
n.asExpr().(MethodAccess).getCallee().getName() = "source"
119
or
1210
sourceNode(n, "kotlinMadFlowTest")
1311
}
1412

15-
override predicate isSink(DataFlow::Node n) {
13+
predicate isSink(DataFlow::Node n) {
1614
n.asExpr().(Argument).getCall().getCallee().getName() = "sink"
1715
or
1816
sinkNode(n, "kotlinMadFlowTest")
1917
}
2018
}
2119

20+
module Flow = TaintTracking::Global<Config>;
21+
2222
class InlineFlowTest extends InlineExpectationsTest {
2323
InlineFlowTest() { this = "HasFlowTest" }
2424

2525
override string getARelevantTag() { result = "flow" }
2626

2727
override predicate hasActualResult(Location location, string element, string tag, string value) {
2828
tag = "flow" and
29-
exists(DataFlow::Node sink, Config c | c.hasFlowTo(sink) |
29+
exists(DataFlow::Node sink | Flow::flowTo(sink) |
3030
sink.getLocation() = location and
3131
element = sink.toString() and
3232
value = ""

java/ql/integration-tests/all-platforms/kotlin/kotlin-interface-inherited-default/test.ql

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ query predicate superAccesses(
1919
enclosingType = enclosingCallable.getDeclaringType()
2020
}
2121

22-
class Config extends DataFlow::Configuration {
23-
Config() { this = "testconfig" }
24-
25-
override predicate isSource(DataFlow::Node x) {
22+
module Config implements DataFlow::ConfigSig {
23+
predicate isSource(DataFlow::Node x) {
2624
x.asExpr() instanceof IntegerLiteral and x.getEnclosingCallable().fromSource()
2725
}
2826

29-
override predicate isSink(DataFlow::Node x) {
27+
predicate isSink(DataFlow::Node x) {
3028
x.asExpr().(Argument).getCall().getCallee().getName() = "sink"
3129
}
3230
}
3331

34-
from Config c, DataFlow::Node source, DataFlow::Node sink
35-
where c.hasFlow(source, sink)
32+
module Flow = DataFlow::Global<Config>;
33+
34+
from DataFlow::Node source, DataFlow::Node sink
35+
where Flow::flow(source, sink)
3636
select source, sink

java/ql/integration-tests/all-platforms/kotlin/kotlin_java_static_fields/test.ql

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ import java
22
import semmle.code.java.dataflow.DataFlow
33
import DataFlow::PathGraph
44

5-
class Config extends DataFlow::Configuration {
6-
Config() { this = "Config" }
5+
module Config implements DataFlow::ConfigSig {
6+
predicate isSource(DataFlow::Node n) { n.asExpr().(StringLiteral).getValue() = "taint" }
77

8-
override predicate isSource(DataFlow::Node n) { n.asExpr().(StringLiteral).getValue() = "taint" }
9-
10-
override predicate isSink(DataFlow::Node n) {
8+
predicate isSink(DataFlow::Node n) {
119
n.asExpr().(Argument).getCall().getCallee().getName() = "sink"
1210
}
1311
}
1412

15-
from DataFlow::PathNode source, DataFlow::PathNode sink, Config c
16-
where c.hasFlowPath(source, sink)
13+
module Flow = DataFlow::Global<Config>;
14+
15+
from Flow::PathNode source, Flow::PathNode sink
16+
where Flow::flowPath(source, sink)
1717
select source, source, sink, "flow path"

0 commit comments

Comments
 (0)