Skip to content

Commit dd7f546

Browse files
committed
Swift: Add inline expectation tags.
1 parent b66ed57 commit dd7f546

File tree

11 files changed

+131
-239
lines changed

11 files changed

+131
-239
lines changed

swift/ql/test/library-tests/dataflow/flowsources/FlowSources.expected

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@
1717
| alamofire.swift:448:20:448:49 | call to String.init(contentsOfFile:) | external |
1818
| alamofire.swift:455:23:455:32 | .data | external |
1919
| alamofire.swift:461:23:461:32 | .data | external |
20-
| customurlschemes.swift:53:44:53:54 | url | external |
21-
| customurlschemes.swift:57:52:57:68 | url | external |
22-
| customurlschemes.swift:61:52:61:62 | url | external |
23-
| customurlschemes.swift:66:9:66:28 | ...[...] | Remote URL in UIApplicationDelegate.application.launchOptions |
24-
| customurlschemes.swift:71:9:71:28 | ...[...] | Remote URL in UIApplicationDelegate.application.launchOptions |
25-
| customurlschemes.swift:77:59:77:76 | options | external |
26-
| customurlschemes.swift:78:28:78:38 | continue | external |
27-
| customurlschemes.swift:79:28:79:39 | didUpdate | external |
28-
| customurlschemes.swift:80:28:80:65 | openURLContexts | external |
29-
| customurlschemes.swift:86:59:86:76 | options | external |
30-
| customurlschemes.swift:87:28:87:38 | continue | external |
31-
| customurlschemes.swift:88:28:88:39 | didUpdate | external |
32-
| customurlschemes.swift:89:28:89:65 | openURLContexts | external |
20+
| customurlschemes.swift:54:44:54:54 | url | external |
21+
| customurlschemes.swift:58:52:58:68 | url | external |
22+
| customurlschemes.swift:62:52:62:62 | url | external |
23+
| customurlschemes.swift:67:9:67:28 | ...[...] | Remote URL in UIApplicationDelegate.application.launchOptions |
24+
| customurlschemes.swift:72:9:72:28 | ...[...] | Remote URL in UIApplicationDelegate.application.launchOptions |
25+
| customurlschemes.swift:78:59:78:76 | options | external |
26+
| customurlschemes.swift:79:28:79:38 | continue | external |
27+
| customurlschemes.swift:80:28:80:39 | didUpdate | external |
28+
| customurlschemes.swift:81:28:81:65 | openURLContexts | external |
29+
| customurlschemes.swift:87:59:87:76 | options | external |
30+
| customurlschemes.swift:88:28:88:38 | continue | external |
31+
| customurlschemes.swift:89:28:89:39 | didUpdate | external |
32+
| customurlschemes.swift:90:28:90:65 | openURLContexts | external |
3333
| data.swift:18:20:18:54 | call to Data.init(contentsOf:options:) | external |
3434
| file://:0:0:0:0 | .data | external |
3535
| file://:0:0:0:0 | .result | external |
Lines changed: 0 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +0,0 @@
1-
| alamofire.swift:91:27:91:27 | .result | Unexpected result: source=remote |
2-
| alamofire.swift:99:27:99:27 | .result | Unexpected result: source=remote |
3-
| alamofire.swift:344:23:344:32 | .data | Unexpected result: source=remote |
4-
| alamofire.swift:351:22:351:31 | .value | Unexpected result: source=remote |
5-
| alamofire.swift:358:23:358:32 | .value | Unexpected result: source=remote |
6-
| alamofire.swift:365:22:365:31 | .value | Unexpected result: source=remote |
7-
| alamofire.swift:372:23:372:32 | .value | Unexpected result: source=remote |
8-
| alamofire.swift:379:28:379:37 | .value | Unexpected result: source=remote |
9-
| alamofire.swift:389:28:389:55 | call to String.init(contentsOfFile:) | Unexpected result: source=local |
10-
| alamofire.swift:396:22:396:31 | .value | Unexpected result: source=remote |
11-
| alamofire.swift:403:22:403:31 | .value | Unexpected result: source=remote |
12-
| alamofire.swift:404:28:404:50 | call to String.init(contentsOf:) | Unexpected result: source=remote |
13-
| alamofire.swift:411:23:411:32 | .value | Unexpected result: source=remote |
14-
| alamofire.swift:418:22:418:31 | .value | Unexpected result: source=remote |
15-
| alamofire.swift:425:23:425:32 | .value | Unexpected result: source=remote |
16-
| alamofire.swift:431:28:431:37 | .value | Unexpected result: source=remote |
17-
| alamofire.swift:448:20:448:49 | call to String.init(contentsOfFile:) | Unexpected result: source=local |
18-
| alamofire.swift:455:23:455:32 | .data | Unexpected result: source=remote |
19-
| alamofire.swift:461:23:461:32 | .data | Unexpected result: source=remote |
20-
| customurlschemes.swift:53:44:53:54 | url | Unexpected result: source=remote |
21-
| customurlschemes.swift:57:52:57:68 | url | Unexpected result: source=remote |
22-
| customurlschemes.swift:61:52:61:62 | url | Unexpected result: source=remote |
23-
| customurlschemes.swift:66:9:66:28 | ...[...] | Unexpected result: source=remote |
24-
| customurlschemes.swift:71:9:71:28 | ...[...] | Unexpected result: source=remote |
25-
| customurlschemes.swift:77:59:77:76 | options | Unexpected result: source=remote |
26-
| customurlschemes.swift:78:28:78:38 | continue | Unexpected result: source=remote |
27-
| customurlschemes.swift:79:28:79:39 | didUpdate | Unexpected result: source=remote |
28-
| customurlschemes.swift:80:28:80:65 | openURLContexts | Unexpected result: source=remote |
29-
| customurlschemes.swift:86:59:86:76 | options | Unexpected result: source=remote |
30-
| customurlschemes.swift:87:28:87:38 | continue | Unexpected result: source=remote |
31-
| customurlschemes.swift:88:28:88:39 | didUpdate | Unexpected result: source=remote |
32-
| customurlschemes.swift:89:28:89:65 | openURLContexts | Unexpected result: source=remote |
33-
| data.swift:18:20:18:54 | call to Data.init(contentsOf:options:) | Unexpected result: source=remote |
34-
| filemanager.swift:37:23:37:86 | call to contentsOfDirectory(at:includingPropertiesForKeys:options:) | Unexpected result: source=local |
35-
| filemanager.swift:38:23:38:58 | call to contentsOfDirectory(atPath:) | Unexpected result: source=local |
36-
| filemanager.swift:39:19:39:52 | call to directoryContents(atPath:) | Unexpected result: source=local |
37-
| filemanager.swift:41:23:41:58 | call to subpathsOfDirectory(atPath:) | Unexpected result: source=local |
38-
| filemanager.swift:42:19:42:43 | call to subpaths(atPath:) | Unexpected result: source=local |
39-
| filemanager.swift:44:19:44:60 | call to destinationOfSymbolicLink(atPath:) | Unexpected result: source=local |
40-
| filemanager.swift:45:15:45:56 | call to pathContentOfSymbolicLink(atPath:) | Unexpected result: source=local |
41-
| filemanager.swift:47:14:47:38 | call to contents(atPath:) | Unexpected result: source=local |
42-
| generics.swift:10:9:10:16 | .source1 | Unexpected result: source=remote |
43-
| generics.swift:11:9:11:16 | .source2 | Unexpected result: source=remote |
44-
| generics.swift:12:9:12:24 | call to source3() | Unexpected result: source=remote |
45-
| generics.swift:48:9:48:17 | .source1 | Unexpected result: source=remote |
46-
| generics.swift:49:9:49:17 | .source2 | Unexpected result: source=remote |
47-
| generics.swift:50:9:50:25 | call to source3() | Unexpected result: source=remote |
48-
| generics.swift:51:9:51:18 | .source1 | Unexpected result: source=remote |
49-
| generics.swift:52:9:52:18 | .source2 | Unexpected result: source=remote |
50-
| generics.swift:53:9:53:26 | call to source3() | Unexpected result: source=remote |
51-
| generics.swift:54:9:54:17 | .source1 | Unexpected result: source=remote |
52-
| generics.swift:55:9:55:17 | .source2 | Unexpected result: source=remote |
53-
| generics.swift:56:9:56:25 | call to source3() | Unexpected result: source=remote |
54-
| generics.swift:57:9:57:17 | .source4 | Unexpected result: source=remote |
55-
| generics.swift:58:9:58:17 | .source5 | Unexpected result: source=remote |
56-
| generics.swift:59:9:59:25 | call to source6() | Unexpected result: source=remote |
57-
| generics.swift:60:9:60:17 | .source7 | Unexpected result: source=remote |
58-
| generics.swift:61:9:61:25 | call to source8() | Unexpected result: source=remote |
59-
| generics.swift:62:9:62:18 | .source1 | Unexpected result: source=remote |
60-
| generics.swift:63:9:63:18 | .source2 | Unexpected result: source=remote |
61-
| generics.swift:64:9:64:26 | call to source3() | Unexpected result: source=remote |
62-
| generics.swift:65:9:65:18 | .source9 | Unexpected result: source=remote |
63-
| generics.swift:66:9:66:18 | .source10 | Unexpected result: source=remote |
64-
| generics.swift:67:9:67:27 | call to source11() | Unexpected result: source=remote |
65-
| generics.swift:68:9:68:18 | .source12 | Unexpected result: source=remote |
66-
| generics.swift:69:9:69:27 | call to source13() | Unexpected result: source=remote |
67-
| generics.swift:93:9:93:15 | .source0 | Unexpected result: source=remote |
68-
| generics.swift:94:9:94:15 | .source1 | Unexpected result: source=remote |
69-
| generics.swift:95:9:95:15 | .source2 | Unexpected result: source=remote |
70-
| generics.swift:96:9:96:14 | .source0 | Unexpected result: source=remote |
71-
| generics.swift:97:9:97:14 | .source1 | Unexpected result: source=remote |
72-
| generics.swift:98:9:98:14 | .source2 | Unexpected result: source=remote |
73-
| generics.swift:99:9:99:15 | .source0 | Unexpected result: source=remote |
74-
| generics.swift:100:9:100:15 | .source1 | Unexpected result: source=remote |
75-
| generics.swift:101:9:101:15 | .source2 | Unexpected result: source=remote |
76-
| generics.swift:125:9:125:15 | .source0 | Unexpected result: source=remote |
77-
| generics.swift:126:9:126:15 | .source1 | Unexpected result: source=remote |
78-
| generics.swift:127:9:127:15 | .source2 | Unexpected result: source=remote |
79-
| generics.swift:128:9:128:14 | .source0 | Unexpected result: source=remote |
80-
| generics.swift:129:9:129:14 | .source1 | Unexpected result: source=remote |
81-
| generics.swift:130:9:130:14 | .source2 | Unexpected result: source=remote |
82-
| generics.swift:131:9:131:15 | .source0 | Unexpected result: source=remote |
83-
| generics.swift:132:9:132:15 | .source1 | Unexpected result: source=remote |
84-
| generics.swift:133:9:133:15 | .source2 | Unexpected result: source=remote |
85-
| generics.swift:162:9:162:22 | call to source2() | Unexpected result: source=remote |
86-
| generics.swift:163:9:163:22 | call to source3() | Unexpected result: source=remote |
87-
| nsdata.swift:18:17:18:40 | call to NSData.init(contentsOf:) | Unexpected result: source=remote |
88-
| nsdata.swift:19:17:19:53 | call to NSData.init(contentsOf:options:) | Unexpected result: source=remote |
89-
| string.swift:56:21:56:44 | call to String.init(contentsOf:) | Unexpected result: source=remote |
90-
| string.swift:57:21:57:77 | call to String.init(contentsOf:encoding:) | Unexpected result: source=remote |
91-
| string.swift:59:21:59:69 | call to String.init(contentsOf:usedEncoding:) | Unexpected result: source=remote |
92-
| string.swift:62:21:62:48 | call to String.init(contentsOfFile:) | Unexpected result: source=local |
93-
| string.swift:63:21:63:81 | call to String.init(contentsOfFile:encoding:) | Unexpected result: source=local |
94-
| string.swift:64:21:64:73 | call to String.init(contentsOfFile:usedEncoding:) | Unexpected result: source=local |
95-
| url.swift:53:15:53:19 | .resourceBytes | Unexpected result: source=remote |
96-
| url.swift:60:15:60:19 | .lines | Unexpected result: source=remote |
97-
| url.swift:67:16:67:22 | .lines | Unexpected result: source=remote |
98-
| webview.swift:13:32:13:49 | decidePolicyFor | Unexpected result: source=remote |
99-
| webview.swift:14:32:14:49 | decidePolicyFor | Unexpected result: source=remote |
100-
| webview.swift:41:82:41:102 | message | Unexpected result: source=remote |
101-
| webview.swift:46:5:46:13 | .globalObject | Unexpected result: source=remote |
102-
| webview.swift:47:5:47:39 | call to objectForKeyedSubscript(_:) | Unexpected result: source=remote |
103-
| webview.swift:60:9:60:9 | .tainted | Unexpected result: source=remote |
104-
| webview.swift:64:10:64:10 | self | Unexpected result: source=remote |
105-
| webview.swift:64:18:64:24 | arg1 | Unexpected result: source=remote |
106-
| webview.swift:64:29:64:35 | arg2 | Unexpected result: source=remote |
107-
| webview.swift:72:32:72:49 | decidePolicyFor | Unexpected result: source=remote |
108-
| webview.swift:73:32:73:49 | decidePolicyFor | Unexpected result: source=remote |
109-
| webview.swift:79:32:79:49 | decidePolicyFor | Unexpected result: source=remote |
110-
| webview.swift:80:32:80:49 | decidePolicyFor | Unexpected result: source=remote |

