Skip to content

Commit 3a3d9bc

Browse files
committed
Swift: Rewrite inline expectation tests to use the parameterized module
1 parent 2276890 commit 3a3d9bc

16 files changed

+56
-40
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
failures
2+
testFailures

swift/ql/test/library-tests/dataflow/dataflow/DataFlowInline.ql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ import swift
22
import FlowConfig
33
import TestUtilities.InlineExpectationsTest
44

5-
class TaintTest extends InlineExpectationsTest {
6-
TaintTest() { this = "DataFlowTest" }
5+
module TaintTest implements TestSig {
6+
string getARelevantTag() { result = "flow" }
77

8-
override string getARelevantTag() { result = "flow" }
9-
10-
override predicate hasActualResult(Location location, string element, string tag, string value) {
8+
predicate hasActualResult(Location location, string element, string tag, string value) {
119
exists(DataFlow::Node source, DataFlow::Node sink, Expr sinkExpr |
1210
TestFlow::flow(source, sink) and
1311
sinkExpr = sink.asExpr() and
@@ -18,3 +16,5 @@ class TaintTest extends InlineExpectationsTest {
1816
)
1917
}
2018
}
19+
20+
import MakeTest<TaintTest>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
failures
2+
testFailures

swift/ql/test/library-tests/dataflow/flowsources/FlowSourcesInline.ql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@ string describe(FlowSource source) {
88
source instanceof LocalFlowSource and result = "local"
99
}
1010

11-
class FlowSourcesTest extends InlineExpectationsTest {
12-
FlowSourcesTest() { this = "FlowSourcesTest" }
11+
module FlowSourcesTest implements TestSig {
12+
string getARelevantTag() { result = "source" }
1313

14-
override string getARelevantTag() { result = "source" }
15-
16-
override predicate hasActualResult(Location location, string element, string tag, string value) {
14+
predicate hasActualResult(Location location, string element, string tag, string value) {
1715
exists(FlowSource source |
1816
location = source.getLocation() and
1917
location.getFile().getBaseName() != "" and
@@ -23,3 +21,5 @@ class FlowSourcesTest extends InlineExpectationsTest {
2321
)
2422
}
2523
}
24+
25+
import MakeTest<FlowSourcesTest>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
failures
2+
testFailures

swift/ql/test/library-tests/dataflow/taint/core/TaintInline.ql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ import swift
22
import Taint
33
import TestUtilities.InlineExpectationsTest
44

5-
class TaintTest extends InlineExpectationsTest {
6-
TaintTest() { this = "TaintTest" }
5+
module TaintTest implements TestSig {
6+
string getARelevantTag() { result = "tainted" }
77

8-
override string getARelevantTag() { result = "tainted" }
9-
10-
override predicate hasActualResult(Location location, string element, string tag, string value) {
8+
predicate hasActualResult(Location location, string element, string tag, string value) {
119
exists(DataFlow::Node source, DataFlow::Node sink, Expr sinkExpr |
1210
TestFlow::flow(source, sink) and
1311
sinkExpr = sink.asExpr() and
@@ -18,3 +16,5 @@ class TaintTest extends InlineExpectationsTest {
1816
)
1917
}
2018
}
19+
20+
import MakeTest<TaintTest>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
failures
2+
testFailures

swift/ql/test/library-tests/dataflow/taint/libraries/TaintInline.ql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ import swift
22
import Taint
33
import TestUtilities.InlineExpectationsTest
44

5-
class TaintTest extends InlineExpectationsTest {
6-
TaintTest() { this = "TaintTest" }
5+
module TaintTest implements TestSig {
6+
string getARelevantTag() { result = "tainted" }
77

8-
override string getARelevantTag() { result = "tainted" }
9-
10-
override predicate hasActualResult(Location location, string element, string tag, string value) {
8+
predicate hasActualResult(Location location, string element, string tag, string value) {
119
exists(DataFlow::Node source, DataFlow::Node sink, Expr sinkExpr |
1210
TestFlow::flow(source, sink) and
1311
sinkExpr = sink.asExpr() and
@@ -18,3 +16,5 @@ class TaintTest extends InlineExpectationsTest {
1816
)
1917
}
2018
}
19+
20+
import MakeTest<TaintTest>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
failures
2+
testFailures

swift/ql/test/query-tests/Security/CWE-022/PathInjectionTest.ql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ import codeql.swift.dataflow.FlowSources
44
import codeql.swift.security.PathInjectionQuery
55
import TestUtilities.InlineExpectationsTest
66

7-
class PathInjectionTest extends InlineExpectationsTest {
8-
PathInjectionTest() { this = "PathInjectionTest" }
7+
module PathInjectionTest implements TestSig {
8+
string getARelevantTag() { result = "hasPathInjection" }
99

10-
override string getARelevantTag() { result = "hasPathInjection" }
11-
12-
override predicate hasActualResult(Location location, string element, string tag, string value) {
10+
predicate hasActualResult(Location location, string element, string tag, string value) {
1311
exists(DataFlow::Node source, DataFlow::Node sink |
1412
PathInjectionFlow::flow(source, sink) and
1513
location = sink.getLocation() and
@@ -20,3 +18,5 @@ class PathInjectionTest extends InlineExpectationsTest {
2018
)
2119
}
2220
}
21+
22+
import MakeTest<PathInjectionTest>

0 commit comments

Comments
 (0)