Skip to content

Commit 698a9e2

Browse files
committed
Swift: Realm database support.
1 parent 3126fb9 commit 698a9e2

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

swift/ql/src/queries/Security/CWE-311/CleartextStorageDatabase.ql

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@ import codeql.swift.dataflow.DataFlow
1616
import codeql.swift.dataflow.TaintTracking
1717
import DataFlow::PathGraph
1818

19+
/**
20+
* An `Expr` that is stored in a local database.
21+
*/
1922
abstract class Stored extends Expr { }
2023

24+
/**
25+
* An `Expr` that is stored with the Core Data library.
26+
*/
2127
class CoreDataStore extends Stored {
2228
CoreDataStore() {
2329
// `content` arg to `NWConnection.send` is a sink
@@ -31,6 +37,31 @@ class CoreDataStore extends Stored {
3137
}
3238
}
3339

40+
/**
41+
* An `Expr` that is stored with the Realm database library.
42+
*/
43+
class RealmStore extends Stored {
44+
RealmStore() {
45+
// `object` arg to `Realm.add` is a sink
46+
exists(ClassDecl c, AbstractFunctionDecl f, CallExpr call |
47+
c.getName() = "Realm" and
48+
c.getAMember() = f and
49+
f.getName() = ["add(_:update:)"] and
50+
call.getFunction().(ApplyExpr).getStaticTarget() = f and
51+
call.getArgument(0).getExpr() = this
52+
)
53+
or
54+
// `value` arg to `Realm.create` is a sink
55+
exists(ClassDecl c, AbstractFunctionDecl f, CallExpr call |
56+
c.getName() = "Realm" and
57+
c.getAMember() = f and
58+
f.getName() = ["create(_:value:update:)"] and
59+
call.getFunction().(ApplyExpr).getStaticTarget() = f and
60+
call.getArgument(1).getExpr() = this
61+
)
62+
}
63+
}
64+
3465
/**
3566
* A taint configuration from sensitive information to expressions that are
3667
* transmitted over a network.

0 commit comments

Comments
 (0)