Swift: Rewrite inline expectation tests to use the parameterized module

This commit is contained in:
Jeroen Ketema 2023-05-24 11:17:56 +02:00
Родитель 2276890cec
Коммит 3a3d9bc505
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 0D28C783F1AAA17F
16 изменённых файлов: 56 добавлений и 40 удалений

Просмотреть файл

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

Просмотреть файл

@ -2,12 +2,10 @@ import swift
import FlowConfig
import TestUtilities.InlineExpectationsTest
class TaintTest extends InlineExpectationsTest {
TaintTest() { this = "DataFlowTest" }
module TaintTest 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) {
exists(DataFlow::Node source, DataFlow::Node sink, Expr sinkExpr |
TestFlow::flow(source, sink) and
sinkExpr = sink.asExpr() and
@ -18,3 +16,5 @@ class TaintTest extends InlineExpectationsTest {
)
}
}
import MakeTest<TaintTest>

Просмотреть файл

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

Просмотреть файл

@ -8,12 +8,10 @@ string describe(FlowSource source) {
source instanceof LocalFlowSource and result = "local"
}
class FlowSourcesTest extends InlineExpectationsTest {
FlowSourcesTest() { this = "FlowSourcesTest" }
module FlowSourcesTest 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) {
exists(FlowSource source |
location = source.getLocation() and
location.getFile().getBaseName() != "" and
@ -23,3 +21,5 @@ class FlowSourcesTest extends InlineExpectationsTest {
)
}
}
import MakeTest<FlowSourcesTest>

Просмотреть файл

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

Просмотреть файл

@ -2,12 +2,10 @@ import swift
import Taint
import TestUtilities.InlineExpectationsTest
class TaintTest extends InlineExpectationsTest {
TaintTest() { this = "TaintTest" }
module TaintTest 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) {
exists(DataFlow::Node source, DataFlow::Node sink, Expr sinkExpr |
TestFlow::flow(source, sink) and
sinkExpr = sink.asExpr() and
@ -18,3 +16,5 @@ class TaintTest extends InlineExpectationsTest {
)
}
}
import MakeTest<TaintTest>

Просмотреть файл

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

Просмотреть файл

@ -2,12 +2,10 @@ import swift
import Taint
import TestUtilities.InlineExpectationsTest
class TaintTest extends InlineExpectationsTest {
TaintTest() { this = "TaintTest" }
module TaintTest 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) {
exists(DataFlow::Node source, DataFlow::Node sink, Expr sinkExpr |
TestFlow::flow(source, sink) and
sinkExpr = sink.asExpr() and
@ -18,3 +16,5 @@ class TaintTest extends InlineExpectationsTest {
)
}
}
import MakeTest<TaintTest>

Просмотреть файл

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

Просмотреть файл

@ -4,12 +4,10 @@ import codeql.swift.dataflow.FlowSources
import codeql.swift.security.PathInjectionQuery
import TestUtilities.InlineExpectationsTest
class PathInjectionTest extends InlineExpectationsTest {
PathInjectionTest() { this = "PathInjectionTest" }
module PathInjectionTest implements TestSig {
string getARelevantTag() { result = "hasPathInjection" }
override string getARelevantTag() { result = "hasPathInjection" }
override predicate hasActualResult(Location location, string element, string tag, string value) {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(DataFlow::Node source, DataFlow::Node sink |
PathInjectionFlow::flow(source, sink) and
location = sink.getLocation() and
@ -20,3 +18,5 @@ class PathInjectionTest extends InlineExpectationsTest {
)
}
}
import MakeTest<PathInjectionTest>

Просмотреть файл

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

Просмотреть файл

@ -3,12 +3,10 @@ import codeql.swift.dataflow.DataFlow
import codeql.swift.security.CleartextLoggingQuery
import TestUtilities.InlineExpectationsTest
class CleartextLogging extends InlineExpectationsTest {
CleartextLogging() { this = "CleartextLogging" }
module CleartextLogging implements TestSig {
string getARelevantTag() { result = "hasCleartextLogging" }
override string getARelevantTag() { result = "hasCleartextLogging" }
override predicate hasActualResult(Location location, string element, string tag, string value) {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(DataFlow::Node source, DataFlow::Node sink, Expr sinkExpr |
CleartextLoggingFlow::flow(source, sink) and
sinkExpr = sink.asExpr() and
@ -19,3 +17,5 @@ class CleartextLogging extends InlineExpectationsTest {
)
}
}
import MakeTest<CleartextLogging>

Просмотреть файл

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

Просмотреть файл

@ -9,12 +9,10 @@ class TestRemoteSource extends RemoteFlowSource {
override string getSourceType() { result = "Test source" }
}
class XxeTest extends InlineExpectationsTest {
XxeTest() { this = "XxeTest" }
module XxeTest implements TestSig {
string getARelevantTag() { result = "hasXXE" }
override string getARelevantTag() { result = "hasXXE" }
override predicate hasActualResult(Location location, string element, string tag, string value) {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(DataFlow::Node source, DataFlow::Node sink, Expr sinkExpr |
XxeFlow::flow(source, sink) and
sinkExpr = sink.asExpr() and
@ -25,3 +23,5 @@ class XxeTest extends InlineExpectationsTest {
)
}
}
import MakeTest<XxeTest>

Просмотреть файл

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

Просмотреть файл

@ -3,12 +3,10 @@ import codeql.swift.dataflow.DataFlow
import codeql.swift.security.PredicateInjectionQuery
import TestUtilities.InlineExpectationsTest
class PredicateInjectionTest extends InlineExpectationsTest {
PredicateInjectionTest() { this = "PredicateInjectionTest" }
module PredicateInjectionTest implements TestSig {
string getARelevantTag() { result = "hasPredicateInjection" }
override string getARelevantTag() { result = "hasPredicateInjection" }
override predicate hasActualResult(Location location, string element, string tag, string value) {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(DataFlow::Node source, DataFlow::Node sink, Expr sinkExpr |
PredicateInjectionFlow::flow(source, sink) and
sinkExpr = sink.asExpr() and
@ -19,3 +17,5 @@ class PredicateInjectionTest extends InlineExpectationsTest {
)
}
}
import MakeTest<PredicateInjectionTest>