From 242dc80907b703edaad8b9111549a48c877dd95c Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Tue, 9 Aug 2022 17:18:45 +0100 Subject: [PATCH] Swift: Add taint test of try. --- .../library-tests/dataflow/taint/try.swift | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 swift/ql/test/library-tests/dataflow/taint/try.swift diff --git a/swift/ql/test/library-tests/dataflow/taint/try.swift b/swift/ql/test/library-tests/dataflow/taint/try.swift new file mode 100644 index 00000000000..caa851dc0b0 --- /dev/null +++ b/swift/ql/test/library-tests/dataflow/taint/try.swift @@ -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] +}