From 124487c57cfd374b539ea57eadb8e2ff87d099e9 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Tue, 5 Dec 2023 14:40:47 +0000 Subject: [PATCH] Kotlin: Add more taint tests --- .../test-kotlin1/library-tests/dataflow/foreach/C2.kt | 11 +++++++++++ .../library-tests/dataflow/foreach/test.expected | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/java/ql/test-kotlin1/library-tests/dataflow/foreach/C2.kt b/java/ql/test-kotlin1/library-tests/dataflow/foreach/C2.kt index fdef81ffed7..e8bec66e974 100644 --- a/java/ql/test-kotlin1/library-tests/dataflow/foreach/C2.kt +++ b/java/ql/test-kotlin1/library-tests/dataflow/foreach/C2.kt @@ -16,4 +16,15 @@ class C2 { sink(s) } } + + fun test2() { + val l1 = arrayOf("") + val l2 = arrayOf("") + l1[0] = taint("a") + l2.set(0, taint("a")) + sink(l1[0]) + sink(l2[0]) + sink(l1.get(0)) + sink(l2.get(0)) + } } diff --git a/java/ql/test-kotlin1/library-tests/dataflow/foreach/test.expected b/java/ql/test-kotlin1/library-tests/dataflow/foreach/test.expected index 432b6d8a87c..29b8c7b7c82 100644 --- a/java/ql/test-kotlin1/library-tests/dataflow/foreach/test.expected +++ b/java/ql/test-kotlin1/library-tests/dataflow/foreach/test.expected @@ -7,3 +7,7 @@ | C2.kt:8:32:8:32 | "a" | C2.kt:11:14:11:21 | get(...) | | C2.kt:8:32:8:32 | "a" | C2.kt:13:18:13:21 | ...[...] | | C2.kt:8:32:8:32 | "a" | C2.kt:16:18:16:18 | s | +| C2.kt:23:24:23:24 | "a" | C2.kt:25:14:25:18 | ...[...] | +| C2.kt:23:24:23:24 | "a" | C2.kt:27:14:27:22 | get(...) | +| C2.kt:24:26:24:26 | "a" | C2.kt:26:14:26:18 | ...[...] | +| C2.kt:24:26:24:26 | "a" | C2.kt:28:14:28:22 | get(...) |