Swift: Add more test cases for launchOptions as a source.

This commit is contained in:
Geoffrey White
2023-12-15 18:11:28 +00:00
parent dc9c538fcc
commit 1908575386

View File

@@ -80,14 +80,45 @@ class AppDelegate: UIApplicationDelegate {
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]?) -> Bool {
_ = launchOptions?[.url] // $ source=remote
let url = launchOptions?[.url] // $ source=remote
sink(arg: url) // $ tainted
return true
}
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]?) -> Bool {
_ = launchOptions?[.url] // $ source=remote
let url = launchOptions?[.url] // $ source=remote
sink(arg: url) // $ tainted
let url2 = launchOptions?[.url] as! String // $ source=remote
sink(arg: url2) // $ tainted
if let url3 = launchOptions?[.url] as? String { // $ source=remote
sink(arg: url3) // $ tainted
}
if let options = launchOptions {
let url4 = options[.url] as! String // $ source=remote
sink(arg: url4) // $ tainted
}
switch launchOptions {
case .some(let options):
let url5 = options[.url] // $ MISSING: source=remote
sink(arg: url5) // $ MISSING: tainted
case .none:
break
}
processLaunchOptions(options: launchOptions)
return true
}
private func processLaunchOptions(options: [UIApplication.LaunchOptionsKey : Any]?) {
// (called above)
let url = options?[.url] // $ MISSING: source=remote
sink(arg: url) // $ MISSING: tainted
}
}
class SceneDelegate : UISceneDelegate {