Skip to content

Commit fc810dd

Browse files
authored
Merge pull request github#10775 from atorralba/atorralba/swift/custom-url-scheme-sources
Swift: Add taint sources for custom URL scheme URLs
2 parents af79139 + f4d43de commit fc810dd

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

swift/ql/lib/codeql/swift/dataflow/ExternalFlow.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ private import internal.FlowSummaryImplSpecific
7878
* ensuring that they are visible to the taint tracking / data flow library.
7979
*/
8080
private module Frameworks {
81+
private import codeql.swift.frameworks.StandardLibrary.CustomUrlSchemes
8182
private import codeql.swift.frameworks.StandardLibrary.String
8283
private import codeql.swift.frameworks.StandardLibrary.Url
8384
private import codeql.swift.frameworks.StandardLibrary.UrlSession
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import swift
2+
private import codeql.swift.dataflow.ExternalFlow
3+
4+
private class UrlRemoteFlowSource extends SourceModelCsv {
5+
override predicate row(string row) {
6+
row =
7+
[
8+
";UIApplicationDelegate;true;application(_:open:options:);;;Parameter[1];remote",
9+
";UIApplicationDelegate;true;application(_:handleOpen:);;;Parameter[1];remote",
10+
";UIApplicationDelegate;true;application(_:open:sourceApplication:annotation:);;;Parameter[1];remote"
11+
]
12+
}
13+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
| customurlschemes.swift:17:44:17:54 | url | external |
2+
| customurlschemes.swift:20:52:20:68 | url | external |
3+
| customurlschemes.swift:23:52:23:62 | url | external |
14
| string.swift:27:21:27:21 | call to init(contentsOf:) | external |
25
| string.swift:27:21:27:44 | call to init(contentsOf:) | external |
36
| url.swift:53:15:53:19 | .resourceBytes | external |
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// --- stubs ---
2+
class UIApplication {
3+
struct OpenURLOptionsKey {}
4+
}
5+
6+
struct URL {}
7+
8+
protocol UIApplicationDelegate {
9+
optional func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool
10+
optional func application(_ application: UIApplication, handleOpen url: URL) -> Bool
11+
optional func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool
12+
}
13+
14+
// --- tests ---
15+
16+
class AppDelegate: UIApplicationDelegate {
17+
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool { // SOURCE
18+
}
19+
20+
func application(_ application: UIApplication, handleOpen url: URL) -> Bool { // SOURCE
21+
}
22+
23+
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool { // SOURCE
24+
}
25+
26+
}

0 commit comments

Comments
 (0)