mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Swift: Add taint test of try.
This commit is contained in:
19
swift/ql/test/library-tests/dataflow/taint/try.swift
Normal file
19
swift/ql/test/library-tests/dataflow/taint/try.swift
Normal 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]
|
||||
}
|
||||
Reference in New Issue
Block a user