Skip to content

Commit cf7cd2b

Browse files
committed
Swift: Convert to MaD.
1 parent 03ae282 commit cf7cd2b

File tree

2 files changed

+11
-46
lines changed

2 files changed

+11
-46
lines changed

swift/ql/lib/codeql/swift/frameworks/Alamofire/Alamofire.qll

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,16 @@ private import codeql.swift.dataflow.DataFlow
77
private import codeql.swift.dataflow.ExternalFlow
88
private import codeql.swift.dataflow.FlowSources
99

10-
/**
11-
* An Alamofire response handler type.
12-
*/
13-
private class AlamofireResponseType extends NominalTypeDecl {
14-
AlamofireResponseType() {
15-
this.getABaseTypeDecl*().getFullName() = ["DataResponse", "DownloadResponse"]
16-
}
17-
18-
/**
19-
* Gets a field that contains remote data.
20-
*/
21-
FieldDecl getADataField() {
22-
result = this.getAMember() and
23-
result.getName() = ["data", "value", "result"]
24-
}
25-
}
26-
27-
/**
28-
* A remote flow source that is an access to remote data from an Alamofire response handler.
29-
*/
30-
private class AlamofireResponseSource extends RemoteFlowSource {
31-
AlamofireResponseSource() {
32-
exists(AlamofireResponseType responseType |
33-
this.asExpr().(MemberRefExpr).getMember() = responseType.getADataField()
34-
)
10+
private class StringSource extends SourceModelCsv {
11+
override predicate row(string row) {
12+
row =
13+
[
14+
// `DataResponse.data`, `.value`, `.result`
15+
";DataResponse;true;data;;;;remote", ";DataResponse;true;value;;;;remote",
16+
";DataResponse;true;result;;;;remote",
17+
// `DownloadResponse.data`, `.value`, `.result`
18+
";DownloadResponse;true;data;;;;remote", ";DownloadResponse;true;value;;;;remote",
19+
";DownloadResponse;true;result;;;;remote",
20+
]
3521
}
36-
37-
override string getSourceType() { result = "Data from an Alamofire response" }
3822
}

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,16 @@
1-
| alamofire.swift:91:27:91:27 | .result | Data from an Alamofire response |
2-
| alamofire.swift:99:27:99:27 | .result | Data from an Alamofire response |
3-
| alamofire.swift:342:23:342:32 | .data | Data from an Alamofire response |
4-
| alamofire.swift:349:22:349:31 | .value | Data from an Alamofire response |
5-
| alamofire.swift:356:23:356:32 | .value | Data from an Alamofire response |
6-
| alamofire.swift:363:22:363:31 | .value | Data from an Alamofire response |
7-
| alamofire.swift:370:23:370:32 | .value | Data from an Alamofire response |
8-
| alamofire.swift:377:28:377:37 | .value | Data from an Alamofire response |
91
| alamofire.swift:387:28:387:28 | call to init(contentsOfFile:) | external |
102
| alamofire.swift:387:28:387:55 | call to init(contentsOfFile:) | external |
11-
| alamofire.swift:394:22:394:31 | .value | Data from an Alamofire response |
12-
| alamofire.swift:401:22:401:31 | .value | Data from an Alamofire response |
133
| alamofire.swift:402:28:402:28 | call to init(contentsOf:) | external |
144
| alamofire.swift:402:28:402:50 | call to init(contentsOf:) | external |
15-
| alamofire.swift:409:23:409:32 | .value | Data from an Alamofire response |
16-
| alamofire.swift:416:22:416:31 | .value | Data from an Alamofire response |
17-
| alamofire.swift:423:23:423:32 | .value | Data from an Alamofire response |
18-
| alamofire.swift:429:28:429:37 | .value | Data from an Alamofire response |
195
| alamofire.swift:446:20:446:20 | call to init(contentsOfFile:) | external |
206
| alamofire.swift:446:20:446:49 | call to init(contentsOfFile:) | external |
21-
| alamofire.swift:453:23:453:32 | .data | Data from an Alamofire response |
22-
| alamofire.swift:459:23:459:32 | .data | Data from an Alamofire response |
237
| customurlschemes.swift:30:44:30:54 | url | external |
248
| customurlschemes.swift:34:52:34:68 | url | external |
259
| customurlschemes.swift:38:52:38:62 | url | external |
2610
| customurlschemes.swift:43:9:43:28 | ...[...] | Remote URL in UIApplicationDelegate.application.launchOptions |
2711
| customurlschemes.swift:48:9:48:28 | ...[...] | Remote URL in UIApplicationDelegate.application.launchOptions |
2812
| data.swift:18:20:18:20 | call to init(contentsOf:options:) | external |
2913
| data.swift:18:20:18:54 | call to init(contentsOf:options:) | external |
30-
| file://:0:0:0:0 | .data | Data from an Alamofire response |
31-
| file://:0:0:0:0 | .result | Data from an Alamofire response |
32-
| file://:0:0:0:0 | .result | Data from an Alamofire response |
3314
| nsdata.swift:18:17:18:17 | call to init(contentsOf:) | external |
3415
| nsdata.swift:18:17:18:40 | call to init(contentsOf:) | external |
3516
| nsdata.swift:19:17:19:17 | call to init(contentsOf:options:) | external |

0 commit comments

Comments
 (0)