Files
codeql/java/ql/test/library-tests/dataflow/callback-dispatch/test.ql
2022-12-05 09:49:38 +01:00

31 lines
975 B
Plaintext

import java
import semmle.code.java.dataflow.DataFlow
import TestUtilities.InlineExpectationsTest
class Conf extends DataFlow::Configuration {
Conf() { this = "qltest:callback-dispatch" }
override predicate isSource(DataFlow::Node n) {
n.asExpr().(MethodAccess).getMethod().hasName("source")
}
override predicate isSink(DataFlow::Node n) {
exists(MethodAccess ma | ma.getMethod().hasName("sink") | n.asExpr() = ma.getAnArgument())
}
}
class HasFlowTest extends InlineExpectationsTest {
HasFlowTest() { this = "HasFlowTest" }
override string getARelevantTag() { result = "flow" }
override predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "flow" and
exists(DataFlow::Node src, DataFlow::Node sink, Conf conf | conf.hasFlow(src, sink) |
sink.getLocation() = location and
element = sink.toString() and
value = src.asExpr().(MethodAccess).getAnArgument().toString()
)
}
}