Files
codeql/java/ql/integration-tests/posix-only/kotlin/kotlin-interface-inherited-default/test.ql
Chris Smowton 14b8892ced Don't create interface forwarders for other interfaces, and target super accesses correctly
Intermediate interfaces don't need interface forwarders, since the Kotlin compiler won't try to make them non-abstract by synthesising methods.

Super references should always target an immediate superclass, not the ancestor containing the intended implementation.
2022-10-19 15:37:06 +01:00

37 lines
1.0 KiB
Plaintext

import java
import semmle.code.java.dataflow.DataFlow
query predicate callables(Callable c, RefType declType, string kind) {
c.fromSource() and
declType = c.getDeclaringType() and
(
kind = c.compilerGeneratedReason()
or
not exists(c.compilerGeneratedReason()) and kind = "from source"
)
}
query predicate superAccesses(
SuperAccess sa, RefType enclosingType, Callable enclosingCallable, Expr qualifier
) {
sa.getQualifier() = qualifier and
enclosingCallable = sa.getEnclosingCallable() and
enclosingType = enclosingCallable.getDeclaringType()
}
class Config extends DataFlow::Configuration {
Config() { this = "testconfig" }
override predicate isSource(DataFlow::Node x) {
x.asExpr() instanceof IntegerLiteral and x.getEnclosingCallable().fromSource()
}
override predicate isSink(DataFlow::Node x) {
x.asExpr().(Argument).getCall().getCallee().getName() = "sink"
}
}
from Config c, DataFlow::Node source, DataFlow::Node sink
where c.hasFlow(source, sink)
select source, sink