@@ -25,8 +25,8 @@ protocol NSMutableCopying {
2525
2626class NSString : NSObject , NSCopying , NSMutableCopying {
2727 struct EncodingConversionOptions : OptionSet { let rawValue : Int }
28-
2928 struct CompareOptions : OptionSet { let rawValue : Int }
29+ struct EnumerationOptions : OptionSet { let rawValue : Int }
3030
3131 init ( characters: UnsafePointer < unichar > , length: Int ) { }
3232 init ( charactersNoCopy characters: UnsafeMutablePointer < unichar > , length: Int , freeWhenDone freeBuffer: Bool ) { }
@@ -83,6 +83,7 @@ class NSString : NSObject, NSCopying, NSMutableCopying {
8383 func folding( options: NSString . CompareOptions = [ ] , locale: Locale ? ) -> String { return " " }
8484 func applyingTransform( _ transform: StringTransform , reverse: Bool ) -> String ? { return " " }
8585 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 ) { }
8687 func replacingOccurrences( of target: String , with replacement: String ) -> String { return " " }
8788 func replacingOccurrences( of target: String , with replacement: String , options: NSString . CompareOptions = [ ] , range searchRange: NSRange ) -> String { return " " }
8889 func propertyList( ) -> Any { return 0 }
@@ -136,8 +137,7 @@ class NSMutableString : NSString {
136137 func setString( _ aString: String ) { }
137138}
138139
139- class NSArray : NSObject {
140- }
140+ class NSArray : NSObject { }
141141
142142struct _NSRange {
143143 init ( location: Int , length: Int ) { }
@@ -275,8 +275,8 @@ func taintThroughInterpolatedStrings() {
275275 sink ( arg: sourceNSString ( ) . replacingOccurrences ( of: " a " , with: " b " , range: NSRange ( location: 0 , length: 10 ) ) ) // $ tainted=275
276276 sink ( arg: harmless. replacingOccurrences ( of: " a " , with: sourceString ( ) , range: NSRange ( location: 0 , length: 10 ) ) ) // $ tainted=276
277277 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
280280 sink ( arg: NSString . string ( withCString: sourceCString ( ) ) ) // $ tainted=280
281281 sink ( arg: NSString . string ( withCString: sourceCString ( ) , length: 128 ) ) // $ tainted=281
282282 sink ( arg: NSString . string ( withContentsOfFile: sourceString ( ) ) ) // $ tainted=282
@@ -306,8 +306,8 @@ func taintThroughInterpolatedStrings() {
306306
307307 sink ( arg: harmless. strings ( byAppendingPaths: [ " " ] ) )
308308 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
311311 sink ( arg: sourceNSString ( ) . strings ( byAppendingPaths: [ " " ] ) ) // $ tainted=311
312312 sink ( arg: sourceNSString ( ) . strings ( byAppendingPaths: [ " " ] ) [ 0 ] ) // $ tainted=312
313313
@@ -355,7 +355,7 @@ func taintThroughInterpolatedStrings() {
355355 } ) )
356356 sink ( arg: sourceNSString ( ) . enumerateLines ( {
357357 line, stop in
358- sink ( arg: line) // $ MISSING: tainted=
358+ sink ( arg: line) // $ tainted=356
359359 sink ( arg: stop)
360360 } ) )
361361
@@ -485,3 +485,13 @@ func taintThroughData() {
485485 let str2 = NSString ( data: data1, encoding: 0 ) !
486486 sink ( arg: str2) // $ tainted=482
487487}
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