Skip to content

Commit 242dc80

Browse files
committed
Swift: Add taint test of try.
1 parent 3bda9af commit 242dc80

File tree

1 file changed

+19
-0
lines changed
  • swift/ql/test/library-tests/dataflow/taint

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
func clean() throws -> String { return ""; }
2+
func source() throws -> String { return ""; }
3+
func sink(arg: String) {}
4+
5+
func taintThroughTry() {
6+
do
7+
{
8+
sink(arg: try clean())
9+
sink(arg: try source()) // tainted [NOT DETECTED]
10+
} catch {
11+
// ...
12+
}
13+
14+
sink(arg: try! clean())
15+
sink(arg: try! source()) // tainted [NOT DETECTED]
16+
17+
sink(arg: (try? clean())!)
18+
sink(arg: (try? source())!) // tainted [NOT DETECTED]
19+
}

0 commit comments

Comments
 (0)