|
2 | 2 |
|
3 | 3 | struct URL { |
4 | 4 | init?(string: String) {} |
5 | | - |
| 5 | + init(fileURLWithPath path: String, isDirectory: Bool) {} |
6 | 6 | } |
7 | 7 |
|
8 | 8 | class NSURL { |
@@ -177,30 +177,30 @@ class SerializedDatabase { |
177 | 177 | init(path: String, configuration: Configuration = Configuration(), defaultLabel: String, purpose: String? = nil) {} |
178 | 178 | } |
179 | 179 |
|
| 180 | +// Realm |
180 | 181 |
|
| 182 | +class Realm { |
| 183 | +} |
181 | 184 |
|
182 | | - |
183 | | - |
184 | | - |
185 | | - |
186 | | - |
187 | | - |
188 | | - |
189 | | - |
190 | | - |
191 | | - |
192 | | - |
193 | | - |
194 | | - |
195 | | - |
196 | | - |
197 | | - |
198 | | - |
199 | | - |
200 | | - |
201 | | - |
202 | | - |
203 | | - |
| 185 | +extension Realm { |
| 186 | + struct Configuration { |
| 187 | + init( |
| 188 | + fileURL: URL? = URL(fileURLWithPath: "defaultFile", isDirectory: false), |
| 189 | + inMemoryIdentifier: String? = nil, |
| 190 | + syncConfiguration: Int = 0, |
| 191 | + encryptionKey: Data? = nil, |
| 192 | + readOnly: Bool = false, |
| 193 | + schemaVersion: UInt64 = 0, |
| 194 | + migrationBlock: Int = 0, |
| 195 | + deleteRealmIfMigrationNeeded: Bool = false, |
| 196 | + shouldCompactOnLaunch: Bool = false, |
| 197 | + objectTypes: Int = 0, |
| 198 | + seedFilePath: URL? = nil) { } |
| 199 | + |
| 200 | + var fileURL: URL? |
| 201 | + var seedFilePath: URL? |
| 202 | + } |
| 203 | +} |
204 | 204 |
|
205 | 205 | // --- tests --- |
206 | 206 |
|
@@ -308,18 +308,18 @@ func test() { |
308 | 308 | let _ = SerializedDatabase(path: remoteString, configuration: Configuration(), defaultLabel: "", purpose: nil) // $ hasPathInjection=208 |
309 | 309 | let _ = SerializedDatabase(path: "", configuration: Configuration(), defaultLabel: "", purpose: nil) // Safe |
310 | 310 |
|
| 311 | + // Realm |
311 | 312 |
|
| 313 | + _ = Realm.Configuration(fileURL: safeUrl) // GOOD |
| 314 | + _ = Realm.Configuration(fileURL: remoteUrl) // BAD [NOT DETECTED] |
| 315 | + _ = Realm.Configuration(seedFilePath: safeUrl) // GOOD |
| 316 | + _ = Realm.Configuration(seedFilePath: remoteUrl) // BAD [NOT DETECTED] |
312 | 317 |
|
313 | | - |
314 | | - |
315 | | - |
316 | | - |
317 | | - |
318 | | - |
319 | | - |
320 | | - |
321 | | - |
322 | | - |
| 318 | + var config = Realm.Configuration() // GOOD |
| 319 | + config.fileURL = safeUrl // GOOD |
| 320 | + config.fileURL = remoteUrl // BAD [NOT DETECTED] |
| 321 | + config.seedFilePath = safeUrl // GOOD |
| 322 | + config.seedFilePath = remoteUrl // BAD [NOT DETECTED] |
323 | 323 | } |
324 | 324 |
|
325 | 325 | func testSanitizers() { |
|
0 commit comments