Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f12bcc5

Browse files
tamasvajkigfoo
authored andcommitted
Add dataflow test for property reference being used as lambda
1 parent 257224a commit f12bcc5

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

java/ql/test/kotlin/library-tests/dataflow/func/functionReference.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,10 @@ class FunctionReference {
1010
Helper.sink(Processor().process(this::fn1, Helper.notaint()))
1111
Helper.sink(Processor().process(::fn2, Helper.taint()))
1212
Helper.sink(Processor().process(::fn2, Helper.notaint()))
13+
14+
Helper.sink(Processor().process(this::prop))
1315
}
16+
17+
val prop: String
18+
get() = Helper.taint()
1419
}

java/ql/test/kotlin/library-tests/dataflow/func/test.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
| functionReference.kt:8:59:8:65 | taint(...) | functionReference.kt:8:33:8:66 | process(...) |
22
| functionReference.kt:9:78:9:84 | taint(...) | functionReference.kt:9:33:9:85 | process(...) |
33
| functionReference.kt:11:55:11:61 | taint(...) | functionReference.kt:11:33:11:62 | process(...) |
4+
| functionReference.kt:18:24:18:30 | taint(...) | functionReference.kt:14:33:14:51 | process(...) |
45
| lambda.kt:4:64:4:70 | taint(...) | lambda.kt:4:33:4:77 | process(...) |
56
| lambda.kt:5:60:5:66 | taint(...) | lambda.kt:5:33:5:67 | process(...) |
67
| lambda.kt:6:69:6:75 | taint(...) | lambda.kt:6:33:6:76 | process(...) |

java/ql/test/kotlin/library-tests/dataflow/func/util.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
class Processor {
2+
fun <R> process(f: () -> R) : R {
3+
return f()
4+
}
5+
26
fun <T, R> process(f: (T) -> R, arg: T) : R {
37
return f(arg)
48
}

0 commit comments

Comments
 (0)