diff --git a/config/identical-files.json b/config/identical-files.json index 79c9c4e0f5db..62472fc9ed85 100644 --- a/config/identical-files.json +++ b/config/identical-files.json @@ -390,7 +390,8 @@ "java/ql/test/TestUtilities/InlineExpectationsTest.qll", "python/ql/test/TestUtilities/InlineExpectationsTest.qll", "ruby/ql/test/TestUtilities/InlineExpectationsTest.qll", - "ql/ql/test/TestUtilities/InlineExpectationsTest.qll" + "ql/ql/test/TestUtilities/InlineExpectationsTest.qll", + "go/ql/test/TestUtilities/InlineExpectationsTest.qll" ], "C++ ExternalAPIs": [ "cpp/ql/src/Security/CWE/CWE-020/ExternalAPIs.qll", diff --git a/go/ql/test/TestUtilities/InlineExpectationsTest.qll b/go/ql/test/TestUtilities/InlineExpectationsTest.qll index 3d2dc05a5efe..3891fcf13a1f 100644 --- a/go/ql/test/TestUtilities/InlineExpectationsTest.qll +++ b/go/ql/test/TestUtilities/InlineExpectationsTest.qll @@ -93,7 +93,7 @@ private import InlineExpectationsTestPrivate /** - * Base class for tests with inline expectations. The test extends this class to provide the actual + * The base class for tests with inline expectations. The test extends this class to provide the actual * results of the query, which are then compared with the expected results in comments to produce a * list of failure messages that point out where the actual results differ from the expected * results. @@ -121,11 +121,17 @@ abstract class InlineExpectationsTest extends string { * - `value` - The value of the result, which will be matched against the value associated with * `tag` in any expected result comment on that line. */ - abstract predicate hasActualResult(string file, int line, string element, string tag, string value); + abstract predicate hasActualResult(Location location, string element, string tag, string value); - predicate hasActualResult(Location location, string element, string tag, string value) { - this.hasActualResult(location.getFile().getAbsolutePath(), location.getStartLine(), element, - tag, value) + /** + * Holds if there is an optional result on the specified location. + * + * This is similar to `hasActualResult`, but returns results that do not require a matching annotation. + * A failure will still arise if there is an annotation that does not match any results, but not vice versa. + * Override this predicate to specify optional results. + */ + predicate hasOptionalResult(Location location, string element, string tag, string value) { + none() } final predicate hasFailureMessage(FailureLocatable element, string message) { @@ -139,13 +145,14 @@ abstract class InlineExpectationsTest extends string { ) or not exists(ValidExpectation expectation | expectation.matchesActualResult(actualResult)) and - message = "Unexpected result: " + actualResult.getExpectationText() + message = "Unexpected result: " + actualResult.getExpectationText() and + not actualResult.isOptional() ) ) or exists(ValidExpectation expectation | not exists(ActualResult actualResult | expectation.matchesActualResult(actualResult)) and - expectation.getTag() = this.getARelevantTag() and + expectation.getTag() = getARelevantTag() and element = expectation and ( expectation instanceof GoodExpectation and @@ -174,7 +181,7 @@ private string expectationCommentPattern() { result = "\\s*\\$((?:[^/]|/[^/])*)( /** * The possible columns in an expectation comment. The `TDefaultColumn` branch represents the first * column in a comment. This column is not precedeeded by a name. `TNamedColumn(name)` represents a - * column containing expected results preceeded by the string `name:`. + * column containing expected results preceded by the string `name:`. */ private newtype TColumn = TDefaultColumn() or @@ -248,9 +255,13 @@ private string expectationPattern() { private newtype TFailureLocatable = TActualResult( - InlineExpectationsTest test, Location location, string element, string tag, string value + InlineExpectationsTest test, Location location, string element, string tag, string value, + boolean optional ) { - test.hasActualResult(location, element, tag, value) + test.hasActualResult(location, element, tag, value) and + optional = false + or + test.hasOptionalResult(location, element, tag, value) and optional = true } or TValidExpectation(ExpectationComment comment, string tag, string value, string knownFailure) { exists(TColumn column, string tags | @@ -269,7 +280,7 @@ class FailureLocatable extends TFailureLocatable { Location getLocation() { none() } - final string getExpectationText() { result = this.getTag() + "=" + this.getValue() } + final string getExpectationText() { result = getTag() + "=" + getValue() } string getTag() { none() } @@ -282,8 +293,9 @@ class ActualResult extends FailureLocatable, TActualResult { string element; string tag; string value; + boolean optional; - ActualResult() { this = TActualResult(test, location, element, tag, value) } + ActualResult() { this = TActualResult(test, location, element, tag, value, optional) } override string toString() { result = element } @@ -294,6 +306,8 @@ class ActualResult extends FailureLocatable, TActualResult { override string getTag() { result = tag } override string getValue() { result = value } + + predicate isOptional() { optional = true } } abstract private class Expectation extends FailureLocatable { @@ -318,24 +332,24 @@ private class ValidExpectation extends Expectation, TValidExpectation { string getKnownFailure() { result = knownFailure } predicate matchesActualResult(ActualResult actualResult) { - this.getLocation().getStartLine() = actualResult.getLocation().getStartLine() and - this.getLocation().getFile() = actualResult.getLocation().getFile() and - this.getTag() = actualResult.getTag() and - this.getValue() = actualResult.getValue() + getLocation().getStartLine() = actualResult.getLocation().getStartLine() and + getLocation().getFile() = actualResult.getLocation().getFile() and + getTag() = actualResult.getTag() and + getValue() = actualResult.getValue() } } /* Note: These next three classes correspond to all the possible values of type `TColumn`. */ class GoodExpectation extends ValidExpectation { - GoodExpectation() { this.getKnownFailure() = "" } + GoodExpectation() { getKnownFailure() = "" } } class FalsePositiveExpectation extends ValidExpectation { - FalsePositiveExpectation() { this.getKnownFailure() = "SPURIOUS" } + FalsePositiveExpectation() { getKnownFailure() = "SPURIOUS" } } class FalseNegativeExpectation extends ValidExpectation { - FalseNegativeExpectation() { this.getKnownFailure() = "MISSING" } + FalseNegativeExpectation() { getKnownFailure() = "MISSING" } } class InvalidExpectation extends Expectation, TInvalidExpectation { diff --git a/go/ql/test/TestUtilities/InlineFlowTest.qll b/go/ql/test/TestUtilities/InlineFlowTest.qll index b6bf3d20308f..ef92f42cdaf1 100644 --- a/go/ql/test/TestUtilities/InlineFlowTest.qll +++ b/go/ql/test/TestUtilities/InlineFlowTest.qll @@ -76,10 +76,11 @@ class InlineFlowTest extends InlineExpectationsTest { override string getARelevantTag() { result = ["hasValueFlow", "hasTaintFlow"] } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "hasValueFlow" and exists(DataFlow::Node src, DataFlow::Node sink | getValueFlowConfig().hasFlow(src, sink) | - sink.hasLocationInfo(file, line, _, _, _) and + sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and element = sink.toString() and value = "\"" + sink.toString() + "\"" ) @@ -88,7 +89,8 @@ class InlineFlowTest extends InlineExpectationsTest { exists(DataFlow::Node src, DataFlow::Node sink | getTaintFlowConfig().hasFlow(src, sink) and not getValueFlowConfig().hasFlow(src, sink) | - sink.hasLocationInfo(file, line, _, _, _) and + sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and element = sink.toString() and value = "\"" + sink.toString() + "\"" ) diff --git a/go/ql/test/experimental/frameworks/CleverGo/HeaderWrite.ql b/go/ql/test/experimental/frameworks/CleverGo/HeaderWrite.ql index d2cc16f92cfb..3f33ae982482 100644 --- a/go/ql/test/experimental/frameworks/CleverGo/HeaderWrite.ql +++ b/go/ql/test/experimental/frameworks/CleverGo/HeaderWrite.ql @@ -9,10 +9,11 @@ class HttpHeaderWriteTest extends InlineExpectationsTest { result = ["headerKeyNode", "headerValNode", "headerKey", "headerVal"] } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { // Dynamic key-value header: exists(HTTP::HeaderWrite hw | - hw.hasLocationInfo(file, line, _, _, _) and + hw.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and ( element = hw.getName().toString() and value = hw.getName().toString() and @@ -26,7 +27,8 @@ class HttpHeaderWriteTest extends InlineExpectationsTest { or // Static key, dynamic value header: exists(HTTP::HeaderWrite hw | - hw.hasLocationInfo(file, line, _, _, _) and + hw.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and ( element = hw.getHeaderName().toString() and value = hw.getHeaderName() and @@ -40,7 +42,8 @@ class HttpHeaderWriteTest extends InlineExpectationsTest { or // Static key, static value header: exists(HTTP::HeaderWrite hw | - hw.hasLocationInfo(file, line, _, _, _) and + hw.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and ( element = hw.getHeaderName().toString() and value = hw.getHeaderName() and diff --git a/go/ql/test/experimental/frameworks/CleverGo/HttpRedirect.ql b/go/ql/test/experimental/frameworks/CleverGo/HttpRedirect.ql index 9ba91ffcf9bf..5ceb813cec97 100644 --- a/go/ql/test/experimental/frameworks/CleverGo/HttpRedirect.ql +++ b/go/ql/test/experimental/frameworks/CleverGo/HttpRedirect.ql @@ -7,10 +7,11 @@ class HttpRedirectTest extends InlineExpectationsTest { override string getARelevantTag() { result = "redirectUrl" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "redirectUrl" and exists(HTTP::Redirect rd | - rd.hasLocationInfo(file, line, _, _, _) and + rd.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and element = rd.getUrl().toString() and value = rd.getUrl().toString() ) diff --git a/go/ql/test/experimental/frameworks/CleverGo/HttpResponseBody.ql b/go/ql/test/experimental/frameworks/CleverGo/HttpResponseBody.ql index 8cfb0dee469a..33c3f94ec07b 100644 --- a/go/ql/test/experimental/frameworks/CleverGo/HttpResponseBody.ql +++ b/go/ql/test/experimental/frameworks/CleverGo/HttpResponseBody.ql @@ -7,9 +7,10 @@ class HttpResponseBodyTest extends InlineExpectationsTest { override string getARelevantTag() { result = ["contentType", "responseBody"] } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { exists(HTTP::ResponseBody rd | - rd.hasLocationInfo(file, line, _, _, _) and + rd.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and ( element = rd.getAContentType().toString() and value = rd.getAContentType().toString() and diff --git a/go/ql/test/experimental/frameworks/CleverGo/TaintTracking.ql b/go/ql/test/experimental/frameworks/CleverGo/TaintTracking.ql index bd15905bba9b..5de07cbe0438 100644 --- a/go/ql/test/experimental/frameworks/CleverGo/TaintTracking.ql +++ b/go/ql/test/experimental/frameworks/CleverGo/TaintTracking.ql @@ -19,12 +19,13 @@ class TaintTrackingTest extends InlineExpectationsTest { override string getARelevantTag() { result = "taintSink" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "taintSink" and exists(DataFlow::Node sink | any(Configuration c).hasFlow(_, sink) | element = sink.toString() and value = "" and - sink.hasLocationInfo(file, line, _, _, _) + sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) ) } } diff --git a/go/ql/test/experimental/frameworks/CleverGo/UntrustedSources.ql b/go/ql/test/experimental/frameworks/CleverGo/UntrustedSources.ql index e33df8fda49d..4ace887e3675 100644 --- a/go/ql/test/experimental/frameworks/CleverGo/UntrustedSources.ql +++ b/go/ql/test/experimental/frameworks/CleverGo/UntrustedSources.ql @@ -7,7 +7,7 @@ class UntrustedFlowSourceTest extends InlineExpectationsTest { override string getARelevantTag() { result = "untrustedFlowSource" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "untrustedFlowSource" and exists(DataFlow::CallNode sinkCall, DataFlow::ArgumentNode arg | sinkCall.getCalleeName() = "sink" and @@ -16,7 +16,8 @@ class UntrustedFlowSourceTest extends InlineExpectationsTest { | element = arg.toString() and value = "" and - arg.hasLocationInfo(file, line, _, _, _) + arg.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) ) } } diff --git a/go/ql/test/experimental/frameworks/Fiber/HeaderWrite.ql b/go/ql/test/experimental/frameworks/Fiber/HeaderWrite.ql index b04dd80b1b7a..d83883f45a75 100644 --- a/go/ql/test/experimental/frameworks/Fiber/HeaderWrite.ql +++ b/go/ql/test/experimental/frameworks/Fiber/HeaderWrite.ql @@ -9,10 +9,11 @@ class HttpHeaderWriteTest extends InlineExpectationsTest { result = ["headerKeyNode", "headerValNode", "headerKey", "headerVal"] } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { // Dynamic key-value header: exists(HTTP::HeaderWrite hw | - hw.hasLocationInfo(file, line, _, _, _) and + hw.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and ( element = hw.getName().toString() and value = hw.getName().toString() and @@ -26,7 +27,8 @@ class HttpHeaderWriteTest extends InlineExpectationsTest { or // Static key, dynamic value header: exists(HTTP::HeaderWrite hw | - hw.hasLocationInfo(file, line, _, _, _) and + hw.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and ( element = hw.getHeaderName().toString() and value = hw.getHeaderName() and @@ -40,7 +42,8 @@ class HttpHeaderWriteTest extends InlineExpectationsTest { or // Static key, static value header: exists(HTTP::HeaderWrite hw | - hw.hasLocationInfo(file, line, _, _, _) and + hw.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and ( element = hw.getHeaderName().toString() and value = hw.getHeaderName() and diff --git a/go/ql/test/experimental/frameworks/Fiber/Redirect.ql b/go/ql/test/experimental/frameworks/Fiber/Redirect.ql index 0ba2d3adff87..68d5bee465c7 100644 --- a/go/ql/test/experimental/frameworks/Fiber/Redirect.ql +++ b/go/ql/test/experimental/frameworks/Fiber/Redirect.ql @@ -7,10 +7,11 @@ class HttpRedirectTest extends InlineExpectationsTest { override string getARelevantTag() { result = "redirectUrl" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "redirectUrl" and exists(HTTP::Redirect rd | - rd.hasLocationInfo(file, line, _, _, _) and + rd.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and element = rd.getUrl().toString() and value = rd.getUrl().toString() ) diff --git a/go/ql/test/experimental/frameworks/Fiber/ResponseBody.ql b/go/ql/test/experimental/frameworks/Fiber/ResponseBody.ql index d089b419f7f9..4361b2fda6ae 100644 --- a/go/ql/test/experimental/frameworks/Fiber/ResponseBody.ql +++ b/go/ql/test/experimental/frameworks/Fiber/ResponseBody.ql @@ -7,9 +7,10 @@ class HttpResponseBodyTest extends InlineExpectationsTest { override string getARelevantTag() { result = ["contentType", "responseBody"] } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { exists(HTTP::ResponseBody rd | - rd.hasLocationInfo(file, line, _, _, _) and + rd.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and ( element = rd.getAContentType().toString() and value = rd.getAContentType().toString() and diff --git a/go/ql/test/experimental/frameworks/Fiber/TaintTracking.ql b/go/ql/test/experimental/frameworks/Fiber/TaintTracking.ql index 2b5eb4fb9580..dba5c65328c0 100644 --- a/go/ql/test/experimental/frameworks/Fiber/TaintTracking.ql +++ b/go/ql/test/experimental/frameworks/Fiber/TaintTracking.ql @@ -19,12 +19,13 @@ class TaintTrackingTest extends InlineExpectationsTest { override string getARelevantTag() { result = "taintSink" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "taintSink" and exists(DataFlow::Node sink | any(Configuration c).hasFlow(_, sink) | element = sink.toString() and value = "" and - sink.hasLocationInfo(file, line, _, _, _) + sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) ) } } diff --git a/go/ql/test/experimental/frameworks/Fiber/UntrustedFlowSources.ql b/go/ql/test/experimental/frameworks/Fiber/UntrustedFlowSources.ql index cb039c5b6d22..3e7666b581a6 100644 --- a/go/ql/test/experimental/frameworks/Fiber/UntrustedFlowSources.ql +++ b/go/ql/test/experimental/frameworks/Fiber/UntrustedFlowSources.ql @@ -7,7 +7,7 @@ class UntrustedFlowSourceTest extends InlineExpectationsTest { override string getARelevantTag() { result = "untrustedFlowSource" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "untrustedFlowSource" and exists(DataFlow::CallNode sinkCall, DataFlow::ArgumentNode arg | sinkCall.getCalleeName() = "sink" and @@ -16,7 +16,8 @@ class UntrustedFlowSourceTest extends InlineExpectationsTest { | element = arg.toString() and value = "" and - arg.hasLocationInfo(file, line, _, _, _) + arg.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) ) } } diff --git a/go/ql/test/library-tests/semmle/go/Function/isVariadic.ql b/go/ql/test/library-tests/semmle/go/Function/isVariadic.ql index 89e9733496c2..b501b84eadda 100644 --- a/go/ql/test/library-tests/semmle/go/Function/isVariadic.ql +++ b/go/ql/test/library-tests/semmle/go/Function/isVariadic.ql @@ -6,10 +6,11 @@ class FunctionIsVariadicTest extends InlineExpectationsTest { override string getARelevantTag() { result = "isVariadic" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { exists(CallExpr ce | ce.getTarget().isVariadic() and - ce.hasLocationInfo(file, line, _, _, _) and + ce.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and element = ce.toString() and value = "" and tag = "isVariadic" diff --git a/go/ql/test/library-tests/semmle/go/Types/ImplementsComparable.ql b/go/ql/test/library-tests/semmle/go/Types/ImplementsComparable.ql index b73b711169a9..789472ecd2fd 100644 --- a/go/ql/test/library-tests/semmle/go/Types/ImplementsComparable.ql +++ b/go/ql/test/library-tests/semmle/go/Types/ImplementsComparable.ql @@ -6,14 +6,15 @@ class ImplementsComparableTest extends InlineExpectationsTest { override string getARelevantTag() { result = "implementsComparable" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { // file = "interface.go" and tag = "implementsComparable" and exists(TypeSpec ts | ts.getName().matches("testComparable%") and ts.getATypeParameterDecl().getTypeConstraint().implementsComparable() | - ts.hasLocationInfo(file, line, _, _, _) and + ts.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and element = ts.getName() and value = "" ) diff --git a/go/ql/test/library-tests/semmle/go/Types/SignatureType_isVariadic.ql b/go/ql/test/library-tests/semmle/go/Types/SignatureType_isVariadic.ql index 6e6e65b72f28..d2ae79ae7d9b 100644 --- a/go/ql/test/library-tests/semmle/go/Types/SignatureType_isVariadic.ql +++ b/go/ql/test/library-tests/semmle/go/Types/SignatureType_isVariadic.ql @@ -6,10 +6,11 @@ class SignatureTypeIsVariadicTest extends InlineExpectationsTest { override string getARelevantTag() { result = "isVariadic" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { exists(FuncDef fd | fd.isVariadic() and - fd.hasLocationInfo(file, line, _, _, _) and + fd.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and element = fd.toString() and value = "" and tag = "isVariadic" diff --git a/go/ql/test/library-tests/semmle/go/concepts/HTTP/Handler.ql b/go/ql/test/library-tests/semmle/go/concepts/HTTP/Handler.ql index 2ab16946cf97..e0b0acd426b5 100644 --- a/go/ql/test/library-tests/semmle/go/concepts/HTTP/Handler.ql +++ b/go/ql/test/library-tests/semmle/go/concepts/HTTP/Handler.ql @@ -6,12 +6,13 @@ class HttpHandler extends InlineExpectationsTest { override string getARelevantTag() { result = "handler" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "handler" and exists(HTTP::RequestHandler h, DataFlow::Node check | element = h.toString() and value = check.toString() | - h.hasLocationInfo(file, line, _, _, _) and + h.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and h.guardedBy(check) ) } diff --git a/go/ql/test/library-tests/semmle/go/concepts/LoggerCall/LoggerCall.ql b/go/ql/test/library-tests/semmle/go/concepts/LoggerCall/LoggerCall.ql index 05b18540aede..ce1be9a05d7b 100644 --- a/go/ql/test/library-tests/semmle/go/concepts/LoggerCall/LoggerCall.ql +++ b/go/ql/test/library-tests/semmle/go/concepts/LoggerCall/LoggerCall.ql @@ -6,9 +6,10 @@ class LoggerTest extends InlineExpectationsTest { override string getARelevantTag() { result = "logger" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { exists(LoggerCall log | - log.hasLocationInfo(file, line, _, _, _) and + log.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and element = log.toString() and value = log.getAMessageComponent().toString() and tag = "logger" diff --git a/go/ql/test/library-tests/semmle/go/dataflow/ExternalFlowVarArgs/Flows.ql b/go/ql/test/library-tests/semmle/go/dataflow/ExternalFlowVarArgs/Flows.ql index b1f63d19a853..278da456bf2d 100644 --- a/go/ql/test/library-tests/semmle/go/dataflow/ExternalFlowVarArgs/Flows.ql +++ b/go/ql/test/library-tests/semmle/go/dataflow/ExternalFlowVarArgs/Flows.ql @@ -34,12 +34,13 @@ class DataFlowTest extends InlineExpectationsTest { override string getARelevantTag() { result = "dataflow" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "dataflow" and exists(DataFlow::Node sink | any(DataConfiguration c).hasFlow(_, sink) | element = sink.toString() and value = "" and - sink.hasLocationInfo(file, line, _, _, _) + sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) ) } } @@ -61,12 +62,13 @@ class TaintFlowTest extends InlineExpectationsTest { override string getARelevantTag() { result = "taintflow" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "taintflow" and exists(DataFlow::Node sink | any(TaintConfiguration c).hasFlow(_, sink) | element = sink.toString() and value = "" and - sink.hasLocationInfo(file, line, _, _, _) + sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) ) } } diff --git a/go/ql/test/library-tests/semmle/go/dataflow/GuardingFunctions/test.ql b/go/ql/test/library-tests/semmle/go/dataflow/GuardingFunctions/test.ql index a4d92e1fc7a8..627ac254ec9f 100644 --- a/go/ql/test/library-tests/semmle/go/dataflow/GuardingFunctions/test.ql +++ b/go/ql/test/library-tests/semmle/go/dataflow/GuardingFunctions/test.ql @@ -28,12 +28,13 @@ class DataFlowTest extends InlineExpectationsTest { override string getARelevantTag() { result = "dataflow" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "dataflow" and exists(DataFlow::Node sink | any(TestConfig c).hasFlow(_, sink) | element = sink.toString() and value = sink.toString() and - sink.hasLocationInfo(file, line, _, _, _) + sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) ) } } diff --git a/go/ql/test/library-tests/semmle/go/dataflow/ListOfConstantsSanitizerGuards/test.ql b/go/ql/test/library-tests/semmle/go/dataflow/ListOfConstantsSanitizerGuards/test.ql index 2b6bddff7f96..f75495313d45 100644 --- a/go/ql/test/library-tests/semmle/go/dataflow/ListOfConstantsSanitizerGuards/test.ql +++ b/go/ql/test/library-tests/semmle/go/dataflow/ListOfConstantsSanitizerGuards/test.ql @@ -18,12 +18,13 @@ class DataFlowTest extends InlineExpectationsTest { override string getARelevantTag() { result = "dataflow" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "dataflow" and exists(DataFlow::Node sink | any(TestConfig c).hasFlow(_, sink) | element = sink.toString() and value = sink.toString() and - sink.hasLocationInfo(file, line, _, _, _) + sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) ) } } diff --git a/go/ql/test/library-tests/semmle/go/dataflow/PromotedFields/DataFlowConfig.ql b/go/ql/test/library-tests/semmle/go/dataflow/PromotedFields/DataFlowConfig.ql index 62ead1d94dee..15b8e3c1238f 100644 --- a/go/ql/test/library-tests/semmle/go/dataflow/PromotedFields/DataFlowConfig.ql +++ b/go/ql/test/library-tests/semmle/go/dataflow/PromotedFields/DataFlowConfig.ql @@ -26,10 +26,11 @@ class PromotedFieldsTest extends InlineExpectationsTest { override string getARelevantTag() { result = "promotedfields" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { exists(TestConfig config, DataFlow::PathNode source, DataFlow::PathNode sink | config.hasFlowPath(source, sink) and - sink.hasLocationInfo(file, line, _, _, _) and + sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and element = sink.toString() and value = "" and tag = "promotedfields" diff --git a/go/ql/test/library-tests/semmle/go/dataflow/PromotedMethods/DataFlowConfig.ql b/go/ql/test/library-tests/semmle/go/dataflow/PromotedMethods/DataFlowConfig.ql index 3dc328238b84..f99f7775a3b5 100644 --- a/go/ql/test/library-tests/semmle/go/dataflow/PromotedMethods/DataFlowConfig.ql +++ b/go/ql/test/library-tests/semmle/go/dataflow/PromotedMethods/DataFlowConfig.ql @@ -26,11 +26,12 @@ class PromotedMethodsTest extends InlineExpectationsTest { override string getARelevantTag() { result = "promotedmethods" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { exists(TestConfig config, DataFlow::Node source, DataFlow::Node sink | config.hasFlow(source, sink) | - sink.hasLocationInfo(file, line, _, _, _) and + sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and element = sink.toString() and value = source.getEnclosingCallable().getName() and tag = "promotedmethods" diff --git a/go/ql/test/library-tests/semmle/go/dataflow/TypeAssertions/DataFlow.ql b/go/ql/test/library-tests/semmle/go/dataflow/TypeAssertions/DataFlow.ql index a706f7311345..edabb61bf5de 100644 --- a/go/ql/test/library-tests/semmle/go/dataflow/TypeAssertions/DataFlow.ql +++ b/go/ql/test/library-tests/semmle/go/dataflow/TypeAssertions/DataFlow.ql @@ -18,12 +18,13 @@ class DataFlowTest extends InlineExpectationsTest { override string getARelevantTag() { result = "dataflow" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "dataflow" and exists(DataFlow::Node sink | any(Configuration c).hasFlow(_, sink) | element = sink.toString() and value = sink.toString() and - sink.hasLocationInfo(file, line, _, _, _) + sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) ) } } diff --git a/go/ql/test/library-tests/semmle/go/dataflow/VarArgs/Flows.ql b/go/ql/test/library-tests/semmle/go/dataflow/VarArgs/Flows.ql index 90c078b70884..e6e99b0e6c2e 100644 --- a/go/ql/test/library-tests/semmle/go/dataflow/VarArgs/Flows.ql +++ b/go/ql/test/library-tests/semmle/go/dataflow/VarArgs/Flows.ql @@ -18,12 +18,13 @@ class DataFlowTest extends InlineExpectationsTest { override string getARelevantTag() { result = "dataflow" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "dataflow" and exists(DataFlow::Node sink | any(DataConfiguration c).hasFlow(_, sink) | element = sink.toString() and value = "" and - sink.hasLocationInfo(file, line, _, _, _) + sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) ) } } @@ -45,12 +46,13 @@ class TaintFlowTest extends InlineExpectationsTest { override string getARelevantTag() { result = "taintflow" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "taintflow" and exists(DataFlow::Node sink | any(TaintConfiguration c).hasFlow(_, sink) | element = sink.toString() and value = "" and - sink.hasLocationInfo(file, line, _, _, _) + sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) ) } } diff --git a/go/ql/test/library-tests/semmle/go/dataflow/VarArgsWithFunctionModels/Flows.ql b/go/ql/test/library-tests/semmle/go/dataflow/VarArgsWithFunctionModels/Flows.ql index 7356e691328c..e80681e243e2 100644 --- a/go/ql/test/library-tests/semmle/go/dataflow/VarArgsWithFunctionModels/Flows.ql +++ b/go/ql/test/library-tests/semmle/go/dataflow/VarArgsWithFunctionModels/Flows.ql @@ -50,12 +50,13 @@ class DataFlowTest extends InlineExpectationsTest { override string getARelevantTag() { result = "dataflow" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "dataflow" and exists(DataFlow::Node sink | any(DataConfiguration c).hasFlow(_, sink) | element = sink.toString() and value = "" and - sink.hasLocationInfo(file, line, _, _, _) + sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) ) } } @@ -79,12 +80,13 @@ class TaintFlowTest extends InlineExpectationsTest { override string getARelevantTag() { result = "taintflow" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "taintflow" and exists(DataFlow::Node sink | any(TaintConfiguration c).hasFlow(_, sink) | element = sink.toString() and value = "" and - sink.hasLocationInfo(file, line, _, _, _) + sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) ) } } diff --git a/go/ql/test/library-tests/semmle/go/frameworks/CouchbaseV1/test.ql b/go/ql/test/library-tests/semmle/go/frameworks/CouchbaseV1/test.ql index 505d4a1360f2..535fb6dd6272 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/CouchbaseV1/test.ql +++ b/go/ql/test/library-tests/semmle/go/frameworks/CouchbaseV1/test.ql @@ -7,12 +7,13 @@ class SqlInjectionTest extends InlineExpectationsTest { override string getARelevantTag() { result = "sqlinjection" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "sqlinjection" and exists(DataFlow::Node sink | any(SqlInjection::Configuration c).hasFlow(_, sink) | element = sink.toString() and value = sink.toString() and - sink.hasLocationInfo(file, line, _, _, _) + sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) ) } } diff --git a/go/ql/test/library-tests/semmle/go/frameworks/ElazarlGoproxy/test.ql b/go/ql/test/library-tests/semmle/go/frameworks/ElazarlGoproxy/test.ql index 1ee889d8dc9a..106d28b48f5c 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/ElazarlGoproxy/test.ql +++ b/go/ql/test/library-tests/semmle/go/frameworks/ElazarlGoproxy/test.ql @@ -6,11 +6,12 @@ class UntrustedFlowSourceTest extends InlineExpectationsTest { override string getARelevantTag() { result = "untrustedflowsource" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "untrustedflowsource" and value = element and exists(UntrustedFlowSource src | value = "\"" + src.toString() + "\"" | - src.hasLocationInfo(file, line, _, _, _) + src.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) ) } } @@ -20,12 +21,13 @@ class HeaderWriteTest extends InlineExpectationsTest { override string getARelevantTag() { result = "headerwrite" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "headerwrite" and exists(HTTP::HeaderWrite hw, string name, string val | element = hw.toString() | hw.definesHeader(name, val) and value = name + ":" + val and - hw.hasLocationInfo(file, line, _, _, _) + hw.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) ) } } @@ -35,9 +37,10 @@ class LoggerTest extends InlineExpectationsTest { override string getARelevantTag() { result = "logger" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { exists(LoggerCall log | - log.hasLocationInfo(file, line, _, _, _) and + log.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and element = log.toString() and value = log.getAMessageComponent().toString() and tag = "logger" diff --git a/go/ql/test/library-tests/semmle/go/frameworks/EvanphxJsonPatch/TaintFlows.ql b/go/ql/test/library-tests/semmle/go/frameworks/EvanphxJsonPatch/TaintFlows.ql index dba2e0fb05cf..0d411503e340 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/EvanphxJsonPatch/TaintFlows.ql +++ b/go/ql/test/library-tests/semmle/go/frameworks/EvanphxJsonPatch/TaintFlows.ql @@ -21,12 +21,13 @@ class TaintFlowTest extends InlineExpectationsTest { override string getARelevantTag() { result = "taintflow" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "taintflow" and exists(DataFlow::Node sink | any(Configuration c).hasFlow(_, sink) | element = sink.toString() and value = "" and - sink.hasLocationInfo(file, line, _, _, _) + sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) ) } } diff --git a/go/ql/test/library-tests/semmle/go/frameworks/GoKit/untrustedflowsource.ql b/go/ql/test/library-tests/semmle/go/frameworks/GoKit/untrustedflowsource.ql index 7533bff89cb5..7cffdcb78ba1 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/GoKit/untrustedflowsource.ql +++ b/go/ql/test/library-tests/semmle/go/frameworks/GoKit/untrustedflowsource.ql @@ -7,9 +7,11 @@ class UntrustedFlowSourceTest extends InlineExpectationsTest { override string getARelevantTag() { result = "source" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { exists(UntrustedFlowSource source | - source.hasLocationInfo(file, line, _, _, _) and + source + .hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and element = source.toString() and value = "\"" + source.toString() + "\"" and tag = "source" diff --git a/go/ql/test/library-tests/semmle/go/frameworks/K8sIoApiCoreV1/TaintFlowsInline.ql b/go/ql/test/library-tests/semmle/go/frameworks/K8sIoApiCoreV1/TaintFlowsInline.ql index c37858feb56b..46fbaefa3eaf 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/K8sIoApiCoreV1/TaintFlowsInline.ql +++ b/go/ql/test/library-tests/semmle/go/frameworks/K8sIoApiCoreV1/TaintFlowsInline.ql @@ -26,10 +26,11 @@ class K8sIoApiCoreV1Test extends InlineExpectationsTest { override string getARelevantTag() { result = "KsIoApiCoreV" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { exists(TestConfig config, DataFlow::PathNode source, DataFlow::PathNode sink | config.hasFlowPath(source, sink) and - sink.hasLocationInfo(file, line, _, _, _) and + sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and element = sink.toString() and value = "" and tag = "KsIoApiCoreV" diff --git a/go/ql/test/library-tests/semmle/go/frameworks/K8sIoApimachineryPkgRuntime/TaintFlowsInline.ql b/go/ql/test/library-tests/semmle/go/frameworks/K8sIoApimachineryPkgRuntime/TaintFlowsInline.ql index a1256b2daa6e..7cd9eb16e871 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/K8sIoApimachineryPkgRuntime/TaintFlowsInline.ql +++ b/go/ql/test/library-tests/semmle/go/frameworks/K8sIoApimachineryPkgRuntime/TaintFlowsInline.ql @@ -26,10 +26,11 @@ class K8sIoApimachineryPkgRuntimeTest extends InlineExpectationsTest { override string getARelevantTag() { result = "KsIoApimachineryPkgRuntime" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { exists(TestConfig config, DataFlow::PathNode source, DataFlow::PathNode sink | config.hasFlowPath(source, sink) and - sink.hasLocationInfo(file, line, _, _, _) and + sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and element = sink.toString() and value = "" and tag = "KsIoApimachineryPkgRuntime" diff --git a/go/ql/test/library-tests/semmle/go/frameworks/K8sIoClientGo/SecretInterfaceSource.ql b/go/ql/test/library-tests/semmle/go/frameworks/K8sIoClientGo/SecretInterfaceSource.ql index be59ef4371c9..1650e2632527 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/K8sIoClientGo/SecretInterfaceSource.ql +++ b/go/ql/test/library-tests/semmle/go/frameworks/K8sIoClientGo/SecretInterfaceSource.ql @@ -6,9 +6,11 @@ class K8sIoApimachineryPkgRuntimeTest extends InlineExpectationsTest { override string getARelevantTag() { result = "KsIoClientGo" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { exists(K8sIoClientGo::SecretInterfaceSource source | - source.hasLocationInfo(file, line, _, _, _) and + source + .hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and element = source.toString() and value = "" and tag = "KsIoClientGo" diff --git a/go/ql/test/library-tests/semmle/go/frameworks/NoSQL/Query.ql b/go/ql/test/library-tests/semmle/go/frameworks/NoSQL/Query.ql index eb51664650b6..6acacf2cb027 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/NoSQL/Query.ql +++ b/go/ql/test/library-tests/semmle/go/frameworks/NoSQL/Query.ql @@ -6,9 +6,10 @@ class NoSQLQueryTest extends InlineExpectationsTest { override string getARelevantTag() { result = "nosqlquery" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { exists(NoSQL::Query q | - q.hasLocationInfo(file, line, _, _, _) and + q.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and element = q.toString() and value = q.toString() and tag = "nosqlquery" diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Revel/test.ql b/go/ql/test/library-tests/semmle/go/frameworks/Revel/test.ql index 6ec1ec4717ce..e3d2cd16be47 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Revel/test.ql +++ b/go/ql/test/library-tests/semmle/go/frameworks/Revel/test.ql @@ -20,12 +20,13 @@ class MissingDataFlowTest extends InlineExpectationsTest { override string getARelevantTag() { result = "noflow" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "noflow" and value = "" and exists(Sink sink | not any(TestConfig c).hasFlow(_, sink) and - sink.hasLocationInfo(file, line, _, _, _) and + sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and element = sink.toString() ) } @@ -36,10 +37,11 @@ class HttpResponseBodyTest extends InlineExpectationsTest { override string getARelevantTag() { result = "responsebody" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "responsebody" and exists(HTTP::ResponseBody rb | - rb.hasLocationInfo(file, line, _, _, _) and + rb.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and element = rb.toString() and value = "'" + rb.toString() + "'" ) diff --git a/go/ql/test/library-tests/semmle/go/frameworks/SQL/QueryString.ql b/go/ql/test/library-tests/semmle/go/frameworks/SQL/QueryString.ql index 7ad5cb581646..1861a1e408de 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/SQL/QueryString.ql +++ b/go/ql/test/library-tests/semmle/go/frameworks/SQL/QueryString.ql @@ -6,10 +6,11 @@ class SQLTest extends InlineExpectationsTest { override string getARelevantTag() { result = "query" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "query" and exists(SQL::Query q, SQL::QueryString qs, string qsFile, int qsLine | qs = q.getAQueryString() | - q.hasLocationInfo(file, line, _, _, _) and + q.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and qs.hasLocationInfo(qsFile, qsLine, _, _, _) and element = q.toString() and value = qs.toString() @@ -22,11 +23,12 @@ class QueryString extends InlineExpectationsTest { override string getARelevantTag() { result = "querystring" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "querystring" and element = "" and exists(SQL::QueryString qs | not exists(SQL::Query q | qs = q.getAQueryString()) | - qs.hasLocationInfo(file, line, _, _, _) and + qs.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and value = qs.toString() ) } diff --git a/go/ql/test/library-tests/semmle/go/frameworks/StdlibTaintFlow/test.ql b/go/ql/test/library-tests/semmle/go/frameworks/StdlibTaintFlow/test.ql index 30b7a2b47974..57796416265e 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/StdlibTaintFlow/test.ql +++ b/go/ql/test/library-tests/semmle/go/frameworks/StdlibTaintFlow/test.ql @@ -6,9 +6,10 @@ class FileSystemAccessTest extends InlineExpectationsTest { override string getARelevantTag() { result = "fsaccess" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { exists(FileSystemAccess f | - f.hasLocationInfo(file, line, _, _, _) and + f.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and element = f.toString() and value = f.getAPathArgument().toString() and tag = "fsaccess" diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Yaml/tests.ql b/go/ql/test/library-tests/semmle/go/frameworks/Yaml/tests.ql index 5aa7aeac95fc..3d7196f038a3 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Yaml/tests.ql +++ b/go/ql/test/library-tests/semmle/go/frameworks/Yaml/tests.ql @@ -6,10 +6,11 @@ class TaintFunctionModelTest extends InlineExpectationsTest { override string getARelevantTag() { result = "ttfnmodelstep" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "ttfnmodelstep" and exists(TaintTracking::FunctionModel model, DataFlow::CallNode call | call = model.getACall() | - call.hasLocationInfo(file, line, _, _, _) and + call.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and element = call.toString() and value = "\"" + model.getAnInputNode(call) + " -> " + model.getAnOutputNode(call) + "\"" ) @@ -21,10 +22,11 @@ class MarshalerTest extends InlineExpectationsTest { override string getARelevantTag() { result = "marshaler" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "marshaler" and exists(MarshalingFunction m, DataFlow::CallNode call | call = m.getACall() | - call.hasLocationInfo(file, line, _, _, _) and + call.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and element = call.toString() and value = "\"" + m.getFormat() + ": " + m.getAnInput().getNode(call) + " -> " + @@ -38,10 +40,11 @@ class UnmarshalerTest extends InlineExpectationsTest { override string getARelevantTag() { result = "unmarshaler" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "unmarshaler" and exists(UnmarshalingFunction m, DataFlow::CallNode call | call = m.getACall() | - call.hasLocationInfo(file, line, _, _, _) and + call.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and element = call.toString() and value = "\"" + m.getFormat() + ": " + m.getAnInput().getNode(call) + " -> " + diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Zap/TaintFlows.ql b/go/ql/test/library-tests/semmle/go/frameworks/Zap/TaintFlows.ql index 390ef7a60de0..a012615e48ed 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Zap/TaintFlows.ql +++ b/go/ql/test/library-tests/semmle/go/frameworks/Zap/TaintFlows.ql @@ -18,12 +18,13 @@ class ZapTest extends InlineExpectationsTest { override string getARelevantTag() { result = "zap" } - override predicate hasActualResult(string file, int line, string element, string tag, string value) { + override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "zap" and exists(DataFlow::Node sink | any(TestConfig c).hasFlow(_, sink) | element = sink.toString() and value = "\"" + sink.toString() + "\"" and - sink.hasLocationInfo(file, line, _, _, _) + sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) ) } }