Merge pull request #13346 from jketema/inline-2

Update inline expectation tests to use parameterized module
This commit is contained in:
Jeroen Ketema
2023-06-13 10:10:55 +02:00
committed by GitHub
244 changed files with 879 additions and 663 deletions

View File

@@ -0,0 +1,2 @@
failures
testFailures

View File

@@ -12,12 +12,10 @@ module Config implements DataFlow::ConfigSig {
module Flow = DataFlow::Global<Config>;
class HasFlowTest extends InlineExpectationsTest {
HasFlowTest() { this = "HasFlowTest" }
module HasFlowTest implements TestSig {
string getARelevantTag() { result = "flow" }
override string getARelevantTag() { result = "flow" }
override predicate hasActualResult(Location location, string element, string tag, string value) {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "flow" and
exists(DataFlow::Node src, DataFlow::Node sink | Flow::flow(src, sink) |
sink.getLocation() = location and
@@ -26,3 +24,5 @@ class HasFlowTest extends InlineExpectationsTest {
)
}
}
import MakeTest<HasFlowTest>

View File

@@ -18,12 +18,10 @@ module TaintFlowConfig implements DataFlow::ConfigSig {
module TaintFlow = TaintTracking::Global<TaintFlowConfig>;
class HasFlowTest extends InlineExpectationsTest {
HasFlowTest() { this = "HasFlowTest" }
module HasFlowTest implements TestSig {
string getARelevantTag() { result = "hasTaintFlow" }
override string getARelevantTag() { result = ["hasTaintFlow"] }
override predicate hasActualResult(Location location, string element, string tag, string value) {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "hasTaintFlow" and
exists(DataFlow::Node sink | TaintFlow::flowTo(sink) |
sink.getLocation() = location and
@@ -32,3 +30,5 @@ class HasFlowTest extends InlineExpectationsTest {
)
}
}
import MakeTest<HasFlowTest>

View File

@@ -0,0 +1,2 @@
failures
testFailures

View File

@@ -59,12 +59,10 @@ module Flow = TaintTracking::GlobalWithState<Config>;
module PartialFlow = Flow::FlowExploration<explorationLimit/0>;
class HasFlowTest extends InlineExpectationsTest {
HasFlowTest() { this = "HasFlowTest" }
module HasFlowTest implements TestSig {
string getARelevantTag() { result = ["pFwd", "pRev", "flow"] }
override string getARelevantTag() { result = ["pFwd", "pRev", "flow"] }
override predicate hasActualResult(Location location, string element, string tag, string value) {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "flow" and
exists(Flow::PathNode src, Flow::PathNode sink |
Flow::flowPath(src, sink) and
@@ -92,3 +90,5 @@ class HasFlowTest extends InlineExpectationsTest {
)
}
}
import MakeTest<HasFlowTest>

View File

@@ -0,0 +1,2 @@
failures
testFailures

View File

@@ -26,12 +26,10 @@ module LocalTaintConfig implements DataFlow::ConfigSig {
module LocalTaintFlow = TaintTracking::Global<LocalTaintConfig>;
class LocalFlowTest extends InlineExpectationsTest {
LocalFlowTest() { this = "LocalFlowTest" }
module LocalFlowTest implements TestSig {
string getARelevantTag() { result = ["hasLocalValueFlow", "hasLocalTaintFlow"] }
override string getARelevantTag() { result = ["hasLocalValueFlow", "hasLocalTaintFlow"] }
override predicate hasActualResult(Location location, string element, string tag, string value) {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "hasLocalValueFlow" and
exists(DataFlow::Node sink | LocalValueFlow::flowTo(sink) |
sink.getLocation() = location and
@@ -49,3 +47,5 @@ class LocalFlowTest extends InlineExpectationsTest {
)
}
}
import MakeTest<LocalFlowTest>

View File

@@ -0,0 +1,2 @@
failures
testFailures

View File

@@ -22,12 +22,10 @@ module RemoteTaintConfig implements DataFlow::ConfigSig {
module RemoteTaintFlow = TaintTracking::Global<RemoteTaintConfig>;
class RemoteFlowTest extends InlineExpectationsTest {
RemoteFlowTest() { this = "RemoteFlowTest" }
module RemoteFlowTest implements TestSig {
string getARelevantTag() { result = ["hasRemoteValueFlow", "hasRemoteTaintFlow"] }
override string getARelevantTag() { result = ["hasRemoteValueFlow", "hasRemoteTaintFlow"] }
override predicate hasActualResult(Location location, string element, string tag, string value) {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "hasRemoteValueFlow" and
exists(DataFlow::Node sink | RemoteValueFlow::flowTo(sink) |
sink.getLocation() = location and
@@ -45,3 +43,5 @@ class RemoteFlowTest extends InlineExpectationsTest {
)
}
}
import MakeTest<RemoteFlowTest>

View File

@@ -0,0 +1,2 @@
failures
testFailures

View File

@@ -3,10 +3,8 @@ import semmle.code.java.frameworks.JaxWS
import semmle.code.java.security.XSS
import TestUtilities.InlineExpectationsTest
class JaxRsTest extends InlineExpectationsTest {
JaxRsTest() { this = "JaxRsTest" }
override string getARelevantTag() {
module JaxRsTest implements TestSig {
string getARelevantTag() {
result =
[
"ResourceMethod", "RootResourceClass", "NonRootResourceClass",
@@ -18,7 +16,7 @@ class JaxRsTest extends InlineExpectationsTest {
]
}
override predicate hasActualResult(Location location, string element, string tag, string value) {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "ResourceMethod" and
exists(JaxRsResourceMethod resourceMethod |
resourceMethod.getLocation() = location and
@@ -168,3 +166,5 @@ class JaxRsTest extends InlineExpectationsTest {
)
}
}
import MakeTest<JaxRsTest>

View File

@@ -0,0 +1,2 @@
failures
testFailures

View File

@@ -2,12 +2,10 @@ import java
import semmle.code.java.frameworks.JaxWS
import TestUtilities.InlineExpectationsTest
class JaxWsEndpointTest extends InlineExpectationsTest {
JaxWsEndpointTest() { this = "JaxWsEndpointTest" }
module JaxWsEndpointTest implements TestSig {
string getARelevantTag() { result = ["JaxWsEndpoint", "JaxWsEndpointRemoteMethod"] }
override string getARelevantTag() { result = ["JaxWsEndpoint", "JaxWsEndpointRemoteMethod"] }
override predicate hasActualResult(Location location, string element, string tag, string value) {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "JaxWsEndpoint" and
exists(JaxWsEndpoint jaxWsEndpoint |
jaxWsEndpoint.getLocation() = location and
@@ -25,3 +23,5 @@ class JaxWsEndpointTest extends InlineExpectationsTest {
)
}
}
import MakeTest<JaxWsEndpointTest>

View File

@@ -0,0 +1,2 @@
failures
testFailures

View File

@@ -14,12 +14,10 @@ module Config implements DataFlow::ConfigSig {
module Flow = TaintTracking::Global<Config>;
class FlowStepTest extends InlineExpectationsTest {
FlowStepTest() { this = "FlowStepTest" }
module FlowStepTest implements TestSig {
string getARelevantTag() { result = "taintReachesReturn" }
override string getARelevantTag() { result = "taintReachesReturn" }
override predicate hasActualResult(Location l, string element, string tag, string value) {
predicate hasActualResult(Location l, string element, string tag, string value) {
tag = "taintReachesReturn" and
value = "" and
exists(DataFlow::Node source | Flow::flow(source, _) |
@@ -28,3 +26,5 @@ class FlowStepTest extends InlineExpectationsTest {
)
}
}
import MakeTest<FlowStepTest>

View File

@@ -0,0 +1,2 @@
failures
testFailures

View File

@@ -14,12 +14,10 @@ module Config implements DataFlow::ConfigSig {
module Flow = TaintTracking::Global<Config>;
class SinkTest extends InlineExpectationsTest {
SinkTest() { this = "SinkTest" }
module SinkTest implements TestSig {
string getARelevantTag() { result = "taintReachesSink" }
override string getARelevantTag() { result = "taintReachesSink" }
override predicate hasActualResult(Location l, string element, string tag, string value) {
predicate hasActualResult(Location l, string element, string tag, string value) {
tag = "taintReachesSink" and
value = "" and
exists(DataFlow::Node source | Flow::flow(source, _) |
@@ -28,3 +26,5 @@ class SinkTest extends InlineExpectationsTest {
)
}
}
import MakeTest<SinkTest>

View File

@@ -0,0 +1,2 @@
failures
testFailures

View File

@@ -24,12 +24,10 @@ module ValueFlowConfig implements DataFlow::ConfigSig {
module ValueFlow = DataFlow::Global<ValueFlowConfig>;
class HasFlowTest extends InlineExpectationsTest {
HasFlowTest() { this = "HasFlowTest" }
module HasFlowTest implements TestSig {
string getARelevantTag() { result = ["numTaintFlow", "numValueFlow"] }
override string getARelevantTag() { result = ["numTaintFlow", "numValueFlow"] }
override predicate hasActualResult(Location location, string element, string tag, string value) {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "numTaintFlow" and
exists(DataFlow::Node src, DataFlow::Node sink, int num | TaintFlow::flow(src, sink) |
not ValueFlow::flow(src, sink) and
@@ -48,3 +46,5 @@ class HasFlowTest extends InlineExpectationsTest {
)
}
}
import MakeTest<HasFlowTest>

View File

@@ -0,0 +1,2 @@
failures
testFailures

View File

@@ -14,15 +14,15 @@ module TestConfig implements DataFlow::ConfigSig {
module TestFlow = TaintTracking::Global<TestConfig>;
class JmsFlowTest extends InlineExpectationsTest {
JmsFlowTest() { this = "JmsFlowTest" }
module JmsFlowTest implements TestSig {
string getARelevantTag() { result = "tainted" }
override string getARelevantTag() { result = "tainted" }
override predicate hasActualResult(Location location, string element, string tag, string value) {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "tainted" and
exists(TestFlow::PathNode sink | TestFlow::flowPath(_, sink) |
location = sink.getNode().getLocation() and element = sink.getNode().toString() and value = ""
)
}
}
import MakeTest<JmsFlowTest>

View File

@@ -0,0 +1,2 @@
failures
testFailures

View File

@@ -2,15 +2,15 @@ import java
import semmle.code.java.dataflow.FlowSources
import TestUtilities.InlineExpectationsTest
class JmsRemoteSourcesTest extends InlineExpectationsTest {
JmsRemoteSourcesTest() { this = "JmsRemoteSourcesTest" }
module JmsRemoteSourcesTest implements TestSig {
string getARelevantTag() { result = "source" }
override string getARelevantTag() { result = "source" }
override predicate hasActualResult(Location location, string element, string tag, string value) {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "source" and
exists(RemoteFlowSource source |
location = source.getLocation() and element = source.toString() and value = ""
)
}
}
import MakeTest<JmsRemoteSourcesTest>

View File

@@ -0,0 +1,2 @@
failures
testFailures

View File

@@ -2,12 +2,10 @@ import java
import semmle.code.java.dataflow.FlowSources
import TestUtilities.InlineExpectationsTest
class SourceTest extends InlineExpectationsTest {
SourceTest() { this = "SourceTest" }
module SourceTest implements TestSig {
string getARelevantTag() { result = "source" }
override string getARelevantTag() { result = "source" }
override predicate hasActualResult(Location location, string element, string tag, string value) {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "source" and
exists(RemoteFlowSource source |
not source.asParameter().getCallable().getDeclaringType().hasName("DefaultConsumer") and
@@ -17,3 +15,5 @@ class SourceTest extends InlineExpectationsTest {
)
}
}
import MakeTest<SourceTest>

View File

@@ -0,0 +1,2 @@
failures
testFailures

View File

@@ -4,12 +4,10 @@ import semmle.code.java.dataflow.DataFlow
import semmle.code.java.dataflow.ExternalFlow
import semmle.code.java.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
class SinkTest extends InlineExpectationsTest {
SinkTest() { this = "SinkTest" }
module SinkTest implements TestSig {
string getARelevantTag() { result = "isSink" }
override string getARelevantTag() { result = "isSink" }
override predicate hasActualResult(Location location, string element, string tag, string value) {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "isSink" and
exists(DataFlow::Node sink |
sinkNode(sink, _) and
@@ -20,12 +18,10 @@ class SinkTest extends InlineExpectationsTest {
}
}
class NeutralSinkTest extends InlineExpectationsTest {
NeutralSinkTest() { this = "NeutralSinkTest" }
module NeutralSinkTest implements TestSig {
string getARelevantTag() { result = "isNeutralSink" }
override string getARelevantTag() { result = "isNeutralSink" }
override predicate hasActualResult(Location location, string element, string tag, string value) {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "isNeutralSink" and
exists(Call call, Callable callable |
call.getCallee() = callable and
@@ -38,3 +34,5 @@ class NeutralSinkTest extends InlineExpectationsTest {
)
}
}
import MakeTest<MergeTests<SinkTest, NeutralSinkTest>>

View File

@@ -1,2 +1,4 @@
failures
testFailures
| test.xml:4:5:4:32 | attribute=value | Unexpected result: hasXmlResult= |
| test.xml:5:29:5:52 | $ hasXmlResult | Missing result:hasXmlResult= |
| test.xml:5:29:5:52 | $ hasXmlResult | Missing result:hasXmlResult= |

View File

@@ -1,12 +1,10 @@
import semmle.code.xml.XML
import TestUtilities.InlineExpectationsTest
class XmlTest extends InlineExpectationsTest {
XmlTest() { this = "XmlTest" }
module XmlTest implements TestSig {
string getARelevantTag() { result = "hasXmlResult" }
override string getARelevantTag() { result = "hasXmlResult" }
override predicate hasActualResult(Location location, string element, string tag, string value) {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "hasXmlResult" and
exists(XmlAttribute a |
a.getLocation() = location and
@@ -15,3 +13,5 @@ class XmlTest extends InlineExpectationsTest {
)
}
}
import MakeTest<XmlTest>