Merge pull request #9898 from smowton/smowton/fix/kotlin-super-calls

Kotlin: implement super-method calls
This commit is contained in:
Chris Smowton
2022-07-27 11:31:36 +01:00
committed by GitHub
4 changed files with 84 additions and 8 deletions

View File

@@ -0,0 +1,2 @@
| test.kt:31:17:31:24 | source(...) | test.kt:31:15:31:25 | f(...) |
| test.kt:32:17:32:24 | source(...) | test.kt:32:15:32:25 | g(...) |

View File

@@ -0,0 +1,36 @@
open class A {
open fun f(x: String) = x
}
interface B {
fun g(x: String) = x
}
interface C {
fun g(x: String) = x
}
class User : A(), B, C {
override fun f(x: String) = super.f(x)
override fun g(x: String) = super<B>.g(x)
fun source() = "tainted"
fun sink(s: String) { }
fun test() {
sink(this.f(source()))
sink(this.g(source()))
}
}

View File

@@ -0,0 +1,18 @@
import java
import semmle.code.java.dataflow.DataFlow
class Config extends DataFlow::Configuration {
Config() { this = "abc" }
override predicate isSource(DataFlow::Node n) {
n.asExpr().(MethodAccess).getMethod().getName() = "source"
}
override predicate isSink(DataFlow::Node n) {
n.asExpr().(Argument).getCall().getCallee().getName() = "sink"
}
}
from Config c, DataFlow::Node n1, DataFlow::Node n2
where c.hasFlow(n1, n2)
select n1, n2