@@ -13,7 +13,7 @@ import codeql.swift.security.CleartextStorageDatabaseExtensions
13
13
* A taint configuration from sensitive information to expressions that are
14
14
* transmitted over a network.
15
15
*/
16
- class CleartextStorageConfig extends TaintTracking:: Configuration {
16
+ deprecated class CleartextStorageConfig extends TaintTracking:: Configuration {
17
17
CleartextStorageConfig ( ) { this = "CleartextStorageConfig" }
18
18
19
19
override predicate isSource ( DataFlow:: Node node ) { node .asExpr ( ) instanceof SensitiveExpr }
@@ -48,3 +48,44 @@ class CleartextStorageConfig extends TaintTracking::Configuration {
48
48
super .allowImplicitRead ( node , c )
49
49
}
50
50
}
51
+
52
+ /**
53
+ * A taint configuration from sensitive information to expressions that are
54
+ * transmitted over a network.
55
+ */
56
+ module CleartextStorageConfig implements DataFlow:: ConfigSig {
57
+ predicate isSource ( DataFlow:: Node node ) { node .asExpr ( ) instanceof SensitiveExpr }
58
+
59
+ predicate isSink ( DataFlow:: Node node ) { node instanceof CleartextStorageDatabaseSink }
60
+
61
+ predicate isBarrier ( DataFlow:: Node sanitizer ) {
62
+ sanitizer instanceof CleartextStorageDatabaseSanitizer
63
+ }
64
+
65
+ predicate isAdditionalFlowStep ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
66
+ any ( CleartextStorageDatabaseAdditionalTaintStep s ) .step ( nodeFrom , nodeTo )
67
+ }
68
+
69
+ predicate isBarrierIn ( DataFlow:: Node node ) {
70
+ // make sources barriers so that we only report the closest instance
71
+ isSource ( node )
72
+ }
73
+
74
+ predicate allowImplicitRead ( DataFlow:: Node node , DataFlow:: ContentSet c ) {
75
+ // flow out from fields of an `NSManagedObject` or `RealmSwiftObject` at the sink,
76
+ // for example in `realmObj.data = sensitive`.
77
+ isSink ( node ) and
78
+ exists ( NominalTypeDecl d , Decl cx |
79
+ d .getType ( ) .getABaseType * ( ) .getUnderlyingType ( ) .getName ( ) =
80
+ [ "NSManagedObject" , "RealmSwiftObject" ] and
81
+ cx .asNominalTypeDecl ( ) = d and
82
+ c .getAReadContent ( ) .( DataFlow:: Content:: FieldContent ) .getField ( ) = cx .getAMember ( )
83
+ )
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Detect taint flow of sensitive information to expressions that are
89
+ * transmitted over a network.
90
+ */
91
+ module CleartextStorageFlow = TaintTracking:: Global< CleartextStorageConfig > ;
0 commit comments