Skip to content

Commit 2ac06b8

Browse files
committed
Turns out lambda flow is already supported
1 parent 2e1a78e commit 2ac06b8

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

swift/ql/lib/codeql/swift/frameworks/StandardLibrary/NSData.qll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ private class NsDataSummaries extends SummaryModelCsv {
4545
";NSData;true;base64EncodedString(options:);;;Argument[-1];ReturnValue;taint",
4646
";NSData;true;base64Encoding();;;Argument[-1];ReturnValue;taint",
4747
";NSData;true;dataWithContentsOfMappedFile(_:);;;Argument[0];ReturnValue;taint",
48-
// TODO: Needs block flow
49-
// ";NSData;true;enumerateBytes(_:);;;Argument[-1];Argument[0].Parameter[0];taint"
48+
";NSData;true;enumerateBytes(_:);;;Argument[-1];Argument[0].Parameter[0];taint",
5049
";NSData;true;getBytes(_:);;;Argument[-1];Argument[0];taint",
5150
";NSData;true;getBytes(_:length:);;;Argument[-1];Argument[0];taint",
5251
";NSData;true;getBytes(_:range:);;;Argument[-1];Argument[0];taint",

swift/ql/test/library-tests/dataflow/taint/Taint.expected

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
edges
2+
| file://:0:0:0:0 | [summary] to write: argument 0.parameter 0 in enumerateBytes(_:) : | nsdata.swift:110:9:110:9 | bytes : |
23
| file://:0:0:0:0 | [summary] to write: argument 1.parameter 0 in dataTask(with:completionHandler:) : | url.swift:120:61:120:61 | data : |
34
| nsdata.swift:22:9:22:9 | self : | file://:0:0:0:0 | .bytes : |
45
| nsdata.swift:23:9:23:9 | self : | file://:0:0:0:0 | .description : |
@@ -19,6 +20,7 @@ edges
1920
| nsdata.swift:38:5:38:96 | [summary param] this in base64EncodedString(options:) : | file://:0:0:0:0 | [summary] to write: return (return) in base64EncodedString(options:) : |
2021
| nsdata.swift:39:5:39:49 | [summary param] this in base64Encoding() : | file://:0:0:0:0 | [summary] to write: return (return) in base64Encoding() : |
2122
| nsdata.swift:40:5:40:82 | [summary param] 0 in dataWithContentsOfMappedFile(_:) : | file://:0:0:0:0 | [summary] to write: return (return) in dataWithContentsOfMappedFile(_:) : |
23+
| nsdata.swift:41:5:41:104 | [summary param] this in enumerateBytes(_:) : | file://:0:0:0:0 | [summary] to write: argument 0.parameter 0 in enumerateBytes(_:) : |
2224
| nsdata.swift:42:5:42:55 | [summary param] this in getBytes(_:) : | file://:0:0:0:0 | [summary] to write: argument 0 in getBytes(_:) : |
2325
| nsdata.swift:43:5:43:68 | [summary param] this in getBytes(_:length:) : | file://:0:0:0:0 | [summary] to write: argument 0 in getBytes(_:length:) : |
2426
| nsdata.swift:44:5:44:71 | [summary param] this in getBytes(_:range:) : | file://:0:0:0:0 | [summary] to write: argument 0 in getBytes(_:range:) : |
@@ -82,6 +84,9 @@ edges
8284
| nsdata.swift:106:15:106:70 | call to dataWithContentsOfMappedFile(_:) : | nsdata.swift:106:15:106:71 | ...! |
8385
| nsdata.swift:106:51:106:58 | call to source() : | nsdata.swift:40:5:40:82 | [summary param] 0 in dataWithContentsOfMappedFile(_:) : |
8486
| nsdata.swift:106:51:106:58 | call to source() : | nsdata.swift:106:15:106:70 | call to dataWithContentsOfMappedFile(_:) : |
87+
| nsdata.swift:108:27:108:34 | call to source() : | nsdata.swift:109:5:109:5 | nsDataTainted17 : |
88+
| nsdata.swift:109:5:109:5 | nsDataTainted17 : | nsdata.swift:41:5:41:104 | [summary param] this in enumerateBytes(_:) : |
89+
| nsdata.swift:110:9:110:9 | bytes : | nsdata.swift:110:45:110:45 | bytes |
8590
| nsdata.swift:113:27:113:34 | call to source() : | nsdata.swift:115:5:115:5 | nsDataTainted18 : |
8691
| nsdata.swift:115:5:115:5 | nsDataTainted18 : | nsdata.swift:42:5:42:55 | [summary param] this in getBytes(_:) : |
8792
| nsdata.swift:115:5:115:5 | nsDataTainted18 : | nsdata.swift:115:30:115:30 | [post] bufferTainted18 : |
@@ -382,6 +387,7 @@ nodes
382387
| file://:0:0:0:0 | [summary] to write: argument 0 in getBytes(_:) : | semmle.label | [summary] to write: argument 0 in getBytes(_:) : |
383388
| file://:0:0:0:0 | [summary] to write: argument 0 in getBytes(_:length:) : | semmle.label | [summary] to write: argument 0 in getBytes(_:length:) : |
384389
| file://:0:0:0:0 | [summary] to write: argument 0 in getBytes(_:range:) : | semmle.label | [summary] to write: argument 0 in getBytes(_:range:) : |
390+
| file://:0:0:0:0 | [summary] to write: argument 0.parameter 0 in enumerateBytes(_:) : | semmle.label | [summary] to write: argument 0.parameter 0 in enumerateBytes(_:) : |
385391
| file://:0:0:0:0 | [summary] to write: argument 1.parameter 0 in dataTask(with:completionHandler:) : | semmle.label | [summary] to write: argument 1.parameter 0 in dataTask(with:completionHandler:) : |
386392
| file://:0:0:0:0 | [summary] to write: argument this in append(_:) : | semmle.label | [summary] to write: argument this in append(_:) : |
387393
| file://:0:0:0:0 | [summary] to write: argument this in append(_:length:) : | semmle.label | [summary] to write: argument this in append(_:length:) : |
@@ -459,6 +465,7 @@ nodes
459465
| nsdata.swift:38:5:38:96 | [summary param] this in base64EncodedString(options:) : | semmle.label | [summary param] this in base64EncodedString(options:) : |
460466
| nsdata.swift:39:5:39:49 | [summary param] this in base64Encoding() : | semmle.label | [summary param] this in base64Encoding() : |
461467
| nsdata.swift:40:5:40:82 | [summary param] 0 in dataWithContentsOfMappedFile(_:) : | semmle.label | [summary param] 0 in dataWithContentsOfMappedFile(_:) : |
468+
| nsdata.swift:41:5:41:104 | [summary param] this in enumerateBytes(_:) : | semmle.label | [summary param] this in enumerateBytes(_:) : |
462469
| nsdata.swift:42:5:42:55 | [summary param] this in getBytes(_:) : | semmle.label | [summary param] this in getBytes(_:) : |
463470
| nsdata.swift:43:5:43:68 | [summary param] this in getBytes(_:length:) : | semmle.label | [summary param] this in getBytes(_:length:) : |
464471
| nsdata.swift:44:5:44:71 | [summary param] this in getBytes(_:range:) : | semmle.label | [summary param] this in getBytes(_:range:) : |
@@ -520,6 +527,10 @@ nodes
520527
| nsdata.swift:106:15:106:70 | call to dataWithContentsOfMappedFile(_:) : | semmle.label | call to dataWithContentsOfMappedFile(_:) : |
521528
| nsdata.swift:106:15:106:71 | ...! | semmle.label | ...! |
522529
| nsdata.swift:106:51:106:58 | call to source() : | semmle.label | call to source() : |
530+
| nsdata.swift:108:27:108:34 | call to source() : | semmle.label | call to source() : |
531+
| nsdata.swift:109:5:109:5 | nsDataTainted17 : | semmle.label | nsDataTainted17 : |
532+
| nsdata.swift:110:9:110:9 | bytes : | semmle.label | bytes : |
533+
| nsdata.swift:110:45:110:45 | bytes | semmle.label | bytes |
523534
| nsdata.swift:113:27:113:34 | call to source() : | semmle.label | call to source() : |
524535
| nsdata.swift:115:5:115:5 | nsDataTainted18 : | semmle.label | nsDataTainted18 : |
525536
| nsdata.swift:115:30:115:30 | [post] bufferTainted18 : | semmle.label | [post] bufferTainted18 : |
@@ -873,6 +884,7 @@ subpaths
873884
| nsdata.swift:101:15:101:62 | call to base64EncodedString(options:) | nsdata.swift:99:27:99:34 | call to source() : | nsdata.swift:101:15:101:62 | call to base64EncodedString(options:) | result |
874885
| nsdata.swift:104:15:104:46 | call to base64Encoding() | nsdata.swift:103:27:103:34 | call to source() : | nsdata.swift:104:15:104:46 | call to base64Encoding() | result |
875886
| nsdata.swift:106:15:106:71 | ...! | nsdata.swift:106:51:106:58 | call to source() : | nsdata.swift:106:15:106:71 | ...! | result |
887+
| nsdata.swift:110:45:110:45 | bytes | nsdata.swift:108:27:108:34 | call to source() : | nsdata.swift:110:45:110:45 | bytes | result |
876888
| nsdata.swift:116:15:116:15 | bufferTainted18 | nsdata.swift:113:27:113:34 | call to source() : | nsdata.swift:116:15:116:15 | bufferTainted18 | result |
877889
| nsdata.swift:121:15:121:15 | bufferTainted19 | nsdata.swift:118:27:118:34 | call to source() : | nsdata.swift:121:15:121:15 | bufferTainted19 | result |
878890
| nsdata.swift:126:15:126:15 | bufferTainted20 | nsdata.swift:123:27:123:34 | call to source() : | nsdata.swift:126:15:126:15 | bufferTainted20 | result |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| nsdata.swift:110:45:110:45 | bytes | Unexpected result: tainted=108 |

swift/ql/test/library-tests/dataflow/taint/nsdata.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func test() {
107107
// ";NSData;true;enumerateBytes(_:);;;Argument[-1];Argument[0].Parameter[0];taint"
108108
let nsDataTainted17 = source() as! NSData
109109
nsDataTainted17.enumerateBytes {
110-
bytes, byteRange, stop in sink(arg: bytes) // $ MISSING: tainted=108
110+
bytes, byteRange, stop in sink(arg: bytes) // tainted=108
111111
}
112112
// ";NSData;true;getBytes(_:);;;Argument[-1];Argument[0];taint",
113113
let nsDataTainted18 = source() as! NSData

0 commit comments

Comments
 (0)