mirror of
https://github.com/github/codeql.git
synced 2025-12-19 10:23:15 +01:00
This adds methods that fill in default parameters whenever a constructor or method uses default parameter values. I use as similar an approach to the real Kotlin compiler as possible both because this produces the desirable dataflow, and because it should merge cleanly with the same class file seen by the Java extractor, which will see and extract the signatures of the default methods.
35 lines
935 B
Plaintext
35 lines
935 B
Plaintext
import java
|
|
import semmle.code.java.dataflow.DataFlow
|
|
|
|
class ShouldNotBeSunk extends StringLiteral {
|
|
ShouldNotBeSunk() { this.getValue().matches("%not sunk%") }
|
|
}
|
|
|
|
class ShouldBeSunk extends StringLiteral {
|
|
ShouldBeSunk() {
|
|
this.getValue().matches("%sunk%") and
|
|
not this instanceof ShouldNotBeSunk
|
|
}
|
|
}
|
|
|
|
class Config extends DataFlow::Configuration {
|
|
Config() { this = "Config" }
|
|
|
|
override predicate isSource(DataFlow::Node n) {
|
|
n.asExpr() instanceof ShouldBeSunk or
|
|
n.asExpr() instanceof ShouldNotBeSunk
|
|
}
|
|
|
|
override predicate isSink(DataFlow::Node n) {
|
|
n.asExpr().(Argument).getCall().getCallee().getName() = "sink"
|
|
}
|
|
}
|
|
|
|
predicate isSunk(StringLiteral sl) {
|
|
exists(Config c, DataFlow::Node source | c.hasFlow(source, _) and sl = source.asExpr())
|
|
}
|
|
|
|
query predicate shouldBeSunkButIsnt(ShouldBeSunk src) { not isSunk(src) }
|
|
|
|
query predicate shouldntBeSunkButIs(ShouldNotBeSunk src) { isSunk(src) }
|