mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
Add test for StmtExpr flow
This commit is contained in:
committed by
Ian Lynagh
parent
8af0f26411
commit
b626e80a61
@@ -0,0 +1,16 @@
|
||||
class StmtExpr {
|
||||
fun test() {
|
||||
val t = object : Source {
|
||||
override fun a() {
|
||||
}
|
||||
}
|
||||
sink(t) // $ hasValueFlow
|
||||
}
|
||||
|
||||
fun sink(t : Source) {}
|
||||
|
||||
}
|
||||
|
||||
interface Source {
|
||||
fun a()
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
| StmtExpr.kt:3:17:6:9 | new (...) | StmtExpr.kt:7:14:7:14 | t |
|
||||
18
java/ql/test/kotlin/library-tests/dataflow/stmtexpr/test.ql
Normal file
18
java/ql/test/kotlin/library-tests/dataflow/stmtexpr/test.ql
Normal file
@@ -0,0 +1,18 @@
|
||||
import java
|
||||
import semmle.code.java.dataflow.DataFlow
|
||||
|
||||
class Conf extends DataFlow::Configuration {
|
||||
Conf() { this = "qltest:exprStmtFlow" }
|
||||
|
||||
override predicate isSource(DataFlow::Node n) {
|
||||
n.asExpr().(ClassInstanceExpr).getType().(RefType).getASupertype*().hasName("Source")
|
||||
}
|
||||
|
||||
override predicate isSink(DataFlow::Node n) {
|
||||
n.asExpr().(Argument).getCall().getCallee().hasName("sink")
|
||||
}
|
||||
}
|
||||
|
||||
from DataFlow::Node src, DataFlow::Node sink, Conf conf
|
||||
where conf.hasFlow(src, sink)
|
||||
select src, sink
|
||||
Reference in New Issue
Block a user