File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed
lib/codeql/swift/frameworks/StandardLibrary
test/library-tests/dataflow/taint/libraries Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change 4
4
*/
5
5
6
6
import swift
7
+ private import codeql.swift.dataflow.ExternalFlow
7
8
8
9
/**
9
10
* A Swift unsafe typed pointer type such as `UnsafePointer`,
@@ -57,3 +58,12 @@ class CVaListPointerType extends NominalType {
57
58
class ManagedBufferPointerType extends BoundGenericType {
58
59
ManagedBufferPointerType ( ) { this .getName ( ) .matches ( "ManagedBufferPointer<%" ) }
59
60
}
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() {
45
45
let return1 = myArray1. withUnsafeMutableBufferPointer ( {
46
46
buffer in
47
47
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
50
50
sink ( arg: buffer. baseAddress!. pointee) // $ MISSING: tainted=47
51
51
return source ( )
52
52
} )
@@ -81,8 +81,8 @@ func taintThroughMutablePointer() {
81
81
let return3 = myArray3. withContiguousMutableStorageIfAvailable ( {
82
82
ptr in
83
83
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
86
86
return source ( )
87
87
} )
88
88
sink ( arg: return3!) // $ MISSING: tainted=83
@@ -129,8 +129,8 @@ func taintThroughMutablePointer() {
129
129
let return6 = myMutableBuffer. withContiguousMutableStorageIfAvailable ( {
130
130
ptr in
131
131
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
134
134
return source ( )
135
135
} )
136
136
sink ( arg: return6!) // $ MISSING: tainted=134
You can’t perform that action at this time.
0 commit comments