2
2
3
3
struct URL {
4
4
init ? ( string: String ) { }
5
+
5
6
}
6
7
7
8
class NSURL {
@@ -176,6 +177,31 @@ class SerializedDatabase {
176
177
init ( path: String , configuration: Configuration = Configuration ( ) , defaultLabel: String , purpose: String ? = nil ) { }
177
178
}
178
179
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
179
205
// --- tests ---
180
206
181
207
func test( ) {
@@ -185,100 +211,115 @@ func test() {
185
211
let safeUrl = URL ( string: " " ) !
186
212
let safeNsUrl = NSURL ( string: " " ) !
187
213
188
- Data ( " " ) . write ( to: remoteUrl, options: [ ] ) // $ hasPathInjection=182
214
+ Data ( " " ) . write ( to: remoteUrl, options: [ ] ) // $ hasPathInjection=208
189
215
190
216
let nsData = NSData ( )
191
- let _ = nsData. write ( to: remoteUrl, atomically: false ) // $ hasPathInjection=182
192
- nsData. write ( to: remoteUrl, options: [ ] ) // $ hasPathInjection=182
193
- let _ = nsData. write ( toFile: remoteString, atomically: false ) // $ hasPathInjection=182
194
- nsData. write ( toFile: remoteString, options: [ ] ) // $ hasPathInjection=182
217
+ let _ = nsData. write ( to: remoteUrl, atomically: false ) // $ hasPathInjection=208
218
+ nsData. write ( to: remoteUrl, options: [ ] ) // $ hasPathInjection=208
219
+ let _ = nsData. write ( toFile: remoteString, atomically: false ) // $ hasPathInjection=208
220
+ nsData. write ( toFile: remoteString, options: [ ] ) // $ hasPathInjection=208
195
221
196
222
let fm = FileManager ( )
197
- let _ = fm. contentsOfDirectory ( at: remoteUrl, includingPropertiesForKeys: [ ] , options: [ ] ) // $ hasPathInjection=182
198
- let _ = fm. contentsOfDirectory ( atPath: remoteString) // $ hasPathInjection=182
199
- let _ = fm. enumerator ( at: remoteUrl, includingPropertiesForKeys: [ ] , options: [ ] , errorHandler: nil ) // $ hasPathInjection=182
200
- let _ = fm. enumerator ( atPath: remoteString) // $ hasPathInjection=182
201
- let _ = fm. subpathsOfDirectory ( atPath: remoteString) // $ hasPathInjection=182
202
- let _ = fm. subpaths ( atPath: remoteString) // $ hasPathInjection=182
203
- fm. createDirectory ( at: remoteUrl, withIntermediateDirectories: false , attributes: [ : ] ) // $ hasPathInjection=182
204
- let _ = fm. createDirectory ( atPath: remoteString, attributes: [ : ] ) // $ hasPathInjection=182
205
- let _ = fm. createFile ( atPath: remoteString, contents: nil , attributes: [ : ] ) // $ hasPathInjection=182
206
- fm. removeItem ( at: remoteUrl) // $ hasPathInjection=182
207
- fm. removeItem ( atPath: remoteString) // $ hasPathInjection=182
208
- fm. trashItem ( at: remoteUrl, resultingItemURL: AutoreleasingUnsafeMutablePointer < NSURL ? > ( ) ) // $ hasPathInjection=182
209
- let _ = fm. replaceItemAt ( remoteUrl, withItemAt: safeUrl, backupItemName: nil , options: [ ] ) // $ hasPathInjection=182
210
- let _ = fm. replaceItemAt ( safeUrl, withItemAt: remoteUrl, backupItemName: nil , options: [ ] ) // $ hasPathInjection=182
211
- fm. replaceItem ( at: remoteUrl, withItemAt: safeUrl, backupItemName: nil , options: [ ] , resultingItemURL: AutoreleasingUnsafeMutablePointer < NSURL ? > ( ) ) // $ hasPathInjection=182
212
- fm. replaceItem ( at: safeUrl, withItemAt: remoteUrl, backupItemName: nil , options: [ ] , resultingItemURL: AutoreleasingUnsafeMutablePointer < NSURL ? > ( ) ) // $ hasPathInjection=182
213
- fm. copyItem ( at: remoteUrl, to: safeUrl) // $ hasPathInjection=182
214
- fm. copyItem ( at: safeUrl, to: remoteUrl) // $ hasPathInjection=182
215
- fm. copyItem ( atPath: remoteString, toPath: " " ) // $ hasPathInjection=182
216
- fm. copyItem ( atPath: " " , toPath: remoteString) // $ hasPathInjection=182
217
- fm. moveItem ( at: remoteUrl, to: safeUrl) // $ hasPathInjection=182
218
- fm. moveItem ( at: safeUrl, to: remoteUrl) // $ hasPathInjection=182
219
- fm. moveItem ( atPath: remoteString, toPath: " " ) // $ hasPathInjection=182
220
- fm. moveItem ( atPath: " " , toPath: remoteString) // $ hasPathInjection=182
221
- fm. createSymbolicLink ( at: remoteUrl, withDestinationURL: safeUrl) // $ hasPathInjection=182
222
- fm. createSymbolicLink ( at: safeUrl, withDestinationURL: remoteUrl) // $ hasPathInjection=182
223
- fm. createSymbolicLink ( atPath: remoteString, withDestinationPath: " " ) // $ hasPathInjection=182
224
- fm. createSymbolicLink ( atPath: " " , withDestinationPath: remoteString) // $ hasPathInjection=182
225
- fm. linkItem ( at: remoteUrl, to: safeUrl) // $ hasPathInjection=182
226
- fm. linkItem ( at: safeUrl, to: remoteUrl) // $ hasPathInjection=182
227
- fm. linkItem ( atPath: remoteString, toPath: " " ) // $ hasPathInjection=182
228
- fm. linkItem ( atPath: " " , toPath: remoteString) // $ hasPathInjection=182
229
- let _ = fm. destinationOfSymbolicLink ( atPath: remoteString) // $ hasPathInjection=182
230
- let _ = fm. fileExists ( atPath: remoteString) // $ hasPathInjection=182
231
- let _ = fm. fileExists ( atPath: remoteString, isDirectory: UnsafeMutablePointer< ObjCBool> . init( bitPattern: 0 ) ) // $ hasPathInjection=182
232
- fm. setAttributes ( [ : ] , ofItemAtPath: remoteString) // $ hasPathInjection=182
233
- let _ = fm. contents ( atPath: remoteString) // $ hasPathInjection=182
234
- let _ = fm. contentsEqual ( atPath: remoteString, andPath: " " ) // $ hasPathInjection=182
235
- let _ = fm. contentsEqual ( atPath: " " , andPath: remoteString) // $ hasPathInjection=182
236
- let _ = fm. changeCurrentDirectoryPath ( remoteString) // $ hasPathInjection=182
237
- let _ = fm. unmountVolume ( at: remoteUrl, options: [ ] , completionHandler: { _ in } ) // $ hasPathInjection=182
223
+ let _ = fm. contentsOfDirectory ( at: remoteUrl, includingPropertiesForKeys: [ ] , options: [ ] ) // $ hasPathInjection=208
224
+ let _ = fm. contentsOfDirectory ( atPath: remoteString) // $ hasPathInjection=208
225
+ let _ = fm. enumerator ( at: remoteUrl, includingPropertiesForKeys: [ ] , options: [ ] , errorHandler: nil ) // $ hasPathInjection=208
226
+ let _ = fm. enumerator ( atPath: remoteString) // $ hasPathInjection=208
227
+ let _ = fm. subpathsOfDirectory ( atPath: remoteString) // $ hasPathInjection=208
228
+ let _ = fm. subpaths ( atPath: remoteString) // $ hasPathInjection=208
229
+ fm. createDirectory ( at: remoteUrl, withIntermediateDirectories: false , attributes: [ : ] ) // $ hasPathInjection=208
230
+ let _ = fm. createDirectory ( atPath: remoteString, attributes: [ : ] ) // $ hasPathInjection=208
231
+ let _ = fm. createFile ( atPath: remoteString, contents: nil , attributes: [ : ] ) // $ hasPathInjection=208
232
+ fm. removeItem ( at: remoteUrl) // $ hasPathInjection=208
233
+ fm. removeItem ( atPath: remoteString) // $ hasPathInjection=208
234
+ fm. trashItem ( at: remoteUrl, resultingItemURL: AutoreleasingUnsafeMutablePointer < NSURL ? > ( ) ) // $ hasPathInjection=208
235
+ let _ = fm. replaceItemAt ( remoteUrl, withItemAt: safeUrl, backupItemName: nil , options: [ ] ) // $ hasPathInjection=208
236
+ let _ = fm. replaceItemAt ( safeUrl, withItemAt: remoteUrl, backupItemName: nil , options: [ ] ) // $ hasPathInjection=208
237
+ fm. replaceItem ( at: remoteUrl, withItemAt: safeUrl, backupItemName: nil , options: [ ] , resultingItemURL: AutoreleasingUnsafeMutablePointer < NSURL ? > ( ) ) // $ hasPathInjection=208
238
+ fm. replaceItem ( at: safeUrl, withItemAt: remoteUrl, backupItemName: nil , options: [ ] , resultingItemURL: AutoreleasingUnsafeMutablePointer < NSURL ? > ( ) ) // $ hasPathInjection=208
239
+ fm. copyItem ( at: remoteUrl, to: safeUrl) // $ hasPathInjection=208
240
+ fm. copyItem ( at: safeUrl, to: remoteUrl) // $ hasPathInjection=208
241
+ fm. copyItem ( atPath: remoteString, toPath: " " ) // $ hasPathInjection=208
242
+ fm. copyItem ( atPath: " " , toPath: remoteString) // $ hasPathInjection=208
243
+ fm. moveItem ( at: remoteUrl, to: safeUrl) // $ hasPathInjection=208
244
+ fm. moveItem ( at: safeUrl, to: remoteUrl) // $ hasPathInjection=208
245
+ fm. moveItem ( atPath: remoteString, toPath: " " ) // $ hasPathInjection=208
246
+ fm. moveItem ( atPath: " " , toPath: remoteString) // $ hasPathInjection=208
247
+ fm. createSymbolicLink ( at: remoteUrl, withDestinationURL: safeUrl) // $ hasPathInjection=208
248
+ fm. createSymbolicLink ( at: safeUrl, withDestinationURL: remoteUrl) // $ hasPathInjection=208
249
+ fm. createSymbolicLink ( atPath: remoteString, withDestinationPath: " " ) // $ hasPathInjection=208
250
+ fm. createSymbolicLink ( atPath: " " , withDestinationPath: remoteString) // $ hasPathInjection=208
251
+ fm. linkItem ( at: remoteUrl, to: safeUrl) // $ hasPathInjection=208
252
+ fm. linkItem ( at: safeUrl, to: remoteUrl) // $ hasPathInjection=208
253
+ fm. linkItem ( atPath: remoteString, toPath: " " ) // $ hasPathInjection=208
254
+ fm. linkItem ( atPath: " " , toPath: remoteString) // $ hasPathInjection=208
255
+ let _ = fm. destinationOfSymbolicLink ( atPath: remoteString) // $ hasPathInjection=208
256
+ let _ = fm. fileExists ( atPath: remoteString) // $ hasPathInjection=208
257
+ let _ = fm. fileExists ( atPath: remoteString, isDirectory: UnsafeMutablePointer< ObjCBool> . init( bitPattern: 0 ) ) // $ hasPathInjection=208
258
+ fm. setAttributes ( [ : ] , ofItemAtPath: remoteString) // $ hasPathInjection=208
259
+ let _ = fm. contents ( atPath: remoteString) // $ hasPathInjection=208
260
+ let _ = fm. contentsEqual ( atPath: remoteString, andPath: " " ) // $ hasPathInjection=208
261
+ let _ = fm. contentsEqual ( atPath: " " , andPath: remoteString) // $ hasPathInjection=208
262
+ let _ = fm. changeCurrentDirectoryPath ( remoteString) // $ hasPathInjection=208
263
+ let _ = fm. unmountVolume ( at: remoteUrl, options: [ ] , completionHandler: { _ in } ) // $ hasPathInjection=208
238
264
// Deprecated methods
239
- let _ = fm. changeFileAttributes ( [ : ] , atPath: remoteString) // $ hasPathInjection=182
240
- let _ = fm. directoryContents ( atPath: remoteString) // $ hasPathInjection=182
241
- let _ = fm. createDirectory ( atPath: remoteString, attributes: [ : ] ) // $ hasPathInjection=182
242
- let _ = fm. createSymbolicLink ( atPath: remoteString, pathContent: " " ) // $ hasPathInjection=182
243
- let _ = fm. createSymbolicLink ( atPath: " " , pathContent: remoteString) // $ hasPathInjection=182
244
- let _ = fm. pathContentOfSymbolicLink ( atPath: remoteString) // $ hasPathInjection=182
245
- let _ = fm. replaceItemAtURL ( originalItemURL: remoteNsUrl, withItemAtURL: safeNsUrl, backupItemName: nil , options: [ ] ) // $ hasPathInjection=182
246
- let _ = fm. replaceItemAtURL ( originalItemURL: safeNsUrl, withItemAtURL: remoteNsUrl, backupItemName: nil , options: [ ] ) // $ hasPathInjection=182
265
+ let _ = fm. changeFileAttributes ( [ : ] , atPath: remoteString) // $ hasPathInjection=208
266
+ let _ = fm. directoryContents ( atPath: remoteString) // $ hasPathInjection=208
267
+ let _ = fm. createDirectory ( atPath: remoteString, attributes: [ : ] ) // $ hasPathInjection=208
268
+ let _ = fm. createSymbolicLink ( atPath: remoteString, pathContent: " " ) // $ hasPathInjection=208
269
+ let _ = fm. createSymbolicLink ( atPath: " " , pathContent: remoteString) // $ hasPathInjection=208
270
+ let _ = fm. pathContentOfSymbolicLink ( atPath: remoteString) // $ hasPathInjection=208
271
+ let _ = fm. replaceItemAtURL ( originalItemURL: remoteNsUrl, withItemAtURL: safeNsUrl, backupItemName: nil , options: [ ] ) // $ hasPathInjection=208
272
+ let _ = fm. replaceItemAtURL ( originalItemURL: safeNsUrl, withItemAtURL: remoteNsUrl, backupItemName: nil , options: [ ] ) // $ hasPathInjection=208
247
273
248
274
var encoding = String . Encoding. utf8
249
- let _ = try ! String ( contentsOfFile: remoteString) // $ hasPathInjection=182
250
- let _ = try ! String ( contentsOfFile: remoteString, encoding: String . Encoding. utf8) // $ hasPathInjection=182
251
- let _ = try ! String ( contentsOfFile: remoteString, usedEncoding: & encoding) // $ hasPathInjection=182
252
-
253
- let _ = try ! NSString ( contentsOfFile: remoteString, encoding: 0 ) // $ hasPathInjection=182
254
- let _ = try ! NSString ( contentsOfFile: remoteString, usedEncoding: nil ) // $ hasPathInjection=182
255
- NSString ( ) . write ( to: remoteUrl, atomically: true , encoding: 0 ) // $ hasPathInjection=182
256
- NSString ( ) . write ( toFile: remoteString, atomically: true , encoding: 0 ) // $ hasPathInjection=182
257
-
258
- let _ = NSKeyedUnarchiver ( ) . unarchiveObject ( withFile: remoteString) // $ hasPathInjection=182
259
- let _ = ArchiveByteStream . fileStream ( fd: remoteString as! FileDescriptor , automaticClose: true ) // $ hasPathInjection=182
260
- ArchiveByteStream . withFileStream ( fd: remoteString as! FileDescriptor , automaticClose: true ) { _ in } // $ hasPathInjection=182
261
- let _ = ArchiveByteStream . fileStream ( path: FilePath ( stringLiteral: remoteString) , mode: . readOnly, options: . append, permissions: . ownerRead) // $ hasPathInjection=182
262
- ArchiveByteStream . withFileStream ( path: FilePath ( stringLiteral: remoteString) , mode: . readOnly, options: . append, permissions: . ownerRead) { _ in } // $ hasPathInjection=182
263
- let _ = Bundle ( url: remoteUrl) // $ hasPathInjection=182
264
- let _ = Bundle ( path: remoteString) // $ hasPathInjection=182
265
-
266
- let _ = Database ( path: remoteString, description: " " , configuration: Configuration ( ) ) // $ hasPathInjection=182
275
+ let _ = try ! String ( contentsOfFile: remoteString) // $ hasPathInjection=208
276
+ let _ = try ! String ( contentsOfFile: remoteString, encoding: String . Encoding. utf8) // $ hasPathInjection=208
277
+ let _ = try ! String ( contentsOfFile: remoteString, usedEncoding: & encoding) // $ hasPathInjection=208
278
+
279
+ let _ = try ! NSString ( contentsOfFile: remoteString, encoding: 0 ) // $ hasPathInjection=208
280
+ let _ = try ! NSString ( contentsOfFile: remoteString, usedEncoding: nil ) // $ hasPathInjection=208
281
+ NSString ( ) . write ( to: remoteUrl, atomically: true , encoding: 0 ) // $ hasPathInjection=208
282
+ NSString ( ) . write ( toFile: remoteString, atomically: true , encoding: 0 ) // $ hasPathInjection=208
283
+
284
+ let _ = NSKeyedUnarchiver ( ) . unarchiveObject ( withFile: remoteString) // $ hasPathInjection=208
285
+ let _ = ArchiveByteStream . fileStream ( fd: remoteString as! FileDescriptor , automaticClose: true ) // $ hasPathInjection=208
286
+ ArchiveByteStream . withFileStream ( fd: remoteString as! FileDescriptor , automaticClose: true ) { _ in } // $ hasPathInjection=208
287
+ let _ = ArchiveByteStream . fileStream ( path: FilePath ( stringLiteral: remoteString) , mode: . readOnly, options: . append, permissions: . ownerRead) // $ hasPathInjection=208
288
+ ArchiveByteStream . withFileStream ( path: FilePath ( stringLiteral: remoteString) , mode: . readOnly, options: . append, permissions: . ownerRead) { _ in } // $ hasPathInjection=208
289
+ let _ = Bundle ( url: remoteUrl) // $ hasPathInjection=208
290
+ let _ = Bundle ( path: remoteString) // $ hasPathInjection=208
291
+
292
+ // GRDB
293
+
294
+ let _ = Database ( path: remoteString, description: " " , configuration: Configuration ( ) ) // $ hasPathInjection=208
267
295
let _ = Database ( path: " " , description: " " , configuration: Configuration ( ) ) // Safe
268
- let _ = DatabasePool ( path: remoteString, configuration: Configuration ( ) ) // $ hasPathInjection=182
296
+ let _ = DatabasePool ( path: remoteString, configuration: Configuration ( ) ) // $ hasPathInjection=208
269
297
let _ = DatabasePool ( path: " " , configuration: Configuration ( ) ) // Safe
270
- let _ = DatabaseQueue ( path: remoteString, configuration: Configuration ( ) ) // $ hasPathInjection=182
298
+ let _ = DatabaseQueue ( path: remoteString, configuration: Configuration ( ) ) // $ hasPathInjection=208
271
299
let _ = DatabaseQueue ( path: " " , configuration: Configuration ( ) ) // Safe
272
- let _ = DatabaseSnapshotPool ( path: remoteString, configuration: Configuration ( ) ) // $ hasPathInjection=182
300
+ let _ = DatabaseSnapshotPool ( path: remoteString, configuration: Configuration ( ) ) // $ hasPathInjection=208
273
301
let _ = DatabaseSnapshotPool ( path: " " , configuration: Configuration ( ) ) // Safe
274
- let _ = SerializedDatabase ( path: remoteString, defaultLabel: " " ) // $ hasPathInjection=182
302
+ let _ = SerializedDatabase ( path: remoteString, defaultLabel: " " ) // $ hasPathInjection=208
275
303
let _ = SerializedDatabase ( path: " " , defaultLabel: " " ) // Safe
276
- let _ = SerializedDatabase ( path: remoteString, defaultLabel: " " , purpose: nil ) // $ hasPathInjection=182
304
+ let _ = SerializedDatabase ( path: remoteString, defaultLabel: " " , purpose: nil ) // $ hasPathInjection=208
277
305
let _ = SerializedDatabase ( path: " " , defaultLabel: " " , purpose: nil ) // Safe
278
- let _ = SerializedDatabase ( path: remoteString, configuration: Configuration ( ) , defaultLabel: " " ) // $ hasPathInjection=182
306
+ let _ = SerializedDatabase ( path: remoteString, configuration: Configuration ( ) , defaultLabel: " " ) // $ hasPathInjection=208
279
307
let _ = SerializedDatabase ( path: " " , configuration: Configuration ( ) , defaultLabel: " " ) // Safe
280
- let _ = SerializedDatabase ( path: remoteString, configuration: Configuration ( ) , defaultLabel: " " , purpose: nil ) // $ hasPathInjection=182
308
+ let _ = SerializedDatabase ( path: remoteString, configuration: Configuration ( ) , defaultLabel: " " , purpose: nil ) // $ hasPathInjection=208
281
309
let _ = SerializedDatabase ( path: " " , configuration: Configuration ( ) , defaultLabel: " " , purpose: nil ) // Safe
310
+
311
+
312
+
313
+
314
+
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
282
323
}
283
324
284
325
func testSanitizers( ) {
@@ -290,5 +331,5 @@ func testSanitizers() {
290
331
if ( filePath. lexicallyNormalized ( ) . starts ( with: " /safe " ) ) {
291
332
let _ = fm. contents ( atPath: remoteString) // Safe
292
333
}
293
- let _ = fm. contents ( atPath: remoteString) // $ hasPathInjection=285
334
+ let _ = fm. contents ( atPath: remoteString) // $ hasPathInjection=326
294
335
}
0 commit comments