swift/ql/test/library-tests/dataflow/flowsources/alamofire.swift

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ struct DataResponse<Success, Failure: Error> {
8888

8989
let result: Result<Success, Failure>
9090

91-
var value: Success? { result.success } // SOURCE
91+
var value: Success? { result.success } // $ source=remote
9292
}
9393

9494
struct DownloadResponse<Success, Failure: Error> {
9595
let fileURL: URL?
9696

9797
let result: Result<Success, Failure>
9898

99-
var value: Success? { result.success } // SOURCE
99+
var value: Success? { result.success } // $ source=remote
100100
}
101101

102102
typealias AFDataResponse<Success> = DataResponse<Success, AFError>
@@ -341,42 +341,42 @@ func testAlamofire() {
341341

342342
AF.request("http://example.com/").response {
343343
response in
344-
if let data = response.data { // SOURCE
344+
if let data = response.data { // $ source=remote
345345
// ...
346346
}
347347
}
348348

349349
AF.request("http://example.com/").response(responseSerializer: MySerializer()) {
350350
response in
351-
if let obj = response.value { // SOURCE
351+
if let obj = response.value { // $ source=remote
352352
// ...
353353
}
354354
}
355355

356356
AF.request("http://example.com/").responseData {
357357
response in
358-
if let data = response.value { // SOURCE
358+
if let data = response.value { // $ source=remote
359359
// ...
360360
}
361361
}
362362

363363
AF.request("http://example.com/").responseString {
364364
response in
365-
if let str = response.value { // SOURCE
365+
if let str = response.value { // $ source=remote
366366
// ...
367367
}
368368
}
369369

370370
AF.request("http://example.com/").responseJSON {
371371
response in
372-
if let json = response.value { // SOURCE
372+
if let json = response.value { // $ source=remote
373373
// ...
374374
}
375375
}
376376

377377
AF.request("http://example.com/").responseDecodable(of: MyDecodable.self) {
378378
response in
379-
if let decodable = response.value { // SOURCE
379+
if let decodable = response.value { // $ source=remote
380380
// ...
381381
}
382382
}
@@ -386,49 +386,49 @@ func testAlamofire() {
386386
AF.download("http://example.com/").response {
387387
response in
388388
if let path = response.fileURL?.path {
389-
let str = try? String(contentsOfFile: path) // SOURCE
389+
let str = try? String(contentsOfFile: path) // $ MISSING: source=remote $ SPURIOUS: source=local
390390
// ...
391391
}
392392
}
393393

394394
AF.download("http://example.com/").response(responseSerializer: MySerializer()) {
395395
response in
396-
if let obj = response.value { // SOURCE
396+
if let obj = response.value { // $ source=remote
397397
// ...
398398
}
399399
}
400400

401401
AF.download("http://example.com/").responseURL {
402402
response in
403-
if let url = response.value { // just the URL [FALSE POSITIVE]
404-
let str = try? String(contentsOf: url) // SOURCE
403+
if let url = response.value { // $ SPURIOUS: source=remote (this is just the URL)
404+
let str = try? String(contentsOf: url) // $ source=remote
405405
// ...
406406
}
407407
}
408408

409409
AF.download("http://example.com/").responseData {
410410
response in
411-
if let data = response.value { // SOURCE
411+
if let data = response.value { // $ source=remote
412412
// ...
413413
}
414414
}
415415

416416
AF.download("http://example.com/").responseString {
417417
response in
418-
if let str = response.value { // SOURCE
418+
if let str = response.value { // $ source=remote
419419
// ...
420420
}
421421
}
422422

423423
AF.download("http://example.com/").responseJSON {
424424
response in
425-
if let json = response.value { // SOURCE
425+
if let json = response.value { // $ source=remote
426426
}
427427
}
428428

429429
AF.download("http://example.com/").responseDecodable(of: MyDecodable.self) {
430430
response in
431-
if let decodable = response.value { // SOURCE
431+
if let decodable = response.value { // $ source=remote
432432
// ...
433433
}
434434
}
@@ -445,20 +445,20 @@ func testAlamofire() {
445445
// ...
446446
}
447447
// ...
448-
let str = try? String(contentsOfFile: myPath) // SOURCE
448+
let str = try? String(contentsOfFile: myPath) // $ MISSING: source=remote SPURIOUS: source=local
449449

450450
// chaining
451451
// - in practice there are a wide range of calls that can be chained through.
452452

453453
AF.request("http://example.com/").response {
454454
response in
455-
if let data = response.data { // SOURCE
455+
if let data = response.data { // $ source=remote
456456
// ...
457457
}
458458
}
459459
.response {
460460
response in
461-
if let data = response.data { // SOURCE
461+
if let data = response.data { // $ source=remote
462462
// ...
463463
}
464464
}
@@ -470,7 +470,7 @@ func testAlamofire() {
470470
switch stream.event {
471471
case let .stream(result):
472472
switch result {
473-
case let .success(data): // SOURCE [NOT DETECTED]
473+
case let .success(data): // $ MISSING: source=remote
474474
doSomethingWith(data)
475475
// ...
476476
}
@@ -485,7 +485,7 @@ func testAlamofire() {
485485
switch stream.event {
486486
case let .stream(result):
487487
switch result {
488-
case let .success(value): // SOURCE [NOT DETECTED]
488+
case let .success(value): // $ MISSING: source=remote
489489
doSomethingWith(value)
490490
// ...
491491
}
@@ -500,7 +500,7 @@ func testAlamofire() {
500500
switch stream.event {
501501
case let .stream(result):
502502
switch result {
503-
case let .success(value): // SOURCE [NOT DETECTED]
503+
case let .success(value): // MISSING: source=remote
504504
doSomethingWith(value)
505505
// ...
506506
}
@@ -515,7 +515,7 @@ func testAlamofire() {
515515
switch stream.event {
516516
case let .stream(result):
517517
switch result {
518-
case let .success(value): // SOURCE [NOT DETECTED]
518+
case let .success(value): // MISSING: source=remote
519519
doSomethingWith(value)
520520
// ...
521521
}
@@ -530,7 +530,7 @@ func testAlamofire() {
530530
AF.streamRequest("http://example.com/").responseStream {
531531
stream in
532532
if case let .stream(myResult) = stream.event {
533-
if case let .success(myData) = myResult { // SOURCE [NOT DETECTED]
533+
if case let .success(myData) = myResult { // MISSING: source=remote
534534
doSomethingWith(myData)
535535
}
536536
}
@@ -539,7 +539,7 @@ func testAlamofire() {
539539
AF.streamRequest("http://example.com/").responseStream {
540540
stream in
541541
if case let .stream(myResult) = stream.event {
542-
doSomethingWith(myResult.success!) // SOURCE [NOT DETECTED]
542+
doSomethingWith(myResult.success!) // MISSING: source=remote
543543
}
544544
}
545545

0 commit comments

Comments
 (0)