@@ -25,8 +25,8 @@ protocol NSMutableCopying {
25
25
26
26
class NSString : NSObject , NSCopying , NSMutableCopying {
27
27
struct EncodingConversionOptions : OptionSet { let rawValue : Int }
28
-
29
28
struct CompareOptions : OptionSet { let rawValue : Int }
29
+ struct EnumerationOptions : OptionSet { let rawValue : Int }
30
30
31
31
init ( characters: UnsafePointer < unichar > , length: Int ) { }
32
32
init ( charactersNoCopy characters: UnsafeMutablePointer < unichar > , length: Int , freeWhenDone freeBuffer: Bool ) { }
@@ -83,6 +83,7 @@ class NSString : NSObject, NSCopying, NSMutableCopying {
83
83
func folding( options: NSString . CompareOptions = [ ] , locale: Locale ? ) -> String { return " " }
84
84
func applyingTransform( _ transform: StringTransform , reverse: Bool ) -> String ? { return " " }
85
85
func enumerateLines( _ block: @escaping ( String , UnsafeMutablePointer < ObjCBool > ) -> Void ) { }
86
+ func enumerateSubstrings( in range: NSRange , options opts: NSString . EnumerationOptions = [ ] , using block: @escaping ( String ? , NSRange , NSRange , UnsafeMutablePointer < ObjCBool > ) -> Void ) { }
86
87
func replacingOccurrences( of target: String , with replacement: String ) -> String { return " " }
87
88
func replacingOccurrences( of target: String , with replacement: String , options: NSString . CompareOptions = [ ] , range searchRange: NSRange ) -> String { return " " }
88
89
func propertyList( ) -> Any { return 0 }
@@ -136,8 +137,7 @@ class NSMutableString : NSString {
136
137
func setString( _ aString: String ) { }
137
138
}
138
139
139
- class NSArray : NSObject {
140
- }
140
+ class NSArray : NSObject { }
141
141
142
142
struct _NSRange {
143
143
init ( location: Int , length: Int ) { }
@@ -275,8 +275,8 @@ func taintThroughInterpolatedStrings() {
275
275
sink ( arg: sourceNSString ( ) . replacingOccurrences ( of: " a " , with: " b " , range: NSRange ( location: 0 , length: 10 ) ) ) // $ tainted=275
276
276
sink ( arg: harmless. replacingOccurrences ( of: " a " , with: sourceString ( ) , range: NSRange ( location: 0 , length: 10 ) ) ) // $ tainted=276
277
277
sink ( arg: NSString . path ( withComponents: [ " a " , " b " , " c " ] ) )
278
- sink ( arg: NSString . path ( withComponents: sourceStringArray ( ) ) ) // $ tainted=278
279
- sink ( arg: NSString . path ( withComponents: [ " a " , sourceString ( ) , " c " ] ) ) // $ MISSING: tainted=
278
+ sink ( arg: NSString . path ( withComponents: sourceStringArray ( ) ) ) // $ MISSING: tainted=278
279
+ sink ( arg: NSString . path ( withComponents: [ " a " , sourceString ( ) , " c " ] ) ) // $ tainted=279
280
280
sink ( arg: NSString . string ( withCString: sourceCString ( ) ) ) // $ tainted=280
281
281
sink ( arg: NSString . string ( withCString: sourceCString ( ) , length: 128 ) ) // $ tainted=281
282
282
sink ( arg: NSString . string ( withContentsOfFile: sourceString ( ) ) ) // $ tainted=282
@@ -306,8 +306,8 @@ func taintThroughInterpolatedStrings() {
306
306
307
307
sink ( arg: harmless. strings ( byAppendingPaths: [ " " ] ) )
308
308
sink ( arg: harmless. strings ( byAppendingPaths: [ " " ] ) [ 0 ] )
309
- sink ( arg: harmless. strings ( byAppendingPaths: [ sourceString ( ) ] ) ) // $ MISSING: tainted=
310
- sink ( arg: harmless. strings ( byAppendingPaths: [ sourceString ( ) ] ) [ 0 ] ) // $ MISSING: tainted=
309
+ sink ( arg: harmless. strings ( byAppendingPaths: [ sourceString ( ) ] ) ) // $ tainted=309
310
+ sink ( arg: harmless. strings ( byAppendingPaths: [ sourceString ( ) ] ) [ 0 ] ) // $ tainted=310
311
311
sink ( arg: sourceNSString ( ) . strings ( byAppendingPaths: [ " " ] ) ) // $ tainted=311
312
312
sink ( arg: sourceNSString ( ) . strings ( byAppendingPaths: [ " " ] ) [ 0 ] ) // $ tainted=312
313
313
@@ -355,7 +355,7 @@ func taintThroughInterpolatedStrings() {
355
355
} ) )
356
356
sink ( arg: sourceNSString ( ) . enumerateLines ( {
357
357
line, stop in
358
- sink ( arg: line) // $ MISSING: tainted=
358
+ sink ( arg: line) // $ tainted=356
359
359
sink ( arg: stop)
360
360
} ) )
361
361
@@ -485,3 +485,13 @@ func taintThroughData() {
485
485
let str2 = NSString ( data: data1, encoding: 0 ) !
486
486
sink ( arg: str2) // $ tainted=482
487
487
}
488
+
489
+ func moreTests( ) {
490
+ let myTainted = sourceNSString ( )
491
+ let myRange = NSRange ( location: 0 , length: 128 )
492
+
493
+ sink ( arg: myTainted. enumerateSubstrings ( in: myRange, options: [ ] , using: {
494
+ substring, substringRange, enclosingRange, stop in
495
+ sink ( arg: substring!) // $ tainted=490
496
+ } ) )
497
+ }
0 commit comments