File tree Expand file tree Collapse file tree 3 files changed +14
-8
lines changed
lib/codeql/swift/elements/decl
src/queries/Security/CWE-089 Expand file tree Collapse file tree 3 files changed +14
-8
lines changed Original file line number Diff line number Diff line change 11private import codeql.swift.generated.decl.AbstractFunctionDecl
22private import codeql.swift.elements.decl.MethodDecl
33
4+ /**
5+ * A function.
6+ */
47class AbstractFunctionDecl extends Generated:: AbstractFunctionDecl {
58 override string toString ( ) { result = this .getName ( ) }
69
710 /**
811 * Holds if this function is called `funcName`.
912 */
1013 predicate hasName ( string funcName ) { this .getName ( ) = funcName }
14+ }
1115
12- /**
13- * Holds if this is a global (non-member) function called `funcName`.
14- */
15- predicate hasGlobalName ( string funcName ) {
16- this .hasName ( funcName ) and
17- not this instanceof MethodDecl
18- }
16+ /**
17+ * A free (non-member) function.
18+ */
19+ class FreeFunctionDecl extends AbstractFunctionDecl {
20+ FreeFunctionDecl ( ) { not this instanceof MethodDecl }
1921}
Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ private Decl getAMember(IterableDeclContext ctx) {
99 )
1010}
1111
12+ /**
13+ * A function that is a member of a class, struct, enum or protocol.
14+ */
1215class MethodDecl extends AbstractFunctionDecl {
1316 MethodDecl ( ) {
1417 this = getAMember ( any ( ClassDecl c ) )
Original file line number Diff line number Diff line change @@ -29,7 +29,8 @@ class CApiSqlSink extends SqlSink {
2929 // `sqlite3_exec` and variants of `sqlite3_prepare`.
3030 exists ( CallExpr call |
3131 call .getStaticTarget ( )
32- .hasGlobalName ( [
32+ .( FreeFunctionDecl )
33+ .hasName ( [
3334 "sqlite3_exec(_:_:_:_:_:)" , "sqlite3_prepare(_:_:_:_:_:)" ,
3435 "sqlite3_prepare_v2(_:_:_:_:_:)" , "sqlite3_prepare_v3(_:_:_:_:_:_:)" ,
3536 "sqlite3_prepare16(_:_:_:_:_:)" , "sqlite3_prepare16_v2(_:_:_:_:_:)" ,
You can’t perform that action at this time.
0 commit comments