File tree Expand file tree Collapse file tree 2 files changed +50
-1
lines changed
lib/codeql/swift/frameworks/StandardLibrary
test/library-tests/dataflow/taint/libraries Expand file tree Collapse file tree 2 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ private class SequenceSummaries extends SummaryModelCsv {
25
25
";Sequence;true;joined();;;Argument[-1];ReturnValue;taint" ,
26
26
";Sequence;true;joined(separator:);;;Argument[-1..0];ReturnValue;taint" ,
27
27
";Sequence;true;first(where:);;;Argument[-1];ReturnValue;taint" ,
28
- ";Sequence;true;withContiguousStorageIfAvailable(_:);;;Argument[-1];Argument[0].Parameter[0];taint" ,
28
+ ";Sequence;true;withContiguousStorageIfAvailable(_:);;;Argument[-1];Argument[0].Parameter[0];taint"
29
29
]
30
30
}
31
31
}
Original file line number Diff line number Diff line change @@ -599,3 +599,52 @@ func untaintedFields() {
599
599
sink ( arg: String . defaultCStringEncoding)
600
600
sink ( arg: tainted. isContiguousUTF8)
601
601
}
602
+
603
+ func callbackWithCleanPointer( ptr: UnsafeBufferPointer < String . Element > ) throws -> Int {
604
+ sink ( arg: ptr)
605
+
606
+ return 0
607
+ }
608
+
609
+ func callbackWithTaintedPointer( ptr: UnsafeBufferPointer < String . Element > ) throws -> Int {
610
+ sink ( arg: ptr) // $ tainted=617
611
+
612
+ return source ( )
613
+ }
614
+
615
+ func furtherTaintThroughCallbacks( ) {
616
+ let clean = " "
617
+ let tainted = source2 ( )
618
+
619
+ // return values from the closure (1)
620
+ let result1 = clean. withContiguousStorageIfAvailable ( {
621
+ ptr in
622
+ return 0
623
+ } )
624
+ sink ( arg: result1!)
625
+ let result2 = clean. withContiguousStorageIfAvailable ( {
626
+ ptr in
627
+ return source ( )
628
+ } )
629
+ sink ( arg: result2!) // $ MISSING: tainted=627
630
+
631
+ // return values from the closure (2)
632
+ if let result3 = clean. withContiguousStorageIfAvailable ( {
633
+ ptr in
634
+ return 0
635
+ } ) {
636
+ sink ( arg: result3)
637
+ }
638
+ if let result4 = clean. withContiguousStorageIfAvailable ( {
639
+ ptr in
640
+ return source ( )
641
+ } ) {
642
+ sink ( arg: result4) // $ MISSING: tainted=640
643
+ }
644
+
645
+ // using a non-closure function
646
+ let result5 = try ? clean. withContiguousStorageIfAvailable ( callbackWithCleanPointer)
647
+ sink ( arg: result5!)
648
+ let result6 = try ? tainted. withContiguousStorageIfAvailable ( callbackWithTaintedPointer)
649
+ sink ( arg: result6!) // $ MISSING: tainted=612
650
+ }
You can’t perform that action at this time.
0 commit comments