Skip to content

Commit 2eda592

Browse files
authored
Merge pull request #15125 from geoffw0/launchoptions
Swift: Add more test cases for application(...launchOptions...).
2 parents dc9c538 + 1908575 commit 2eda592

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

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

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,45 @@ class AppDelegate: UIApplicationDelegate {
8080
}
8181

8282
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]?) -> Bool {
83-
_ = launchOptions?[.url] // $ source=remote
83+
let url = launchOptions?[.url] // $ source=remote
84+
sink(arg: url) // $ tainted
8485
return true
8586
}
8687

8788
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]?) -> Bool {
88-
_ = launchOptions?[.url] // $ source=remote
89+
let url = launchOptions?[.url] // $ source=remote
90+
sink(arg: url) // $ tainted
91+
92+
let url2 = launchOptions?[.url] as! String // $ source=remote
93+
sink(arg: url2) // $ tainted
94+
95+
if let url3 = launchOptions?[.url] as? String { // $ source=remote
96+
sink(arg: url3) // $ tainted
97+
}
98+
99+
if let options = launchOptions {
100+
let url4 = options[.url] as! String // $ source=remote
101+
sink(arg: url4) // $ tainted
102+
}
103+
104+
switch launchOptions {
105+
case .some(let options):
106+
let url5 = options[.url] // $ MISSING: source=remote
107+
sink(arg: url5) // $ MISSING: tainted
108+
case .none:
109+
break
110+
}
111+
112+
processLaunchOptions(options: launchOptions)
113+
89114
return true
90115
}
116+
117+
private func processLaunchOptions(options: [UIApplication.LaunchOptionsKey : Any]?) {
118+
// (called above)
119+
let url = options?[.url] // $ MISSING: source=remote
120+
sink(arg: url) // $ MISSING: tainted
121+
}
91122
}
92123

93124
class SceneDelegate : UISceneDelegate {

0 commit comments

Comments
 (0)