File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
swift/ql/lib/codeql/swift/security Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff 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 */
153161private 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
You can’t perform that action at this time.
0 commit comments