Skip to content

Commit 17dd119

Browse files
committed
Swift: Fix performance.
1 parent 4bfdb76 commit 17dd119

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

swift/ql/lib/codeql/swift/security/SqlInjectionExtensions.qll

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,23 @@ private class GrdbDefaultSqlInjectionSink extends SqlInjectionSink {
147147
}
148148
}
149149

150+
/**
151+
* A parameter that might be executed as SQL.
152+
*/
153+
pragma[noinline] predicate sqlLikeHeuristic(Callable f, int ix, ParamDecl pd) {
154+
pd.getName() = "sql" and
155+
pd = f.getParam(ix)
156+
}
157+
150158
/**
151159
* An SQL injection sink that is determined by imprecise methods.
152160
*/
153161
private class HeuristicSqlInjectionSink extends SqlInjectionSink {
154162
HeuristicSqlInjectionSink() {
155163
// by parameter name
156-
exists(CallExpr ce, int ix, ParamDecl pd |
157-
pd.getName() = "sql" and
158-
pd = ce.getStaticTarget().getParam(ix) and
164+
exists(CallExpr ce, Callable f, int ix |
165+
sqlLikeHeuristic(f, ix, _) and
166+
f = ce.getStaticTarget() and
159167
this.asExpr() = ce.getArgument(ix).getExpr()
160168
)
161169
or

0 commit comments

Comments
 (0)