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 1
1
private import codeql.swift.generated.decl.AbstractFunctionDecl
2
2
private import codeql.swift.elements.decl.MethodDecl
3
3
4
+ /**
5
+ * A function.
6
+ */
4
7
class AbstractFunctionDecl extends Generated:: AbstractFunctionDecl {
5
8
override string toString ( ) { result = this .getName ( ) }
6
9
7
10
/**
8
11
* Holds if this function is called `funcName`.
9
12
*/
10
13
predicate hasName ( string funcName ) { this .getName ( ) = funcName }
14
+ }
11
15
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 }
19
21
}
Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ private Decl getAMember(IterableDeclContext ctx) {
9
9
)
10
10
}
11
11
12
+ /**
13
+ * A function that is a member of a class, struct, enum or protocol.
14
+ */
12
15
class MethodDecl extends AbstractFunctionDecl {
13
16
MethodDecl ( ) {
14
17
this = getAMember ( any ( ClassDecl c ) )
Original file line number Diff line number Diff line change @@ -29,7 +29,8 @@ class CApiSqlSink extends SqlSink {
29
29
// `sqlite3_exec` and variants of `sqlite3_prepare`.
30
30
exists ( CallExpr call |
31
31
call .getStaticTarget ( )
32
- .hasGlobalName ( [
32
+ .( FreeFunctionDecl )
33
+ .hasName ( [
33
34
"sqlite3_exec(_:_:_:_:_:)" , "sqlite3_prepare(_:_:_:_:_:)" ,
34
35
"sqlite3_prepare_v2(_:_:_:_:_:)" , "sqlite3_prepare_v3(_:_:_:_:_:_:)" ,
35
36
"sqlite3_prepare16(_:_:_:_:_:)" , "sqlite3_prepare16_v2(_:_:_:_:_:)" ,
You can’t perform that action at this time.
0 commit comments