Skip to content

Commit 4bf717c

Browse files
committed
Swift: Use InlineFlowTest.qll in the data flow inline tests, so that we have less code duplication and can use flow labels.
1 parent d15c468 commit 4bf717c

File tree

3 files changed

+9
-51
lines changed

3 files changed

+9
-51
lines changed
Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
1-
import swift
1+
import TestUtilities.InlineFlowTest
22
import FlowConfig
3-
import TestUtilities.InlineExpectationsTest
43

5-
module TaintTest implements TestSig {
6-
string getARelevantTag() { result = "flow" }
4+
string customTaintFlowTag() { result = "flow" }
75

8-
predicate hasActualResult(Location location, string element, string tag, string value) {
9-
exists(DataFlow::Node source, DataFlow::Node sink, Expr sinkExpr |
10-
TestFlow::flow(source, sink) and
11-
sinkExpr = sink.asExpr() and
12-
location = sinkExpr.getLocation() and
13-
element = sinkExpr.toString() and
14-
tag = "flow" and
15-
value = source.asExpr().getLocation().getStartLine().toString()
16-
)
17-
}
18-
}
19-
20-
import MakeTest<TaintTest>
6+
import FlowTest<DefaultFlowConfig, NoFlowConfig, customTaintFlowTag/0, defaultTaintFlowTag/0>
Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
1-
import swift
1+
import TestUtilities.InlineFlowTest
22
import Taint
3-
import TestUtilities.InlineExpectationsTest
43

5-
module TaintTest implements TestSig {
6-
string getARelevantTag() { result = "tainted" }
4+
string customTaintFlowTag() { result = "tainted" }
75

8-
predicate hasActualResult(Location location, string element, string tag, string value) {
9-
exists(DataFlow::Node source, DataFlow::Node sink, Expr sinkExpr |
10-
TestFlow::flow(source, sink) and
11-
sinkExpr = sink.asExpr() and
12-
location = sinkExpr.getLocation() and
13-
element = sinkExpr.toString() and
14-
tag = "tainted" and
15-
value = source.asExpr().getLocation().getStartLine().toString()
16-
)
17-
}
18-
}
19-
20-
import MakeTest<TaintTest>
6+
import FlowTest<NoFlowConfig, DefaultFlowConfig, defaultValueFlowTag/0, customTaintFlowTag/0>
Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
1-
import swift
1+
import TestUtilities.InlineFlowTest
22
import Taint
3-
import TestUtilities.InlineExpectationsTest
43

5-
module TaintTest implements TestSig {
6-
string getARelevantTag() { result = "tainted" }
4+
string customTaintFlowTag() { result = "tainted" }
75

8-
predicate hasActualResult(Location location, string element, string tag, string value) {
9-
exists(DataFlow::Node source, DataFlow::Node sink, Expr sinkExpr |
10-
TestFlow::flow(source, sink) and
11-
sinkExpr = sink.asExpr() and
12-
location = sinkExpr.getLocation() and
13-
element = sinkExpr.toString() and
14-
tag = "tainted" and
15-
value = source.asExpr().getLocation().getStartLine().toString()
16-
)
17-
}
18-
}
19-
20-
import MakeTest<TaintTest>
6+
import FlowTest<NoFlowConfig, DefaultFlowConfig, defaultValueFlowTag/0, customTaintFlowTag/0>

0 commit comments

Comments
 (0)