mirror of
https://github.com/github/codeql.git
synced 2026-05-05 21:55:19 +02:00
Kotlin: Add flow through use and with
This commit is contained in:
11
java/ql/test/kotlin/library-tests/dataflow/summaries/use.kt
Normal file
11
java/ql/test/kotlin/library-tests/dataflow/summaries/use.kt
Normal file
@@ -0,0 +1,11 @@
|
||||
import java.io.Closeable
|
||||
|
||||
class UseFlowTest {
|
||||
fun <T> taint(t: T) = t
|
||||
fun sink(s: Closeable) { }
|
||||
|
||||
fun test(input: Closeable) {
|
||||
taint(input).use { it -> sink(it) } // $ hasValueFlow
|
||||
sink(taint(input).use { it }) // $ hasValueFlow
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class WithFlowTest {
|
||||
fun <T> taint(t: T) = t
|
||||
fun sink(s: String) { }
|
||||
|
||||
fun test(input: String) {
|
||||
with(taint(input)) { sink(this) } // $ hasValueFlow
|
||||
sink(with(taint(input)) { this }) // $ hasValueFlow
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user