@@ -33,6 +33,34 @@ private class DefaultPathInjectionSink extends PathInjectionSink {
3333 DefaultPathInjectionSink ( ) { sinkNode ( this , "path-injection" ) }
3434}
3535
36+ /**
37+ * A sink that is a write to a global variable.
38+ */
39+ private class GlobalVariablePathInjectionSink extends PathInjectionSink {
40+ GlobalVariablePathInjectionSink ( ) {
41+ // value assigned to the sqlite3 global variable `sqlite3_temp_directory`
42+ // the sink should be the `DeclRefExpr` itself, but we don't currently have taint flow to globals.
43+ exists ( AssignExpr ae |
44+ ae .getDest ( ) .( DeclRefExpr ) .getDecl ( ) .( VarDecl ) .getName ( ) = "sqlite3_temp_directory" and
45+ ae .getSource ( ) = this .asExpr ( )
46+ )
47+ }
48+ }
49+
50+ /**
51+ * A sink that is an argument to an enum element.
52+ */
53+ private class EnumConstructorPathInjectionSink extends PathInjectionSink {
54+ EnumConstructorPathInjectionSink ( ) {
55+ // first argument to SQLite.swift's `Connection.Location.uri(_:parameters:)`
56+ exists ( ApplyExpr ae , EnumElementDecl decl |
57+ ae .getFunction ( ) .( MethodLookupExpr ) .getMember ( ) = decl and
58+ decl .hasQualifiedName ( "Connection.Location" , "uri" ) and
59+ this .asExpr ( ) = ae .getArgument ( 0 ) .getExpr ( )
60+ )
61+ }
62+ }
63+
3664private class DefaultPathInjectionBarrier extends PathInjectionBarrier {
3765 DefaultPathInjectionBarrier ( ) {
3866 // This is a simplified implementation.
@@ -130,6 +158,17 @@ private class PathInjectionSinks extends SinkModelCsv {
130158 ";Realm.Configuration;true;init(fileURL:inMemoryIdentifier:syncConfiguration:encryptionKey:readOnly:schemaVersion:migrationBlock:deleteRealmIfMigrationNeeded:shouldCompactOnLaunch:objectTypes:seedFilePath:);;;Argument[10];path-injection" ,
131159 ";Realm.Configuration;true;fileURL;;;PostUpdate;path-injection" ,
132160 ";Realm.Configuration;true;seedFilePath;;;PostUpdate;path-injection" ,
161+ // sqlite3
162+ ";;false;sqlite3_open(_:_:);;;Argument[0];path-injection" ,
163+ ";;false;sqlite3_open16(_:_:);;;Argument[0];path-injection" ,
164+ ";;false;sqlite3_open_v2(_:_:_:_:);;;Argument[0];path-injection" ,
165+ ";;false;sqlite3_database_file_object(_:);;;Argument[0];path-injection" ,
166+ ";;false;sqlite3_filename_database(_:);;;Argument[0];path-injection" ,
167+ ";;false;sqlite3_filename_journal(_:);;;Argument[0];path-injection" ,
168+ ";;false;sqlite3_filename_wal(_:);;;Argument[0];path-injection" ,
169+ ";;false;sqlite3_free_filename(_:);;;Argument[0];path-injection" ,
170+ // SQLite.swift
171+ ";Connection;true;init(_:readonly:);;;Argument[0];path-injection" ,
133172 ]
134173 }
135174}
0 commit comments