Skip to content

Swift: Add more test cases for application(...launchOptions...). #15125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down