Refactor jms test

This commit is contained in:
Ed Minnix
2023-04-13 21:54:49 -04:00
parent 6cda285d56
commit 2579852e90

View File

@@ -2,18 +2,18 @@ import java
import semmle.code.java.dataflow.FlowSources import semmle.code.java.dataflow.FlowSources
import TestUtilities.InlineExpectationsTest import TestUtilities.InlineExpectationsTest
class TestConfig extends TaintTracking::Configuration { module TestConfig implements DataFlow::ConfigSig {
TestConfig() { this = "TestConfig" } predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource } predicate isSink(DataFlow::Node sink) {
override predicate isSink(DataFlow::Node sink) {
exists(MethodAccess call | exists(MethodAccess call |
call.getMethod().hasName("sink") and call.getArgument(0) = sink.asExpr() call.getMethod().hasName("sink") and call.getArgument(0) = sink.asExpr()
) )
} }
} }
module TestFlow = TaintTracking::Global<TestConfig>;
class JmsFlowTest extends InlineExpectationsTest { class JmsFlowTest extends InlineExpectationsTest {
JmsFlowTest() { this = "JmsFlowTest" } JmsFlowTest() { this = "JmsFlowTest" }
@@ -21,7 +21,7 @@ class JmsFlowTest extends InlineExpectationsTest {
override predicate hasActualResult(Location location, string element, string tag, string value) { override predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "tainted" and tag = "tainted" and
exists(DataFlow::PathNode sink, TestConfig conf | conf.hasFlowPath(_, sink) | exists(TestFlow::PathNode sink | TestFlow::flowPath(_, sink) |
location = sink.getNode().getLocation() and element = sink.getNode().toString() and value = "" location = sink.getNode().getLocation() and element = sink.getNode().toString() and value = ""
) )
} }