Refactor Android tests

This commit is contained in:
Ed Minnix
2023-04-13 21:43:59 -04:00
parent 95c28967cc
commit f745642252
5 changed files with 44 additions and 38 deletions

View File

@@ -4,16 +4,16 @@ import semmle.code.java.dataflow.FlowSources
import semmle.code.java.security.QueryInjection
import TestUtilities.InlineExpectationsTest
class Conf extends TaintTracking::Configuration {
Conf() { this = "qltest:dataflow:android::flow" }
override predicate isSource(DataFlow::Node source) {
module Config implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) {
source.asExpr().(MethodAccess).getMethod().hasName("taint")
}
override predicate isSink(DataFlow::Node sink) { sink.asExpr() = any(ReturnStmt r).getResult() }
predicate isSink(DataFlow::Node sink) { sink.asExpr() = any(ReturnStmt r).getResult() }
}
module Flow = TaintTracking::Global<Config>;
class FlowStepTest extends InlineExpectationsTest {
FlowStepTest() { this = "FlowStepTest" }
@@ -22,8 +22,7 @@ class FlowStepTest extends InlineExpectationsTest {
override predicate hasActualResult(Location l, string element, string tag, string value) {
tag = "taintReachesReturn" and
value = "" and
exists(Conf conf, DataFlow::Node source |
conf.hasFlow(source, _) and
exists(DataFlow::Node source | Flow::flow(source, _) |
l = source.getLocation() and
element = source.toString()
)