mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
Consolidate application mode tests.
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
import java
|
||||
import AutomodelApplicationModeCharacteristics
|
||||
import TestUtilities.InlineExpectationsTest
|
||||
|
||||
module CandidateTest implements TestSig {
|
||||
string getARelevantTag() { result in ["sourceModel", "sinkModel"] }
|
||||
|
||||
predicate hasActualResult(Location location, string element, string tag, string value) {
|
||||
exists(
|
||||
Endpoint endpoint, string name, string signature, string input, string output,
|
||||
string extensibleType
|
||||
|
|
||||
isCandidate(endpoint, _, _, _, name, signature, input, output, _, extensibleType, _)
|
||||
|
|
||||
endpoint.asTop().getLocation() = location and
|
||||
endpoint.toString() = element and
|
||||
tag = extensibleType and
|
||||
// for source models only the output is relevant, and vice versa for sink models
|
||||
if extensibleType = "sourceModel"
|
||||
then value = name + signature + ":" + output
|
||||
else value = name + signature + ":" + input
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
import MakeTest<CandidateTest>
|
||||
@@ -1,2 +0,0 @@
|
||||
testFailures
|
||||
failures
|
||||
@@ -1,27 +0,0 @@
|
||||
import java
|
||||
import AutomodelApplicationModeCharacteristics
|
||||
import TestUtilities.InlineExpectationsTest
|
||||
|
||||
module NegativeExampleTest implements TestSig {
|
||||
string getARelevantTag() { result = "negativeExample" }
|
||||
|
||||
predicate hasActualResult(Location location, string element, string tag, string value) {
|
||||
exists(
|
||||
Endpoint endpoint, string name, string signature, string input,
|
||||
string output, string extensibleType
|
||||
|
|
||||
isNegativeExample(endpoint, _, _, _, _, _, name, signature, input, output, _,
|
||||
extensibleType)
|
||||
|
|
||||
endpoint.asTop().getLocation() = location and
|
||||
endpoint.toString() = element and
|
||||
tag = "negativeExample" and
|
||||
// for source models only the output is relevant, and vice versa for sink models
|
||||
if extensibleType = "sourceModel"
|
||||
then value = name + signature + ":" + output
|
||||
else value = name + signature + ":" + input
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
import MakeTest<NegativeExampleTest>
|
||||
@@ -1,2 +0,0 @@
|
||||
testFailures
|
||||
failures
|
||||
@@ -1,27 +0,0 @@
|
||||
import java
|
||||
import AutomodelApplicationModeCharacteristics
|
||||
import TestUtilities.InlineExpectationsTest
|
||||
|
||||
module PositiveExampleTest implements TestSig {
|
||||
string getARelevantTag() { result = "positiveExample" }
|
||||
|
||||
predicate hasActualResult(Location location, string element, string tag, string value) {
|
||||
exists(
|
||||
Endpoint endpoint, string endpointType, string name, string signature, string input,
|
||||
string output, string extensibleType
|
||||
|
|
||||
isPositiveExample(endpoint, endpointType, _, _, _, name, signature, input, output, _,
|
||||
extensibleType)
|
||||
|
|
||||
endpoint.asTop().getLocation() = location and
|
||||
endpoint.toString() = element and
|
||||
tag = "positiveExample" and
|
||||
// for source models only the output is relevant, and vice versa for sink models
|
||||
if extensibleType = "sourceModel"
|
||||
then value = name + signature + ":" + output + "(" + endpointType + ")"
|
||||
else value = name + signature + ":" + input + "(" + endpointType + ")"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
import MakeTest<PositiveExampleTest>
|
||||
@@ -0,0 +1,47 @@
|
||||
import java
|
||||
import AutomodelApplicationModeCharacteristics
|
||||
import TestUtilities.InlineExpectationsTest
|
||||
|
||||
module Extraction implements TestSig {
|
||||
string getARelevantTag() {
|
||||
result in ["sourceModel", "sinkModel", "positiveExample", "negativeExample"]
|
||||
}
|
||||
|
||||
additional predicate selectEndpoint(
|
||||
Endpoint endpoint, string name, string signature, string input, string output,
|
||||
string extensibleType, string tag, string suffix
|
||||
) {
|
||||
isCandidate(endpoint, _, _, _, name, signature, input, output, _, extensibleType, _) and
|
||||
tag = extensibleType and
|
||||
suffix = ""
|
||||
or
|
||||
isNegativeExample(endpoint, _, _, _, _, _, name, signature, input, output, _, extensibleType) and
|
||||
tag = "negativeExample" and
|
||||
suffix = ""
|
||||
or
|
||||
exists(string endpointType |
|
||||
isPositiveExample(endpoint, endpointType, _, _, _, name, signature, input, output, _,
|
||||
extensibleType) and
|
||||
tag = "positiveExample" and
|
||||
suffix = "(" + endpointType + ")"
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasActualResult(Location location, string element, string tag, string value) {
|
||||
exists(
|
||||
Endpoint endpoint, string name, string signature, string input, string output,
|
||||
string extensibleType, string suffix
|
||||
|
|
||||
selectEndpoint(endpoint, name, signature, input, output, extensibleType, tag, suffix)
|
||||
|
|
||||
endpoint.asTop().getLocation() = location and
|
||||
endpoint.toString() = element and
|
||||
// for source models only the output is relevant, and vice versa for sink models
|
||||
if extensibleType = "sourceModel"
|
||||
then value = name + signature + ":" + output + suffix
|
||||
else value = name + signature + ":" + input + suffix
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
import MakeTest<Extraction>
|
||||
@@ -87,9 +87,9 @@ class TaskUtils {
|
||||
class MoreTests {
|
||||
public static void FilesListExample(Path p) throws Exception {
|
||||
Files.list(
|
||||
Files.createDirectories( // $ negativeExample=list(Path):Argument[0] // modeled as a flow step
|
||||
Files.createDirectories(
|
||||
p // $ positiveExample=createDirectories(Path,FileAttribute[]):Argument[0](path-injection)
|
||||
) // $ sourceModel=createDirectories(Path,FileAttribute[]):ReturnValue
|
||||
) // $ sourceModel=createDirectories(Path,FileAttribute[]):ReturnValue negativeExample=list(Path):Argument[0] // modeled as a flow step
|
||||
); // $ sourceModel=list(Path):ReturnValue
|
||||
|
||||
Files.delete(
|
||||
|
||||
Reference in New Issue
Block a user