Swift: Add taint test of try.

This commit is contained in:
Geoffrey White
2022-08-09 17:18:45 +01:00
parent 3bda9af97a
commit 242dc80907

View File

@@ -0,0 +1,19 @@
func clean() throws -> String { return ""; }
func source() throws -> String { return ""; }
func sink(arg: String) {}
func taintThroughTry() {
do
{
sink(arg: try clean())
sink(arg: try source()) // tainted [NOT DETECTED]
} catch {
// ...
}
sink(arg: try! clean())
sink(arg: try! source()) // tainted [NOT DETECTED]
sink(arg: (try? clean())!)
sink(arg: (try? source())!) // tainted [NOT DETECTED]
}