Skip to content

Commit c3577b3

Browse files
committed
Swift: Clean up logic.
1 parent e4da8da commit c3577b3

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

swift/ql/test/TestUtilities/InlineFlowTest.qll

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,7 @@ string defaultTaintFlowTag() { result = "hasTaintFlow" }
8181

8282
private string getSourceArgString(DataFlow::Node src) {
8383
defaultSource(src) and
84-
(
85-
src.asExpr().(CallExpr).getAnArgument().getExpr().(StringLiteralExpr).getValue() = result
86-
or
87-
not src.asExpr().(CallExpr).getAnArgument().getExpr() instanceof StringLiteralExpr and
88-
result = src.getLocation().getStartLine().toString()
89-
)
84+
src.asExpr().(CallExpr).getAnArgument().getExpr().(StringLiteralExpr).getValue() = result
9085
}
9186

9287
module FlowTest<
@@ -105,7 +100,9 @@ module FlowTest<
105100
exists(DataFlow::Node src, DataFlow::Node sink | ValueFlow::flow(src, sink) |
106101
sink.getLocation() = location and
107102
element = sink.toString() and
108-
if exists(getSourceArgString(src)) then value = getSourceArgString(src) else value = ""
103+
if exists(getSourceArgString(src))
104+
then value = getSourceArgString(src)
105+
else value = src.getLocation().getStartLine().toString()
109106
)
110107
or
111108
tag = taintFlowTag() and
@@ -114,7 +111,9 @@ module FlowTest<
114111
|
115112
sink.getLocation() = location and
116113
element = sink.toString() and
117-
if exists(getSourceArgString(src)) then value = getSourceArgString(src) else value = ""
114+
if exists(getSourceArgString(src))
115+
then value = getSourceArgString(src)
116+
else value = src.getLocation().getStartLine().toString()
118117
)
119118
}
120119
}

0 commit comments

Comments
 (0)