File tree Expand file tree Collapse file tree
lib/codeql/swift/frameworks/StandardLibrary
test/library-tests/dataflow/taint/libraries Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 */
55
66import swift
7+ private import codeql.swift.dataflow.ExternalFlow
78
89/**
910 * A Swift unsafe typed pointer type such as `UnsafePointer`,
@@ -57,3 +58,12 @@ class CVaListPointerType extends NominalType {
5758class ManagedBufferPointerType extends BoundGenericType {
5859 ManagedBufferPointerType ( ) { this .getName ( ) .matches ( "ManagedBufferPointer<%" ) }
5960}
61+
62+ /**
63+ * A model for `UnsafePointer` and related Swift class members that permit taint flow.
64+ */
65+ private class PointerSummaries extends SummaryModelCsv {
66+ override predicate row ( string row ) {
67+ row = ";UnsafeMutableBufferPointer;true;update(repeating:);;;Argument[0];Argument[-1];taint"
68+ }
69+ }
Original file line number Diff line number Diff line change @@ -45,8 +45,8 @@ func taintThroughMutablePointer() {
4545 let return1 = myArray1. withUnsafeMutableBufferPointer ( {
4646 buffer in
4747 buffer. update ( repeating: source ( ) )
48- sink ( arg: buffer)
49- sink ( arg: buffer [ 0 ] ) // $ MISSING: tainted=47
48+ sink ( arg: buffer) // $ tainted=47
49+ sink ( arg: buffer [ 0 ] ) // $ tainted=47
5050 sink ( arg: buffer. baseAddress!. pointee) // $ MISSING: tainted=47
5151 return source ( )
5252 } )
@@ -81,8 +81,8 @@ func taintThroughMutablePointer() {
8181 let return3 = myArray3. withContiguousMutableStorageIfAvailable ( {
8282 ptr in
8383 ptr. update ( repeating: source ( ) )
84- sink ( arg: ptr)
85- sink ( arg: ptr [ 0 ] ) // $ MISSING: tainted=83
84+ sink ( arg: ptr) // $ tainted=83
85+ sink ( arg: ptr [ 0 ] ) // $ tainted=83
8686 return source ( )
8787 } )
8888 sink ( arg: return3!) // $ MISSING: tainted=83
@@ -129,8 +129,8 @@ func taintThroughMutablePointer() {
129129 let return6 = myMutableBuffer. withContiguousMutableStorageIfAvailable ( {
130130 ptr in
131131 ptr. update ( repeating: source2 ( ) )
132- sink ( arg: ptr)
133- sink ( arg: ptr [ 0 ] ) // $ MISSING: tainted=131
132+ sink ( arg: ptr) // $ tainted=131
133+ sink ( arg: ptr [ 0 ] ) // $ tainted=131
134134 return source ( )
135135 } )
136136 sink ( arg: return6!) // $ MISSING: tainted=134
You can’t perform that action at this time.
0 commit comments