File tree Expand file tree Collapse file tree 3 files changed +25
-6
lines changed
lib/codeql/swift/frameworks
test/library-tests/dataflow/taint/libraries Expand file tree Collapse file tree 3 files changed +25
-6
lines changed Original file line number Diff line number Diff line change 6
6
import swift
7
7
private import codeql.swift.dataflow.DataFlow
8
8
private import codeql.swift.dataflow.FlowSources
9
+ private import codeql.swift.dataflow.FlowSteps
9
10
10
11
/**
11
12
* An initializer call `ce` that has a "contentsOf" argument, along with a
@@ -51,3 +52,21 @@ private class InitializerContentsOfLocalSource extends LocalFlowSource {
51
52
52
53
override string getSourceType ( ) { result = "contentsOf initializer" }
53
54
}
55
+
56
+ /**
57
+ * An imprecise flow step for an initializer call with a "data" argument. For
58
+ * example:
59
+ * ```
60
+ * let mc = MyClass(data: taintedData)
61
+ * ```
62
+ */
63
+ private class InitializerFromDataStep extends AdditionalTaintStep {
64
+ override predicate step ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
65
+ exists ( InitializerCallExpr ce , Argument arg |
66
+ ce .getAnArgument ( ) = arg and
67
+ arg .getLabel ( ) = "data" and
68
+ node1 .asExpr ( ) = arg .getExpr ( ) and
69
+ node2 .asExpr ( ) = ce
70
+ )
71
+ }
72
+ }
Original file line number Diff line number Diff line change @@ -44,10 +44,10 @@ func testCustom() {
44
44
let tainted2 = MyContainer ( data: source ( " data2 " ) , flags: 123 )
45
45
sink ( arg: clean)
46
46
sink ( arg: clean [ 0 ] )
47
- sink ( arg: tainted) // $ MISSING: tainted=data1
48
- sink ( arg: tainted [ 0 ] ) // $ MISSING: tainted=data1
49
- sink ( arg: tainted2) // $ MISSING: tainted=data2
50
- sink ( arg: tainted2 [ 0 ] ) // $ MISSING: tainted=data2
47
+ sink ( arg: tainted) // $ tainted=data1
48
+ sink ( arg: tainted [ 0 ] ) // $ tainted=data1
49
+ sink ( arg: tainted2) // $ tainted=data2
50
+ sink ( arg: tainted2 [ 0 ] ) // $ tainted=data2
51
51
52
52
var mc1 = MyContainer ( )
53
53
mc1. append ( Data ( 0 ) )
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ func testUIImage(scale: CGFloat) {
91
91
let taintedData = source ( " UIImage " ) as! Data
92
92
93
93
sink ( UIImage ( data: Data ( 0 ) ) !)
94
- sink ( UIImage ( data: Data ( taintedData) ) !) // $ MISSING: tainted=UIImage
94
+ sink ( UIImage ( data: Data ( taintedData) ) !) // $ tainted=UIImage
95
95
sink ( UIImage ( data: Data ( 0 ) , scale: scale) !)
96
- sink ( UIImage ( data: Data ( taintedData) , scale: scale) !) // $ MISSING: tainted=UIImage
96
+ sink ( UIImage ( data: Data ( taintedData) , scale: scale) !) // $ tainted=UIImage
97
97
}
You can’t perform that action at this time.
0 commit comments