File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
swift/ql/test/library-tests/dataflow/taint/libraries Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -648,3 +648,32 @@ func furtherTaintThroughCallbacks() {
648
648
let result6 = try ? tainted. withContiguousStorageIfAvailable ( callbackWithTaintedPointer)
649
649
sink ( arg: result6!) // $ tainted=612
650
650
}
651
+
652
+ func testSubstringMembers( ) {
653
+ let clean = " "
654
+ let tainted = source2 ( )
655
+
656
+ let sub1 = tainted [ ..< tainted. index ( tainted. endIndex, offsetBy: - 5 ) ]
657
+ sink ( arg: sub1) // $ tainted=654
658
+ sink ( arg: sub1. base) // $ MISSING: tainted=
659
+ sink ( arg: sub1. utf8) // $ MISSING: tainted=
660
+ sink ( arg: sub1. capitalized) // $ tainted=654
661
+ sink ( arg: sub1. description) // $ tainted=654
662
+
663
+ var sub2 = tainted [ tainted. index ( tainted. startIndex, offsetBy: 5 ) ... ]
664
+ sink ( arg: sub2) // $ tainted=654
665
+ let result1 = sub2. withUTF8 ( {
666
+ buffer in
667
+ sink ( arg: buffer [ 0 ] ) // $ MISSING: tainted=
668
+ return source ( )
669
+ } )
670
+ sink ( arg: result1) // $ MISSING: tainted=
671
+
672
+ let sub3 = Substring ( sub2. utf8)
673
+ sink ( arg: sub3) // $ MISSING: tainted=
674
+
675
+ var sub4 = clean. prefix ( 10 )
676
+ sink ( arg: sub4)
677
+ sub4. replaceSubrange ( ..< clean. endIndex, with: sub1)
678
+ sink ( arg: sub4) // $ MISSING: tainted=
679
+ }
You can’t perform that action at this time.
0 commit comments