mirror of
https://github.com/github/codeql.git
synced 2026-04-30 03:05:15 +02:00
Use InlineExpectationsTest directly
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import java
|
||||
import semmle.code.java.dataflow.FlowSources
|
||||
import TestUtilities.InlineFlowTest
|
||||
import TestUtilities.InlineExpectationsTest
|
||||
|
||||
class LocalSource extends DataFlow::Node {
|
||||
LocalSource() {
|
||||
@@ -9,20 +9,34 @@ class LocalSource extends DataFlow::Node {
|
||||
}
|
||||
}
|
||||
|
||||
class LocalValueConf extends DefaultValueFlowConf {
|
||||
override predicate isSource(DataFlow::Node n) { n instanceof LocalSource }
|
||||
predicate isTestSink(DataFlow::Node n) {
|
||||
exists(MethodAccess ma | ma.getMethod().hasName("sink") | n.asExpr() = ma.getAnArgument())
|
||||
}
|
||||
|
||||
class LocalTaintConf extends DefaultTaintFlowConf {
|
||||
class LocalValueConf extends DataFlow::Configuration {
|
||||
LocalValueConf() { this = "LocalValueConf" }
|
||||
|
||||
override predicate isSource(DataFlow::Node n) { n instanceof LocalSource }
|
||||
|
||||
override predicate isSink(DataFlow::Node n) { isTestSink(n) }
|
||||
}
|
||||
|
||||
class LocalFlowTest extends InlineFlowTest {
|
||||
class LocalTaintConf extends TaintTracking::Configuration {
|
||||
LocalTaintConf() { this = "LocalTaintConf" }
|
||||
|
||||
override predicate isSource(DataFlow::Node n) { n instanceof LocalSource }
|
||||
|
||||
override predicate isSink(DataFlow::Node n) { isTestSink(n) }
|
||||
}
|
||||
|
||||
class LocalFlowTest extends InlineExpectationsTest {
|
||||
LocalFlowTest() { this = "LocalFlowTest" }
|
||||
|
||||
override string getARelevantTag() { result = ["hasLocalValueFlow", "hasLocalTaintFlow"] }
|
||||
|
||||
override predicate hasActualResult(Location location, string element, string tag, string value) {
|
||||
tag = "hasLocalValueFlow" and
|
||||
exists(DataFlow::Node src, DataFlow::Node sink | getValueFlowConfig().hasFlow(src, sink) |
|
||||
exists(DataFlow::Node src, DataFlow::Node sink | any(LocalValueConf c).hasFlow(src, sink) |
|
||||
sink.getLocation() = location and
|
||||
element = sink.toString() and
|
||||
value = ""
|
||||
@@ -30,7 +44,7 @@ class LocalFlowTest extends InlineFlowTest {
|
||||
or
|
||||
tag = "hasLocalTaintFlow" and
|
||||
exists(DataFlow::Node src, DataFlow::Node sink |
|
||||
getTaintFlowConfig().hasFlow(src, sink) and not getValueFlowConfig().hasFlow(src, sink)
|
||||
any(LocalTaintConf c).hasFlow(src, sink) and not any(LocalValueConf c).hasFlow(src, sink)
|
||||
|
|
||||
sink.getLocation() = location and
|
||||
element = sink.toString() and
|
||||
|
||||
@@ -1,21 +1,35 @@
|
||||
import java
|
||||
import semmle.code.java.dataflow.FlowSources
|
||||
import TestUtilities.InlineFlowTest
|
||||
import TestUtilities.InlineExpectationsTest
|
||||
|
||||
class RemoteValueConf extends DefaultValueFlowConf {
|
||||
override predicate isSource(DataFlow::Node n) { n instanceof RemoteFlowSource }
|
||||
predicate isTestSink(DataFlow::Node n) {
|
||||
exists(MethodAccess ma | ma.getMethod().hasName("sink") | n.asExpr() = ma.getAnArgument())
|
||||
}
|
||||
|
||||
class RemoteTaintConf extends DefaultTaintFlowConf {
|
||||
class RemoteValueConf extends DataFlow::Configuration {
|
||||
RemoteValueConf() { this = "RemoteValueConf" }
|
||||
|
||||
override predicate isSource(DataFlow::Node n) { n instanceof RemoteFlowSource }
|
||||
|
||||
override predicate isSink(DataFlow::Node n) { isTestSink(n) }
|
||||
}
|
||||
|
||||
class RemoteFlowTest extends InlineFlowTest {
|
||||
class RemoteTaintConf extends TaintTracking::Configuration {
|
||||
RemoteTaintConf() { this = "RemoteTaintConf" }
|
||||
|
||||
override predicate isSource(DataFlow::Node n) { n instanceof RemoteFlowSource }
|
||||
|
||||
override predicate isSink(DataFlow::Node n) { isTestSink(n) }
|
||||
}
|
||||
|
||||
class RemoteFlowTest extends InlineExpectationsTest {
|
||||
RemoteFlowTest() { this = "RemoteFlowTest" }
|
||||
|
||||
override string getARelevantTag() { result = ["hasRemoteValueFlow", "hasRemoteTaintFlow"] }
|
||||
|
||||
override predicate hasActualResult(Location location, string element, string tag, string value) {
|
||||
tag = "hasRemoteValueFlow" and
|
||||
exists(DataFlow::Node src, DataFlow::Node sink | getValueFlowConfig().hasFlow(src, sink) |
|
||||
exists(DataFlow::Node src, DataFlow::Node sink | any(RemoteValueConf c).hasFlow(src, sink) |
|
||||
sink.getLocation() = location and
|
||||
element = sink.toString() and
|
||||
value = ""
|
||||
@@ -23,7 +37,7 @@ class RemoteFlowTest extends InlineFlowTest {
|
||||
or
|
||||
tag = "hasRemoteTaintFlow" and
|
||||
exists(DataFlow::Node src, DataFlow::Node sink |
|
||||
getTaintFlowConfig().hasFlow(src, sink) and not getValueFlowConfig().hasFlow(src, sink)
|
||||
any(RemoteTaintConf c).hasFlow(src, sink) and not any(RemoteValueConf c).hasFlow(src, sink)
|
||||
|
|
||||
sink.getLocation() = location and
|
||||
element = sink.toString() and
|
||||
|
||||
Reference in New Issue
Block a user