mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
Add test for NotNullExpr flow
This commit is contained in:
committed by
Ian Lynagh
parent
4e18974889
commit
cf5152baa2
@@ -0,0 +1,14 @@
|
||||
class NotNullExpr {
|
||||
fun taint() = Uri()
|
||||
|
||||
fun sink(s: String) { }
|
||||
|
||||
fun bad() {
|
||||
val s0 = taint()
|
||||
sink(s0!!.getQueryParameter())
|
||||
}
|
||||
}
|
||||
|
||||
class Uri {
|
||||
fun getQueryParameter() = "tainted"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
| NotNullExpr.kt:7:14:7:20 | taint(...) | NotNullExpr.kt:8:15:8:33 | getQueryParameter(...) |
|
||||
@@ -0,0 +1,25 @@
|
||||
import java
|
||||
import semmle.code.java.dataflow.TaintTracking
|
||||
import semmle.code.java.dataflow.ExternalFlow
|
||||
|
||||
class Step extends SummaryModelCsv {
|
||||
override predicate row(string row) {
|
||||
row = ";Uri;false;getQueryParameter;;;Argument[-1];ReturnValue;taint"
|
||||
}
|
||||
}
|
||||
|
||||
class Conf extends TaintTracking::Configuration {
|
||||
Conf() { this = "qltest:notNullExprFlow" }
|
||||
|
||||
override predicate isSource(DataFlow::Node n) {
|
||||
n.asExpr().(MethodAccess).getMethod().hasName("taint")
|
||||
}
|
||||
|
||||
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