From 640b17ec788f26b9e56762e1ecad898ffb13bbe7 Mon Sep 17 00:00:00 2001 From: Matthew Costabile Date: Tue, 5 May 2026 07:41:36 -0400 Subject: [PATCH 01/23] Add UseMemoDirective and UseNoMemoDirective classes --- javascript/ql/lib/semmle/javascript/Stmt.qll | 26 ++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/javascript/ql/lib/semmle/javascript/Stmt.qll b/javascript/ql/lib/semmle/javascript/Stmt.qll index db0d79de7bd..6a757cc1d6c 100644 --- a/javascript/ql/lib/semmle/javascript/Stmt.qll +++ b/javascript/ql/lib/semmle/javascript/Stmt.qll @@ -435,6 +435,32 @@ module Directive { UseClientDirective() { this.getDirectiveText() = "use client" } } + /** + * A `use memo` directive. + * + * Example: + * + * ``` + * "use memo"; + * ``` + */ + class UseMemoDirective extends KnownDirective { + UseMemoDirective() { this.getDirectiveText() = "use memo" } + } + + /** + * A `use no memo` directive. + * + * Example: + * + * ``` + * "use no memo"; + * ``` + */ + class UseNoMemoDirective extends KnownDirective { + UseNoMemoDirective() { this.getDirectiveText() = "use no memo" } + } + /** * A `use cache` directive. * From 0caa48392506265fe7689d344dc2085dc4b67edf Mon Sep 17 00:00:00 2001 From: Matthew Costabile Date: Tue, 5 May 2026 13:20:39 +0000 Subject: [PATCH 02/23] change note and test --- .../2026-05-05-use-memo-directive.md | 4 +++ .../Directives/KnownDirective.expected | 26 +++++++++++-------- .../ql/test/library-tests/Directives/tst.js | 4 +++ 3 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 javascript/ql/lib/change-notes/2026-05-05-use-memo-directive.md diff --git a/javascript/ql/lib/change-notes/2026-05-05-use-memo-directive.md b/javascript/ql/lib/change-notes/2026-05-05-use-memo-directive.md new file mode 100644 index 00000000000..be95205c9ab --- /dev/null +++ b/javascript/ql/lib/change-notes/2026-05-05-use-memo-directive.md @@ -0,0 +1,4 @@ +--- +category: feature +--- +* Added `UseMemoDirective` and `UseNoMemoDirective` classes to model the React compiler directives `"use memo"` and `"use no memo"`. diff --git a/javascript/ql/test/library-tests/Directives/KnownDirective.expected b/javascript/ql/test/library-tests/Directives/KnownDirective.expected index 731158e7e8f..0d7440e3f63 100644 --- a/javascript/ql/test/library-tests/Directives/KnownDirective.expected +++ b/javascript/ql/test/library-tests/Directives/KnownDirective.expected @@ -3,14 +3,18 @@ | tst.js:3:1:3:9 | 'bundle'; | bundle | | tst.js:4:1:4:13 | 'use server'; | use server | | tst.js:5:1:5:13 | 'use client'; | use client | -| tst.js:6:1:6:12 | 'use cache'; | use cache | -| tst.js:7:1:7:20 | 'use cache: remote'; | use cache: remote | -| tst.js:8:1:8:21 | 'use ca ... ivate'; | use cache: private | -| tst.js:17:3:17:12 | 'use asm'; | use asm | -| tst.js:18:3:18:11 | 'bundle'; | bundle | -| tst.js:19:3:19:15 | 'use server'; | use server | -| tst.js:20:3:20:15 | 'use client'; | use client | -| tst.js:21:3:21:14 | 'use cache'; | use cache | -| tst.js:22:3:22:22 | 'use cache: remote'; | use cache: remote | -| tst.js:23:3:23:23 | 'use ca ... ivate'; | use cache: private | -| tst.js:30:5:30:17 | 'use strict'; | use strict | +| tst.js:6:1:6:12 | 'use memo'; | use memo | +| tst.js:7:1:7:15 | 'use no memo'; | use no memo | +| tst.js:8:1:8:12 | 'use cache'; | use cache | +| tst.js:9:1:9:20 | 'use cache: remote'; | use cache: remote | +| tst.js:10:1:10:21 | 'use ca ... ivate'; | use cache: private | +| tst.js:19:3:19:12 | 'use asm'; | use asm | +| tst.js:20:3:20:11 | 'bundle'; | bundle | +| tst.js:21:3:21:15 | 'use server'; | use server | +| tst.js:22:3:22:15 | 'use client'; | use client | +| tst.js:23:3:23:13 | 'use memo'; | use memo | +| tst.js:24:3:24:17 | 'use no memo'; | use no memo | +| tst.js:25:3:25:14 | 'use cache'; | use cache | +| tst.js:26:3:26:22 | 'use cache: remote'; | use cache: remote | +| tst.js:27:3:27:23 | 'use ca ... ivate'; | use cache: private | +| tst.js:34:5:34:17 | 'use strict'; | use strict | diff --git a/javascript/ql/test/library-tests/Directives/tst.js b/javascript/ql/test/library-tests/Directives/tst.js index ec03cbffa0e..7c7676322a4 100644 --- a/javascript/ql/test/library-tests/Directives/tst.js +++ b/javascript/ql/test/library-tests/Directives/tst.js @@ -3,6 +3,8 @@ 'bundle';// and this 'use server'; 'use client'; +'use memo'; +'use no memo'; 'use cache'; 'use cache: remote'; 'use cache: private'; @@ -18,6 +20,8 @@ function f() { 'bundle'; 'use server'; 'use client'; + 'use memo'; + 'use no memo'; 'use cache'; 'use cache: remote'; 'use cache: private'; From 18550039f277e25620c083309ab5cc0e2296c85d Mon Sep 17 00:00:00 2001 From: Matthew Costabile Date: Tue, 5 May 2026 11:06:40 -0400 Subject: [PATCH 03/23] Update KnownDirective.expected --- .../test/library-tests/Directives/KnownDirective.expected | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/javascript/ql/test/library-tests/Directives/KnownDirective.expected b/javascript/ql/test/library-tests/Directives/KnownDirective.expected index 0d7440e3f63..065c0954f74 100644 --- a/javascript/ql/test/library-tests/Directives/KnownDirective.expected +++ b/javascript/ql/test/library-tests/Directives/KnownDirective.expected @@ -3,8 +3,8 @@ | tst.js:3:1:3:9 | 'bundle'; | bundle | | tst.js:4:1:4:13 | 'use server'; | use server | | tst.js:5:1:5:13 | 'use client'; | use client | -| tst.js:6:1:6:12 | 'use memo'; | use memo | -| tst.js:7:1:7:15 | 'use no memo'; | use no memo | +| tst.js:6:1:6:11 | 'use memo'; | use memo | +| tst.js:7:1:7:14 | 'use no memo'; | use no memo | | tst.js:8:1:8:12 | 'use cache'; | use cache | | tst.js:9:1:9:20 | 'use cache: remote'; | use cache: remote | | tst.js:10:1:10:21 | 'use ca ... ivate'; | use cache: private | @@ -13,7 +13,7 @@ | tst.js:21:3:21:15 | 'use server'; | use server | | tst.js:22:3:22:15 | 'use client'; | use client | | tst.js:23:3:23:13 | 'use memo'; | use memo | -| tst.js:24:3:24:17 | 'use no memo'; | use no memo | +| tst.js:24:3:24:16 | 'use no memo'; | use no memo | | tst.js:25:3:25:14 | 'use cache'; | use cache | | tst.js:26:3:26:22 | 'use cache: remote'; | use cache: remote | | tst.js:27:3:27:23 | 'use ca ... ivate'; | use cache: private | From 01173bf383fdb3e13b5be81f57f8215944f211ee Mon Sep 17 00:00:00 2001 From: Anders Schack-Mulligen Date: Mon, 8 Jun 2026 14:01:24 +0200 Subject: [PATCH 04/23] Cfg: Fold getTryInit into indexed getBody. --- .../controlflow/internal/ControlFlowGraph.qll | 2 +- .../lib/semmle/code/java/ControlFlowGraph.qll | 9 ++-- .../codeql/controlflow/ControlFlowGraph.qll | 45 +++++++------------ 3 files changed, 24 insertions(+), 32 deletions(-) diff --git a/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll b/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll index 7e5072637c3..0d8ced82e24 100644 --- a/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll +++ b/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll @@ -203,7 +203,7 @@ module Ast implements AstSig { final private class FinalTryStmt = CS::TryStmt; class TryStmt extends FinalTryStmt { - Stmt getBody() { result = this.getBlock() } + Stmt getBody(int index) { index = 0 and result = this.getBlock() } CatchClause getCatch(int index) { result = this.getCatchClause(index) } diff --git a/java/ql/lib/semmle/code/java/ControlFlowGraph.qll b/java/ql/lib/semmle/code/java/ControlFlowGraph.qll index 3407a43403e..ec1ce80a9b8 100644 --- a/java/ql/lib/semmle/code/java/ControlFlowGraph.qll +++ b/java/ql/lib/semmle/code/java/ControlFlowGraph.qll @@ -117,15 +117,18 @@ private module Ast implements AstSig { final private class FinalTryStmt = J::TryStmt; class TryStmt extends FinalTryStmt { - Stmt getBody() { result = super.getBlock() } + Stmt getBody(int index) { + result = super.getResource(index) + or + index = count(super.getAResource()) and + result = super.getBlock() + } CatchClause getCatch(int index) { result = super.getCatchClause(index) } Stmt getFinally() { result = super.getFinally() } } - AstNode getTryInit(TryStmt try, int index) { result = try.getResource(index) } - final private class FinalCatchClause = J::CatchClause; class CatchClause extends FinalCatchClause { diff --git a/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll b/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll index 33a609d5552..4e6fd7ac2d4 100644 --- a/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll +++ b/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll @@ -185,8 +185,12 @@ signature module AstSig { /** A `try` statement with `catch` and/or `finally` clauses. */ class TryStmt extends Stmt { - /** Gets the body of this `try` statement. */ - Stmt getBody(); + /** + * Gets the body of this `try` statement at the specified (zero-based) + * position `index`. In some languages, there is only ever a single body + * (with `index` 0). + */ + Stmt getBody(int index); /** * Gets the `catch` clause at the specified (zero-based) position `index` @@ -198,15 +202,6 @@ signature module AstSig { Stmt getFinally(); } - /** - * Gets the initializer of this `try` statement at the specified (zero-based) - * position `index`, if any. - * - * An example of this are resource declarations in Java's try-with-resources - * statement. - */ - default AstNode getTryInit(TryStmt try, int index) { none() } - /** * Gets the `else` block of this `try` statement, if any. * @@ -699,7 +694,7 @@ module Make0 Ast> { or exists(TryStmt trystmt | trystmt = n and - cannotTerminateNormally(trystmt.getBody()) and + cannotTerminateNormally(trystmt.getBody(_)) and forall(CatchClause catch | trystmt.getCatch(_) = catch | cannotTerminateNormally(catch.getBody()) ) @@ -1256,11 +1251,7 @@ module Make0 Ast> { ) ) or - exists(TryStmt trystmt | - ast = getTryInit(trystmt, _) - or - ast = trystmt.getBody() - | + exists(TryStmt trystmt | ast = trystmt.getBody(_) | c.getSuccessorType() instanceof ExceptionSuccessor and ( n.isBefore(trystmt.getCatch(0)) @@ -1635,16 +1626,11 @@ module Make0 Ast> { or exists(TryStmt trystmt | n1.isBefore(trystmt) and - ( - n2.isBefore(getTryInit(trystmt, 0)) - or - not exists(getTryInit(trystmt, _)) and n2.isBefore(trystmt.getBody()) - ) + n2.isBefore(trystmt.getBody(0)) or - exists(int i | n1.isAfter(getTryInit(trystmt, i)) | - n2.isBefore(getTryInit(trystmt, i + 1)) - or - not exists(getTryInit(trystmt, i + 1)) and n2.isBefore(trystmt.getBody()) + exists(int i | + n1.isAfter(trystmt.getBody(i)) and + n2.isBefore(trystmt.getBody(i + 1)) ) or exists(PreControlFlowNode beforeElse, PreControlFlowNode beforeFinally | @@ -1659,8 +1645,11 @@ module Make0 Ast> { not exists(trystmt.getFinally()) and beforeFinally.isAfter(trystmt) ) | - n1.isAfter(trystmt.getBody()) and - n2 = beforeElse + exists(int i | + n1.isAfter(trystmt.getBody(i)) and + not exists(trystmt.getBody(i + 1)) and + n2 = beforeElse + ) or n1.isAfter(getTryElse(trystmt)) and n2 = beforeFinally From 1c1d26453ddec0796b22968273afe81006e5084c Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Wed, 10 Jun 2026 07:46:42 +0200 Subject: [PATCH 05/23] First pass converting qlref tests to inline expectation with postprocess --- .../examples/NonceReuse/NonceReuse.qlref | 4 +- .../quantum/examples/NonceReuse/Test.java | 10 +- .../security/CWE-020/Log4jInjectionTest.qlref | 4 +- .../CWE-020/Log4jJndiInjectionTest.java | 2096 ++++++++--------- .../security/CWE-073/FilePathInjection.java | 18 +- .../security/CWE-073/FilePathInjection.qlref | 4 +- .../CommandInjectionRuntimeExecLocal.qlref | 4 +- .../security/CWE-078/ExecTainted.qlref | 4 +- .../security/CWE-078/JSchOSInjectionTest.java | 8 +- .../security/CWE-078/RuntimeExecTest.java | 12 +- .../main/MyBatisAnnotationSqlInjection.qlref | 4 +- .../main/MyBatisMapperXmlSqlInjection.qlref | 4 +- .../CWE-089/src/main/MybatisSqlInjection.java | 20 +- .../src/main/MybatisSqlInjectionService.java | 20 +- .../security/CWE-094/BeanShellInjection.java | 12 +- .../security/CWE-094/BeanShellInjection.qlref | 4 +- .../security/CWE-094/JShellInjection.java | 14 +- .../security/CWE-094/JShellInjection.qlref | 4 +- .../CWE-094/JakartaExpressionInjection.java | 18 +- .../CWE-094/JakartaExpressionInjection.qlref | 4 +- .../security/CWE-094/JythonInjection.java | 18 +- .../security/CWE-094/JythonInjection.qlref | 4 +- .../security/CWE-094/RhinoServlet.java | 12 +- .../security/CWE-094/ScriptEngineTest.java | 14 +- .../security/CWE-094/ScriptInjection.qlref | 4 +- .../security/CWE-200/FileService.java | 2 +- .../CWE-200/InsecureWebResourceResponse.java | 12 +- .../CWE-200/InsecureWebResourceResponse.qlref | 4 +- .../CWE-200/InsecureWebViewActivity.java | 4 +- .../security/CWE-200/LeakFileActivity.java | 4 +- .../security/CWE-200/LeakFileActivity2.java | 4 +- .../CWE-200/SensitiveAndroidFileLeak.qlref | 4 +- .../NotConstantTimeCheckOnSignature/Test.java | 14 +- .../Test.qlref | 4 +- .../TimingAttackAgainstHeader/Test.java | 2 +- .../TimingAttackAgainstHeader.qlref | 3 +- .../TimingAttackAgainstSignagure/Test.java | 38 +- .../TimingAttackAgainstSignagure/Test.qlref | 4 +- .../JxBrowserWithoutCertValidation.qlref | 3 +- ...JxBrowserWithoutCertValidationV6_23_1.java | 4 +- .../JxBrowserWithoutCertValidation.qlref | 3 +- .../CWE-297/IgnoredHostnameVerification.java | 4 +- .../CWE-297/IgnoredHostnameVerification.qlref | 3 +- .../CWE-297/InsecureLdapEndpoint.java | 10 +- .../CWE-297/InsecureLdapEndpoint.qlref | 3 +- .../CWE-299/DisabledRevocationChecking.java | 4 +- .../CWE-299/DisabledRevocationChecking.qlref | 4 +- .../security/CWE-327/UnsafeTlsVersion.java | 70 +- .../security/CWE-327/UnsafeTlsVersion.qlref | 4 +- .../security/CWE-346/UnvalidatedCors.java | 4 +- .../security/CWE-346/UnvalidatedCors.qlref | 4 +- .../security/CWE-347/Auth0NoVerifier.qlref | 4 +- .../security/CWE-347/JwtNoVerifier.java | 6 +- .../ClientSuppliedIpUsedInSecurityCheck.java | 6 +- .../ClientSuppliedIpUsedInSecurityCheck.qlref | 4 +- .../security/CWE-352/JsonpController.java | 30 +- .../security/CWE-352/JsonpInjection.qlref | 4 +- .../CWE-400/LocalThreadResourceAbuse.qlref | 4 +- .../security/CWE-400/ThreadResourceAbuse.java | 26 +- .../CWE-400/ThreadResourceAbuse.qlref | 4 +- .../security/CWE-400/UploadListener.java | 2 +- .../security/CWE-470/BadClassLoader.java | 6 +- .../CWE-470/LoadClassNoSignatureCheck.qlref | 4 +- .../security/CWE-470/UnsafeReflection.java | 12 +- .../security/CWE-470/UnsafeReflection.qlref | 4 +- .../security/CWE-489/ServiceBean.java | 2 +- .../security/CWE-489/ServiceBean.qlref | 3 +- .../CWE-489/ServletContextListenerMain.java | 2 +- .../security/CWE-489/ServletMain.java | 2 +- .../security/CWE-489/ServletMain.qlref | 3 +- .../SpringExporterUnsafeDeserialization.java | 12 +- .../CWE-502/UnsafeDeserializationRmi.java | 10 +- .../CWE-502/UnsafeDeserializationRmi.qlref | 4 +- ...feSpringExporterInConfigurationClass.qlref | 3 +- ...safeSpringExporterInXMLConfiguration.qlref | 3 +- .../query-tests/security/CWE-502/beans.xml | 8 +- .../CWE-548/InsecureDirectoryConfig.qlref | 3 +- .../security/CWE-548/insecure-web.xml | 4 +- .../CWE-555/PasswordInConfigurationFile.qlref | 3 +- .../security/CWE-555/applicationContext.xml | 2 +- .../query-tests/security/CWE-555/context.xml | 4 +- .../security/CWE-555/custom-config.xml | 2 +- .../security/CWE-598/SensitiveGetQuery.java | 6 +- .../security/CWE-598/SensitiveGetQuery.qlref | 4 +- .../security/CWE-598/SensitiveGetQuery2.java | 6 +- .../security/CWE-598/SensitiveGetQuery3.java | 4 +- .../security/CWE-598/SensitiveGetQuery4.java | 4 +- .../CWE-600/UncaughtServletException.java | 16 +- .../CWE-600/UncaughtServletException.qlref | 4 +- .../security/CWE-601/SpringUrlRedirect.java | 56 +- .../security/CWE-601/SpringUrlRedirect.qlref | 4 +- .../security/CWE-625/DotRegexFilter.java | 6 +- .../security/CWE-625/DotRegexServlet.java | 16 +- .../security/CWE-625/DotRegexSpring.java | 8 +- .../security/CWE-625/PermissiveDotRegex.qlref | 4 +- .../security/CWE-652/XQueryInjection.java | 40 +- .../security/CWE-652/XQueryInjection.qlref | 4 +- ...nsecureRmiJmxEnvironmentConfiguration.java | 8 +- ...secureRmiJmxEnvironmentConfiguration.qlref | 3 +- .../security/CWE-755/NFEAndroidDoS.java | 20 +- .../security/CWE-755/NFEAndroidDoS.qlref | 4 +- .../security/CWE-759/HashWithoutSalt.java | 12 +- .../security/CWE-759/HashWithoutSalt.qlref | 4 +- .../frameworks/JaxWs/UrlRedirect.qlref | 4 +- .../frameworks/JaxWs/UrlRedirectJakarta.java | 4 +- .../frameworks/JaxWs/UrlRedirectJax.java | 4 +- .../AmbiguousOuterSuper.qlref | 3 +- .../AmbiguousOuterSuper/GenericTest.java | 2 +- .../query-tests/AmbiguousOuterSuper/Test.java | 2 +- .../query-tests/AutoBoxing/AutoBoxing.qlref | 3 +- java/ql/test/query-tests/AutoBoxing/Test.java | 22 +- .../AvoidDeprecatedCallableAccess.qlref | 3 +- .../AvoidDeprecatedCallableAccess/Test.java | 6 +- .../BadAbsOfRandom/BadAbsOfRandom.qlref | 3 +- .../test/query-tests/BadAbsOfRandom/Test.java | 12 +- .../query-tests/BadCheckOdd/BadCheckOdd.java | 20 +- .../query-tests/BadCheckOdd/BadCheckOdd.qlref | 3 +- .../BoxedVariable/BoxedVariable.java | 10 +- .../BoxedVariable/BoxedVariable.qlref | 3 +- .../test/query-tests/BusyWait/BusyWait.qlref | 3 +- .../test/query-tests/BusyWait/BusyWaits.java | 6 +- .../CloseReader/CloseReader.java | 8 +- .../CloseReader/CloseReader.qlref | 3 +- .../CloseWriter/CloseWriter.java | 6 +- .../CloseWriter/CloseWriter.qlref | 3 +- .../query-tests/CompareIdenticalValues/A.java | 36 +- .../CompareIdenticalValues.qlref | 3 +- .../ComplexCondition/ComplexCondition.java | 8 +- .../ComplexCondition/ComplexCondition.qlref | 3 +- .../ConfusingOverloading.qlref | 3 +- .../TestConfusingOverloading.java | 2 +- .../ConstantExpAppearsNonConstant.qlref | 3 +- .../ConstantExpAppearsNonConstant/Test.java | 22 +- .../query-tests/ConstantLoopCondition/A.java | 8 +- .../ConstantLoopCondition.qlref | 3 +- .../ContainerSizeCmpZero.qlref | 3 +- .../ContainerSizeCmpZero/Main.java | 36 +- .../query-tests/ContinueInFalseLoop/A.java | 6 +- .../ContinueInFalseLoop.qlref | 3 +- .../ContradictoryTypeChecks.qlref | 3 +- .../ContradictoryTypeChecks/Test.java | 12 +- .../DeadCode/DeadRefTypes/DeadRefTypes.qlref | 3 +- .../DeadCode/DeadRefTypes/UnusedClass.java | 2 +- .../NonAssignedFields/NonAssignedFields.qlref | 3 +- .../DeadCode/camel/DeadClass.qlref | 3 +- .../DeadCode/camel/DeadMethod.qlref | 3 +- .../camel/com/semmle/camel/DeadTarget.java | 4 +- .../camel/javadsl/CustomRouteBuilder.java | 2 +- .../Declarations/BreakInSwitchCase.qlref | 3 +- .../test/query-tests/Declarations/Test.java | 4 +- .../DefineEqualsWhenAddingFields.qlref | 4 +- .../query-tests/DoubleCheckedLocking/A.java | 16 +- .../DoubleCheckedLocking.qlref | 3 +- .../DoubleCheckedLockingWithInitRace.qlref | 3 +- .../query-tests/EqualsArray/EqualsArray.qlref | 3 +- .../ql/test/query-tests/EqualsArray/Test.java | 6 +- .../EqualsUsesInstanceOf.qlref | 3 +- .../ExposeRepresentation.qlref | 3 +- .../ExposeRepresentation/ExposesRep.java | 10 +- java/ql/test/query-tests/Finally/Finally.java | 14 +- .../Finally/FinallyMayNotComplete.qlref | 3 +- .../HashedButNoHash/HashedButNoHash.qlref | 3 +- .../query-tests/HashedButNoHash/Test.java | 2 +- .../IgnoreExceptionalReturn.qlref | 3 +- .../IgnoreExceptionalReturn/Test.java | 12 +- .../ImpossibleCast/ImpossibleCast.qlref | 3 +- .../ImpossibleCast/impossible_cast/A.java | 4 +- .../InconsistentEqualsHashCode.qlref | 3 +- .../InconsistentEqualsHashCode/Test.java | 6 +- .../InconsistentCallOnResult.qlref | 3 +- .../InconsistentOperations/Operations.java | 4 +- .../ReturnValueIgnored.qlref | 3 +- .../InconsistentOperations/Test2.java | 4 +- .../InconsistentOperations/Test3.java | 4 +- .../InefficientOutputStream.qlref | 3 +- .../InefficientOutputStreamBad.java | 2 +- .../InnerClassCouldBeStatic/Classes.java | 42 +- .../InnerClassCouldBeStatic.qlref | 3 +- .../InnerClassCouldBeStatic/Test.java | 2 +- .../Iterable/IterableIterator.qlref | 3 +- java/ql/test/query-tests/Iterable/Test.java | 6 +- .../Iterable/WrappedIterator.qlref | 3 +- .../IteratorRemoveMayFail.qlref | 3 +- .../IteratorRemoveMayFail/Test.java | 6 +- .../Javadoc/ImpossibleJavadocThrows.java | 6 +- .../Javadoc/ImpossibleJavadocThrows.qlref | 3 +- .../LShiftLargerThanTypeWidth/A.java | 44 +- .../LShiftLargerThanTypeWidth.qlref | 3 +- .../LazyInitStaticField.qlref | 3 +- .../LazyInitStaticField/LazyInits.java | 14 +- .../MissingEnumInSwitch.qlref | 3 +- .../Statements/MissingEnumInSwitch/Test.java | 20 +- .../MissedTernaryOpportunity.qlref | 3 +- .../MissedTernaryOpportunityTest.java | 12 +- .../MissingCallToSuperClone.qlref | 3 +- .../MissingCallToSuperClone/Test.java | 2 +- .../MissingInstanceofInEquals/Bad.java | 4 +- .../MissingInstanceofInEquals.qlref | 3 +- .../MissingOverrideAnnotation.qlref | 3 +- .../MissingOverrideAnnotation/Test.java | 4 +- .../test/query-tests/MissingSpaceTypo/A.java | 28 +- .../MissingSpaceTypo/MissingSpaceTypo.qlref | 3 +- ...issingVoidConstructorsOnSerializable.qlref | 3 +- .../Test.java | 2 +- .../MutualDependency/MutualDependency.qlref | 3 +- .../onepackage/MutualDependency.java | 2 +- .../Naming/ConfusingOverloading.qlref | 3 +- .../test/query-tests/Naming/NamingTest.java | 2 +- .../NonPrivateField/NonPrivateField.qlref | 3 +- .../NonPrivateField/NonPrivateFieldTest.java | 16 +- .../NonSerializableField.qlref | 3 +- .../NonSerializableFieldTest.java | 32 +- .../NonSerializableInnerClass.qlref | 3 +- .../NonSerializableInnerClassTest.java | 10 +- .../NonSynchronizedOverride.qlref | 3 +- .../NonSynchronizedOverride/Test.java | 10 +- .../NotifyWithoutSynch.qlref | 3 +- .../query-tests/NotifyWithoutSynch/Test.java | 20 +- java/ql/test/query-tests/Nullness/A.java | 42 +- java/ql/test/query-tests/Nullness/B.java | 50 +- java/ql/test/query-tests/Nullness/C.java | 14 +- .../test/query-tests/Nullness/ExprDeref.java | 2 +- java/ql/test/query-tests/Nullness/F.java | 4 +- java/ql/test/query-tests/Nullness/G.java | 2 +- .../query-tests/Nullness/NullAlways.qlref | 3 +- .../query-tests/Nullness/NullExprDeref.qlref | 3 +- .../test/query-tests/Nullness/NullMaybe.qlref | 3 +- .../NumberFormatException.qlref | 3 +- .../NumberFormatException/Test.java | 60 +- .../PartiallyMaskedCatch.qlref | 3 +- .../PartiallyMaskedCatchTest.java | 6 +- .../PointlessForwardingMethod.qlref | 3 +- .../pointlessforwardingmethod/Test.java | 2 +- .../query-tests/PrintLnArray/PrintLn.qlref | 3 +- .../test/query-tests/PrintLnArray/Test.java | 4 +- .../RandomUsedOnce/RandomUsedOnce.qlref | 3 +- .../test/query-tests/RandomUsedOnce/Test.java | 2 +- java/ql/test/query-tests/RangeAnalysis/A.java | 34 +- .../RangeAnalysis/ArrayIndexOutOfBounds.qlref | 3 +- .../ReadOnlyContainer/ReadOnlyContainer.qlref | 3 +- .../query-tests/ReadOnlyContainer/Test.java | 6 +- .../ReturnValueIgnored.qlref | 3 +- .../return_value_ignored/Test.java | 4 +- .../SelfAssignment/SelfAssignment.qlref | 3 +- .../test/query-tests/SelfAssignment/Test.java | 4 +- .../SimplifyBoolExpr/SimplifyBoolExpr.java | 18 +- .../SimplifyBoolExpr/SimplifyBoolExpr.qlref | 3 +- .../SpuriousJavadocParam/Test.java | 34 +- .../SpuriousJavadocParam/test.qlref | 3 +- .../StartInConstructor.qlref | 3 +- .../query-tests/StartInConstructor/Test.java | 2 +- .../query-tests/StaticArray/StaticArray.java | 10 +- .../query-tests/StaticArray/StaticArray.qlref | 3 +- .../StringComparison/StringComparison.java | 6 +- .../StringComparison/StringComparison.qlref | 3 +- java/ql/test/query-tests/StringFormat/A.java | 64 +- .../StringFormat/MissingFormatArg.qlref | 3 +- .../StringFormat/UnusedFormatArg.qlref | 3 +- .../query-tests/SuspiciousDateFormat/A.java | 2 +- .../SuspiciousDateFormat.qlref | 3 +- .../SynchSetUnsynchSet.qlref | 3 +- .../query-tests/SynchSetUnsynchGet/Test.java | 4 +- .../TypeMismatch/IncomparableEquals.qlref | 3 +- .../TypeMismatch/RemoveTypeMismatch.qlref | 3 +- .../TypeMismatch/incomparable_equals/B.java | 2 +- .../TypeMismatch/incomparable_equals/F.java | 4 +- .../TypeMismatch/remove_type_mismatch/A.java | 12 +- java/ql/test/query-tests/UnreadLocal/A.java | 12 +- .../UnreadLocal/DeadStoreOfLocal.qlref | 3 +- .../UnreadLocal/DeadStoreOfLocalUnread.qlref | 3 +- .../query-tests/UnreadLocal/UnreadLocal.qlref | 3 +- .../UnreadLocal/ImplicitReads.java | 2 +- .../UnreadLocal/UnreadLocal/UnreadLocals.java | 4 +- .../UnreleasedLock/UnreleasedLock.java | 12 +- .../UnreleasedLock/UnreleasedLock.qlref | 3 +- .../test/query-tests/UseBraces/UseBraces.java | 28 +- .../query-tests/UseBraces/UseBraces.qlref | 3 +- .../query-tests/UselessComparisonTest/A.java | 30 +- .../UselessComparisonTest/CharLiterals.java | 8 +- .../UselessComparisonTest/Test.java | 16 +- .../UselessComparisonTest.qlref | 3 +- .../test/query-tests/UselessNullCheck/A.java | 16 +- .../UselessNullCheck/UselessNullCheck.qlref | 3 +- .../test/query-tests/UselessUpcast/Test.java | 6 +- .../test/query-tests/UselessUpcast/Test2.java | 4 +- .../UselessUpcast/UselessUpcast.qlref | 3 +- .../WhitespaceContradictsPrecedence.java | 4 +- .../WhitespaceContradictsPrecedence.qlref | 3 +- .../WriteOnlyContainer/CollectionTest.java | 4 +- .../WriteOnlyContainer/MapTest.java | 4 +- .../WriteOnlyContainer.qlref | 3 +- .../query-tests/WrongNanComparison/Test.java | 4 +- .../WrongNanComparison.qlref | 3 +- .../dead-code/DeadCallable/DeadCallable.qlref | 3 +- .../dead-code/DeadCallable/Main.java | 10 +- .../dead-code/DeadClass/DeadClass.qlref | 3 +- .../dead-code/DeadClass/DeadEnumTest.java | 2 +- .../DeadClass/ExternalDeadCodeCycle.java | 2 +- .../dead-code/DeadClass/ExternalDeadRoot.java | 2 +- .../DeadClass/InternalDeadCodeCycle.java | 2 +- .../dead-code/DeadClass/NamespaceTest.java | 2 +- .../DeadEnumConstant/DeadEnumConstant.qlref | 3 +- .../DeadEnumConstantTest.java | 4 +- .../DeadField/AnnotationValueTest.java | 2 +- .../DeadField/AnnotationValueUtil.java | 6 +- .../dead-code/DeadField/BasicTest.java | 6 +- .../dead-code/DeadField/DeadField.qlref | 3 +- .../dead-code/DeadField/ReflectionTest.java | 4 +- .../dead-code/DeadMethod/DeadMethod.qlref | 3 +- .../DeadMethod/InternalDeadCodeCycle.java | 4 +- .../dead-code/DeadMethod/JMXTest.java | 2 +- .../DeadMethod/SuppressedConstructorTest.java | 6 +- .../dead-code/UselessParameter/Test.java | 2 +- .../UselessParameter/UselessParameter.qlref | 3 +- .../UnusedMavenDependencyBinary.qlref | 3 +- .../UnusedMavenDependencySource.qlref | 3 +- .../maven-dependencies/my-project/pom.xml | 8 +- .../CWE-020/OverlyLargeRangeQuery.qlref | 3 +- .../CWE-020/SuspiciousRegexpRange.java | 20 +- .../CWE-022/semmle/tests/ZipSlip.qlref | 4 +- .../CWE-022/semmle/tests/ZipTest.java | 8 +- .../security/CWE-078/ExecRelative.qlref | 3 +- .../security/CWE-078/ExecTainted.qlref | 4 +- .../security/CWE-078/ExecUnescaped.qlref | 3 +- .../security/CWE-078/TaintedEnvironment.java | 2 +- .../query-tests/security/CWE-078/Test.java | 14 +- .../semmle/tests/SetJavascriptEnabled.java | 2 +- .../tests/WebViewAddJavascriptInterface.java | 2 +- .../tests/WebViewAddJavascriptInterface.qlref | 3 +- .../tests/WebViewSetEnabledJavaScript.qlref | 3 +- .../AllowListSanitizerWithJavaUtilList.java | 54 +- .../AllowListSanitizerWithJavaUtilSet.java | 54 +- .../CWE-089/semmle/examples/CouchBase.java | 14 +- .../CWE-089/semmle/examples/Mongo.java | 8 +- .../semmle/examples/SqlConcatenated.qlref | 3 +- .../CWE-089/semmle/examples/SqlTainted.qlref | 4 +- .../CWE-089/semmle/examples/Test.java | 24 +- .../security/CWE-090/LdapInjection.java | 164 +- .../security/CWE-090/LdapInjection.qlref | 4 +- .../CWE-094/InsecureBeanValidation.java | 4 +- .../CWE-094/InsecureBeanValidation.qlref | 4 +- .../tests/MavenPomDependsOnBintray.qlref | 3 +- .../CWE-1104/semmle/tests/bad-bintray-pom.xml | 10 +- .../semmle/tests/ResponseSplitting.java | 12 +- .../semmle/tests/ResponseSplitting.qlref | 4 +- ...mproperValidationOfArrayConstruction.qlref | 4 +- ...tionOfArrayConstructionCodeSpecified.qlref | 4 +- .../ImproperValidationOfArrayIndex.qlref | 4 +- ...rValidationOfArrayIndexCodeSpecified.qlref | 4 +- .../security/CWE-129/semmle/tests/Test.java | 28 +- .../ExternallyControlledFormatString.qlref | 4 +- .../security/CWE-134/semmle/tests/Test.java | 16 +- .../semmle/tests/ArithmeticTainted.java | 20 +- .../semmle/tests/ArithmeticTainted.qlref | 4 +- .../semmle/tests/ArithmeticUncontrolled.qlref | 4 +- .../tests/ArithmeticWithExtremeValues.qlref | 4 +- .../semmle/tests/ComparisonWithWiderType.java | 6 +- .../tests/ComparisonWithWiderType.qlref | 3 +- .../semmle/tests/InformationLoss.qlref | 3 +- .../CWE-190/semmle/tests/IntMultToLong.qlref | 3 +- .../security/CWE-190/semmle/tests/Test.java | 54 +- .../Files.java | 4 +- .../TempDirLocalInformationDisclosure.qlref | 4 +- .../Test.java | 78 +- .../WebViewAccess/WebViewContentAccess.java | 20 +- .../WebViewAccess/WebViewContentAccess.qlref | 3 +- .../WebViewAccess/WebViewFileAccess.java | 6 +- .../WebViewAccess/WebViewFileAccess.qlref | 3 +- ...itiveDataExposureThroughErrorMessage.qlref | 3 +- .../semmle/tests/StackTraceExposure.qlref | 3 +- .../security/CWE-209/semmle/tests/Test.java | 8 +- .../CWE-297/UnsafeHostnameVerification.java | 22 +- .../CWE-297/UnsafeHostnameVerification.qlref | 4 +- .../security/CWE-311/CWE-319/HttpsUrls.qlref | 4 +- .../CWE-311/CWE-319/HttpsUrlsTest.java | 18 +- .../security/CWE-311/CWE-319/UseSSL.qlref | 3 +- .../security/CWE-311/CWE-319/UseSSLTest.java | 2 +- .../CWE-614/semmle/tests/InsecureCookie.qlref | 3 +- .../CWE-311/CWE-614/semmle/tests/Test.java | 8 +- .../backup/AllowBackupEnabledTest.qlref | 3 +- .../TestExplicitlyEnabled/AndroidManifest.xml | 2 +- .../backup/TestMissing/AndroidManifest.xml | 2 +- .../semmle/tests/BrokenCryptoAlgorithm.qlref | 4 +- .../tests/MaybeBrokenCryptoAlgorithm.qlref | 3 +- .../security/CWE-327/semmle/tests/Test.java | 6 +- .../CWE-327/semmle/tests/WeakHashing.java | 6 +- .../semmle/tests/PredictableSeed.qlref | 3 +- .../security/CWE-335/semmle/tests/Test.java | 6 +- .../semmle/tests/JHipsterGeneratedPRNG.qlref | 3 +- .../semmle/tests/vulnerable/RandomUtil.java | 10 +- .../CWE-421/semmle/SocketAuthRace.qlref | 3 +- .../security/CWE-421/semmle/Test.java | 6 +- .../CWE-601/semmle/tests/UrlRedirect.java | 8 +- .../CWE-601/semmle/tests/UrlRedirect.qlref | 4 +- .../CWE-601/semmle/tests/UrlRedirect2.java | 2 +- .../CWE-601/semmle/tests/mad/Test.java | 4 +- .../tests/PotentiallyDangerousFunction.qlref | 3 +- .../security/CWE-676/semmle/tests/Test.java | 2 +- .../semmle/tests/NumericCastTainted.qlref | 4 +- .../security/CWE-681/semmle/tests/Test.java | 6 +- .../tests/ReadingFromWorldWritableFile.qlref | 3 +- .../security/CWE-732/semmle/tests/Test.java | 6 +- .../tests/TaintedPermissionsCheck.qlref | 4 +- .../tests/TaintedPermissionsCheckTest.java | 4 +- .../tests/InsecureDependencyResolution.qlref | 3 +- .../CWE-829/semmle/tests/insecure-pom.xml | 10 +- .../semmle/tests/LockOrderInconsistency.qlref | 3 +- .../semmle/tests/MethodAccessLockOrder.java | 2 +- .../semmle/tests/ReentrantLockOrder.java | 4 +- .../tests/SynchronizedStmtLockOrder.java | 4 +- .../CWE-835/semmle/tests/InfiniteLoop.java | 2 +- .../CWE-835/semmle/tests/InfiniteLoop.qlref | 3 +- .../org/apache/camel/Consume.java | 8 +- .../camel/builder/ExpressionClause.java | 2 +- .../apache/camel/builder/RouteBuilder.java | 4 +- .../camel/impl/DefaultCamelContext.java | 2 +- .../apache/camel/model/FilterDefinition.java | 2 +- .../apache/camel/model/OutputDefinition.java | 2 +- .../camel/model/ProcessorDefinition.java | 2 +- .../apache/camel/model/RouteDefinition.java | 2 +- 420 files changed, 2846 insertions(+), 2598 deletions(-) diff --git a/java/ql/test/experimental/query-tests/quantum/examples/NonceReuse/NonceReuse.qlref b/java/ql/test/experimental/query-tests/quantum/examples/NonceReuse/NonceReuse.qlref index 9658a376bb9..b3c88b353dd 100644 --- a/java/ql/test/experimental/query-tests/quantum/examples/NonceReuse/NonceReuse.qlref +++ b/java/ql/test/experimental/query-tests/quantum/examples/NonceReuse/NonceReuse.qlref @@ -1,2 +1,4 @@ query: experimental/quantum/Examples/ReusedNonce.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/quantum/examples/NonceReuse/Test.java b/java/ql/test/experimental/query-tests/quantum/examples/NonceReuse/Test.java index e384143db08..80524e269e7 100644 --- a/java/ql/test/experimental/query-tests/quantum/examples/NonceReuse/Test.java +++ b/java/ql/test/experimental/query-tests/quantum/examples/NonceReuse/Test.java @@ -16,7 +16,7 @@ public class Test { private static byte[] getRandomWrapper1() throws Exception { byte[] val = new byte[16]; - new SecureRandom().nextBytes(val); + new SecureRandom().nextBytes(val); // $ Source return val; } @@ -37,7 +37,7 @@ public class Test { IvParameterSpec ivSpec = new IvParameterSpec(iv); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); SecretKey key = generateAESKey(); - cipher.init(Cipher.ENCRYPT_MODE, key, ivSpec); // BAD: Reuse of `iv` in funcB1 + cipher.init(Cipher.ENCRYPT_MODE, key, ivSpec); // $ Alert // BAD: Reuse of `iv` in funcB1 byte[] ciphertext = cipher.doFinal("Simple Test Data".getBytes()); } @@ -46,7 +46,7 @@ public class Test { IvParameterSpec ivSpec = new IvParameterSpec(iv); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); SecretKey key = generateAESKey(); - cipher.init(Cipher.ENCRYPT_MODE, key, ivSpec); // BAD: Reuse of `iv` in funcA1 + cipher.init(Cipher.ENCRYPT_MODE, key, ivSpec); // $ Alert // BAD: Reuse of `iv` in funcA1 byte[] ciphertext = cipher.doFinal("Simple Test Data".getBytes()); } @@ -73,13 +73,13 @@ public class Test { IvParameterSpec ivSpec1 = new IvParameterSpec(iv); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); SecretKey key1 = generateAESKey(); - cipher.init(Cipher.ENCRYPT_MODE, key1, ivSpec1); // BAD: reuse of `iv` below + cipher.init(Cipher.ENCRYPT_MODE, key1, ivSpec1); // $ Alert // BAD: reuse of `iv` below byte[] ciphertext = cipher.doFinal("Simple Test Data".getBytes()); IvParameterSpec ivSpec2 = new IvParameterSpec(iv); Cipher cipher2 = Cipher.getInstance("AES/CBC/PKCS5Padding"); SecretKey key2 = generateAESKey(); - cipher2.init(Cipher.ENCRYPT_MODE, key2, ivSpec2); // BAD: Reuse of `iv` above + cipher2.init(Cipher.ENCRYPT_MODE, key2, ivSpec2); // $ Alert // BAD: Reuse of `iv` above byte[] ciphertext2 = cipher2.doFinal("Simple Test Data".getBytes()); } diff --git a/java/ql/test/experimental/query-tests/security/CWE-020/Log4jInjectionTest.qlref b/java/ql/test/experimental/query-tests/security/CWE-020/Log4jInjectionTest.qlref index ea158af1e3a..3b0cb0955c9 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-020/Log4jInjectionTest.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-020/Log4jInjectionTest.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-020/Log4jJndiInjection.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-020/Log4jJndiInjectionTest.java b/java/ql/test/experimental/query-tests/security/CWE-020/Log4jJndiInjectionTest.java index c180fdc40f1..25f43bf4e69 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-020/Log4jJndiInjectionTest.java +++ b/java/ql/test/experimental/query-tests/security/CWE-020/Log4jJndiInjectionTest.java @@ -21,985 +21,985 @@ public class Log4jJndiInjectionTest { private HttpServletRequest request; public Object source() { - return request.getParameter("source"); + return request.getParameter("source"); // $ Source } public void test() { Logger logger = null; { // @formatter:off - logger.debug((CharSequence) source()); - logger.debug((CharSequence) source(), (Throwable) null); - logger.debug((Marker) null, (CharSequence) source()); - logger.debug((Marker) null, (CharSequence) source(), null); - logger.debug((Marker) null, (Message) source()); - logger.debug((Marker) null, (MessageSupplier) source()); - logger.debug((Marker) null, (MessageSupplier) source(), null); - logger.debug((Marker) null, source()); - logger.debug((Marker) null, (String) source()); - logger.debug((Marker) null, (String) source(), new Object[] {}); - logger.debug((Marker) null, (String) null, new Object[] {source()}); - logger.debug((Marker) null, (String) null, (Object) source()); - logger.debug((Marker) null, (String) source(), (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) source()); - logger.debug((Marker) null, (String) null, (Object) source(), (Object) null); - logger.debug((Marker) null, (String) source(), (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) source()); - logger.debug((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null); - logger.debug((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null); - logger.debug((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((Marker) null, (String) source(), (Supplier) null); - logger.debug((Marker) null, (String) null, (Supplier) source()); - logger.debug((Marker) null, (String) source(), (Throwable) null); - logger.debug((Marker) null, (Supplier) source()); - logger.debug((Marker) null, (Supplier) source(), (Throwable) null); - logger.debug((MessageSupplier) source()); - logger.debug((MessageSupplier) source(), (Throwable) null); - logger.debug((Message) source()); - logger.debug((Message) source(), (Throwable) null); - logger.debug(source()); - logger.debug(source(), (Throwable) null); - logger.debug((String) source()); - logger.debug((String) source(), (Object[]) null); - logger.debug((String) null, new Object[] {source()}); - logger.debug((String) null, (Object) source()); - logger.debug((String) source(), (Object) null); - logger.debug((String) null, (Object) null, (Object) source()); - logger.debug((String) null, (Object) source(), (Object) null); - logger.debug((String) source(), (Object) null, (Object) null); - logger.debug((String) null, (Object) null, (Object) null, (Object) source()); - logger.debug((String) null, (Object) null, (Object) source(), (Object) null); - logger.debug((String) null, (Object) source(), (Object) null, (Object) null); - logger.debug((String) source(), (Object) null, (Object) null, (Object) null); - logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.debug((String) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.debug((String) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.debug((String) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.debug((String) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.debug((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.debug((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.debug((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.debug((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.debug((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.debug((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.debug((String) source(), (Supplier) null); - logger.debug((String) null, (Supplier) source()); - logger.debug((String) source(), (Throwable) null); - logger.debug((Supplier) source()); - logger.debug((Supplier) source(), (Throwable) null); - logger.error((CharSequence) source()); - logger.error((CharSequence) source(), (Throwable) null); - logger.error((Marker) null, (CharSequence) source()); - logger.error((Marker) null, (CharSequence) source(), null); - logger.error((Marker) null, (Message) source()); - logger.error((Marker) null, (MessageSupplier) source()); - logger.error((Marker) null, (MessageSupplier) source(), null); - logger.error((Marker) null, source()); - logger.error((Marker) null, (String) source()); - logger.error((Marker) null, (String) source(), new Object[] {}); - logger.error((Marker) null, (String) null, new Object[] {source()}); - logger.error((Marker) null, (String) null, (Object) source()); - logger.error((Marker) null, (String) source(), (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) source()); - logger.error((Marker) null, (String) null, (Object) source(), (Object) null); - logger.error((Marker) null, (String) source(), (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) source()); - logger.error((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null); - logger.error((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null); - logger.error((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((Marker) null, (String) source(), (Supplier) null); - logger.error((Marker) null, (String) null, (Supplier) source()); - logger.error((Marker) null, (String) source(), (Throwable) null); - logger.error((Marker) null, (Supplier) source()); - logger.error((Marker) null, (Supplier) source(), (Throwable) null); - logger.error((MessageSupplier) source()); - logger.error((MessageSupplier) source(), (Throwable) null); - logger.error((Message) source()); - logger.error((Message) source(), (Throwable) null); - logger.error(source()); - logger.error(source(), (Throwable) null); - logger.error((String) source()); - logger.error((String) source(), (Object[]) null); - logger.error((String) null, new Object[] {source()}); - logger.error((String) null, (Object) source()); - logger.error((String) source(), (Object) null); - logger.error((String) null, (Object) null, (Object) source()); - logger.error((String) null, (Object) source(), (Object) null); - logger.error((String) source(), (Object) null, (Object) null); - logger.error((String) null, (Object) null, (Object) null, (Object) source()); - logger.error((String) null, (Object) null, (Object) source(), (Object) null); - logger.error((String) null, (Object) source(), (Object) null, (Object) null); - logger.error((String) source(), (Object) null, (Object) null, (Object) null); - logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.error((String) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.error((String) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.error((String) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.error((String) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.error((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.error((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.error((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.error((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.error((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.error((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.error((String) source(), (Supplier) null); - logger.error((String) null, (Supplier) source()); - logger.error((String) source(), (Throwable) null); - logger.error((Supplier) source()); - logger.error((Supplier) source(), (Throwable) null); - logger.fatal((CharSequence) source()); - logger.fatal((CharSequence) source(), (Throwable) null); - logger.fatal((Marker) null, (CharSequence) source()); - logger.fatal((Marker) null, (CharSequence) source(), null); - logger.fatal((Marker) null, (Message) source()); - logger.fatal((Marker) null, (MessageSupplier) source()); - logger.fatal((Marker) null, (MessageSupplier) source(), null); - logger.fatal((Marker) null, source()); - logger.fatal((Marker) null, (String) source()); - logger.fatal((Marker) null, (String) source(), new Object[] {}); - logger.fatal((Marker) null, (String) null, new Object[] {source()}); - logger.fatal((Marker) null, (String) null, (Object) source()); - logger.fatal((Marker) null, (String) source(), (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) source()); - logger.fatal((Marker) null, (String) null, (Object) source(), (Object) null); - logger.fatal((Marker) null, (String) source(), (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) source()); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null); - logger.fatal((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null); - logger.fatal((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((Marker) null, (String) source(), (Supplier) null); - logger.fatal((Marker) null, (String) null, (Supplier) source()); - logger.fatal((Marker) null, (String) source(), (Throwable) null); - logger.fatal((Marker) null, (Supplier) source()); - logger.fatal((Marker) null, (Supplier) source(), (Throwable) null); - logger.fatal((MessageSupplier) source()); - logger.fatal((MessageSupplier) source(), (Throwable) null); - logger.fatal((Message) source()); - logger.fatal((Message) source(), (Throwable) null); - logger.fatal(source()); - logger.fatal(source(), (Throwable) null); - logger.fatal((String) source()); - logger.fatal((String) source(), (Object[]) null); - logger.fatal((String) null, new Object[] {source()}); - logger.fatal((String) null, (Object) source()); - logger.fatal((String) source(), (Object) null); - logger.fatal((String) null, (Object) null, (Object) source()); - logger.fatal((String) null, (Object) source(), (Object) null); - logger.fatal((String) source(), (Object) null, (Object) null); - logger.fatal((String) null, (Object) null, (Object) null, (Object) source()); - logger.fatal((String) null, (Object) null, (Object) source(), (Object) null); - logger.fatal((String) null, (Object) source(), (Object) null, (Object) null); - logger.fatal((String) source(), (Object) null, (Object) null, (Object) null); - logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.fatal((String) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.fatal((String) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.fatal((String) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.fatal((String) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.fatal((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.fatal((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.fatal((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.fatal((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.fatal((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.fatal((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.fatal((String) source(), (Supplier) null); - logger.fatal((String) null, (Supplier) source()); - logger.fatal((String) source(), (Throwable) null); - logger.fatal((Supplier) source()); - logger.fatal((Supplier) source(), (Throwable) null); - logger.info((CharSequence) source()); - logger.info((CharSequence) source(), (Throwable) null); - logger.info((Marker) null, (CharSequence) source()); - logger.info((Marker) null, (CharSequence) source(), null); - logger.info((Marker) null, (Message) source()); - logger.info((Marker) null, (MessageSupplier) source()); - logger.info((Marker) null, (MessageSupplier) source(), null); - logger.info((Marker) null, source()); - logger.info((Marker) null, (String) source()); - logger.info((Marker) null, (String) source(), new Object[] {}); - logger.info((Marker) null, (String) null, new Object[] {source()}); - logger.info((Marker) null, (String) null, (Object) source()); - logger.info((Marker) null, (String) source(), (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) source()); - logger.info((Marker) null, (String) null, (Object) source(), (Object) null); - logger.info((Marker) null, (String) source(), (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) source()); - logger.info((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null); - logger.info((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null); - logger.info((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((Marker) null, (String) source(), (Supplier) null); - logger.info((Marker) null, (String) null, (Supplier) source()); - logger.info((Marker) null, (String) source(), (Throwable) null); - logger.info((Marker) null, (Supplier) source()); - logger.info((Marker) null, (Supplier) source(), (Throwable) null); - logger.info((MessageSupplier) source()); - logger.info((MessageSupplier) source(), (Throwable) null); - logger.info((Message) source()); - logger.info((Message) source(), (Throwable) null); - logger.info(source()); - logger.info(source(), (Throwable) null); - logger.info((String) source()); - logger.info((String) source(), (Object[]) null); - logger.info((String) null, new Object[] {source()}); - logger.info((String) null, (Object) source()); - logger.info((String) source(), (Object) null); - logger.info((String) null, (Object) null, (Object) source()); - logger.info((String) null, (Object) source(), (Object) null); - logger.info((String) source(), (Object) null, (Object) null); - logger.info((String) null, (Object) null, (Object) null, (Object) source()); - logger.info((String) null, (Object) null, (Object) source(), (Object) null); - logger.info((String) null, (Object) source(), (Object) null, (Object) null); - logger.info((String) source(), (Object) null, (Object) null, (Object) null); - logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.info((String) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.info((String) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.info((String) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.info((String) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.info((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.info((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.info((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.info((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.info((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.info((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.info((String) source(), (Supplier) null); - logger.info((String) null, (Supplier) source()); - logger.info((String) source(), (Throwable) null); - logger.info((Supplier) source()); - logger.info((Supplier) source(), (Throwable) null); - logger.log((Level) null, (CharSequence) source()); - logger.log((Level) null, (CharSequence) source(), (Throwable) null); - logger.log((Level) null, (Marker) null, (CharSequence) source()); - logger.log((Level) null, (Marker) null, (CharSequence) source(), null); - logger.log((Level) null, (Marker) null, (Message) source()); - logger.log((Level) null, (Marker) null, (MessageSupplier) source()); - logger.log((Level) null, (Marker) null, (MessageSupplier) source(), null); - logger.log((Level) null, (Marker) null, source()); - logger.log((Level) null, (Marker) null, (String) source()); - logger.log((Level) null, (Marker) null, (String) source(), new Object[] {}); - logger.log((Level) null, (Marker) null, (String) null, new Object[] {source()}); - logger.log((Level) null, (Marker) null, (String) null, (Object) source()); - logger.log((Level) null, (Marker) null, (String) source(), (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) source()); - logger.log((Level) null, (Marker) null, (String) null, (Object) source(), (Object) null); - logger.log((Level) null, (Marker) null, (String) source(), (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) source()); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) source(), (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) source(), (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) source(), (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (Marker) null, (String) source(), (Supplier) null); - logger.log((Level) null, (Marker) null, (String) null, (Supplier) source()); - logger.log((Level) null, (Marker) null, (String) source(), (Throwable) null); - logger.log((Level) null, (Marker) null, (Supplier) source()); - logger.log((Level) null, (Marker) null, (Supplier) source(), (Throwable) null); - logger.log((Level) null, (MessageSupplier) source()); - logger.log((Level) null, (MessageSupplier) source(), (Throwable) null); - logger.log((Level) null, (Message) source()); - logger.log((Level) null, (Message) source(), (Throwable) null); - logger.log((Level) null, source()); - logger.log((Level) null, source(), (Throwable) null); - logger.log((Level) null, (String) source()); - logger.log((Level) null, (String) source(), (Object[]) null); - logger.log((Level) null, (String) null, new Object[] {source()}); - logger.log((Level) null, (String) null, (Object) source()); - logger.log((Level) null, (String) source(), (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) source()); - logger.log((Level) null, (String) null, (Object) source(), (Object) null); - logger.log((Level) null, (String) source(), (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) source()); - logger.log((Level) null, (String) null, (Object) null, (Object) source(), (Object) null); - logger.log((Level) null, (String) null, (Object) source(), (Object) null, (Object) null); - logger.log((Level) null, (String) source(), (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.log((Level) null, (String) source(), (Supplier) null); - logger.log((Level) null, (String) null, (Supplier) source()); - logger.log((Level) null, (String) source(), (Throwable) null); - logger.log((Level) null, (Supplier) source()); - logger.log((Level) null, (Supplier) source(), (Throwable) null); - logger.trace((CharSequence) source()); - logger.trace((CharSequence) source(), (Throwable) null); - logger.trace((Marker) null, (CharSequence) source()); - logger.trace((Marker) null, (CharSequence) source(), null); - logger.trace((Marker) null, (Message) source()); - logger.trace((Marker) null, (MessageSupplier) source()); - logger.trace((Marker) null, (MessageSupplier) source(), null); - logger.trace((Marker) null, source()); - logger.trace((Marker) null, (String) source()); - logger.trace((Marker) null, (String) source(), new Object[] {}); - logger.trace((Marker) null, (String) null, new Object[] {source()}); - logger.trace((Marker) null, (String) null, (Object) source()); - logger.trace((Marker) null, (String) source(), (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) source()); - logger.trace((Marker) null, (String) null, (Object) source(), (Object) null); - logger.trace((Marker) null, (String) source(), (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) source()); - logger.trace((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null); - logger.trace((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null); - logger.trace((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((Marker) null, (String) source(), (Supplier) null); - logger.trace((Marker) null, (String) null, (Supplier) source()); - logger.trace((Marker) null, (String) source(), (Throwable) null); - logger.trace((Marker) null, (Supplier) source()); - logger.trace((Marker) null, (Supplier) source(), (Throwable) null); - logger.trace((MessageSupplier) source()); - logger.trace((MessageSupplier) source(), (Throwable) null); - logger.trace((Message) source()); - logger.trace((Message) source(), (Throwable) null); - logger.trace(source()); - logger.trace(source(), (Throwable) null); - logger.trace((String) source()); - logger.trace((String) source(), (Object[]) null); - logger.trace((String) null, new Object[] {source()}); - logger.trace((String) null, (Object) source()); - logger.trace((String) source(), (Object) null); - logger.trace((String) null, (Object) null, (Object) source()); - logger.trace((String) null, (Object) source(), (Object) null); - logger.trace((String) source(), (Object) null, (Object) null); - logger.trace((String) null, (Object) null, (Object) null, (Object) source()); - logger.trace((String) null, (Object) null, (Object) source(), (Object) null); - logger.trace((String) null, (Object) source(), (Object) null, (Object) null); - logger.trace((String) source(), (Object) null, (Object) null, (Object) null); - logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.trace((String) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.trace((String) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.trace((String) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.trace((String) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.trace((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.trace((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.trace((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.trace((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.trace((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.trace((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.trace((String) source(), (Supplier) null); - logger.trace((String) null, (Supplier) source()); - logger.trace((String) source(), (Throwable) null); - logger.trace((Supplier) source()); - logger.trace((Supplier) source(), (Throwable) null); - logger.warn((CharSequence) source()); - logger.warn((CharSequence) source(), (Throwable) null); - logger.warn((Marker) null, (CharSequence) source()); - logger.warn((Marker) null, (CharSequence) source(), null); - logger.warn((Marker) null, (Message) source()); - logger.warn((Marker) null, (MessageSupplier) source()); - logger.warn((Marker) null, (MessageSupplier) source(), null); - logger.warn((Marker) null, source()); - logger.warn((Marker) null, (String) source()); - logger.warn((Marker) null, (String) source(), new Object[] {}); - logger.warn((Marker) null, (String) null, new Object[] {source()}); - logger.warn((Marker) null, (String) null, (Object) source()); - logger.warn((Marker) null, (String) source(), (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) source()); - logger.warn((Marker) null, (String) null, (Object) source(), (Object) null); - logger.warn((Marker) null, (String) source(), (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) source()); - logger.warn((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null); - logger.warn((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null); - logger.warn((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((Marker) null, (String) source(), (Supplier) null); - logger.warn((Marker) null, (String) null, (Supplier) source()); - logger.warn((Marker) null, (String) source(), (Throwable) null); - logger.warn((Marker) null, (Supplier) source()); - logger.warn((Marker) null, (Supplier) source(), (Throwable) null); - logger.warn((MessageSupplier) source()); - logger.warn((MessageSupplier) source(), (Throwable) null); - logger.warn((Message) source()); - logger.warn((Message) source(), (Throwable) null); - logger.warn(source()); - logger.warn(source(), (Throwable) null); - logger.warn((String) source()); - logger.warn((String) source(), (Object[]) null); - logger.warn((String) null, new Object[] {source()}); - logger.warn((String) null, (Object) source()); - logger.warn((String) source(), (Object) null); - logger.warn((String) null, (Object) null, (Object) source()); - logger.warn((String) null, (Object) source(), (Object) null); - logger.warn((String) source(), (Object) null, (Object) null); - logger.warn((String) null, (Object) null, (Object) null, (Object) source()); - logger.warn((String) null, (Object) null, (Object) source(), (Object) null); - logger.warn((String) null, (Object) source(), (Object) null, (Object) null); - logger.warn((String) source(), (Object) null, (Object) null, (Object) null); - logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.warn((String) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.warn((String) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.warn((String) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.warn((String) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.warn((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.warn((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.warn((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.warn((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.warn((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.warn((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - logger.warn((String) source(), (Supplier) null); - logger.warn((String) null, (Supplier) source()); - logger.warn((String) source(), (Throwable) null); - logger.warn((Supplier) source()); - logger.warn((Supplier) source(), (Throwable) null); + logger.debug((CharSequence) source()); // $ Alert + logger.debug((CharSequence) source(), (Throwable) null); // $ Alert + logger.debug((Marker) null, (CharSequence) source()); // $ Alert + logger.debug((Marker) null, (CharSequence) source(), null); // $ Alert + logger.debug((Marker) null, (Message) source()); // $ Alert + logger.debug((Marker) null, (MessageSupplier) source()); // $ Alert + logger.debug((Marker) null, (MessageSupplier) source(), null); // $ Alert + logger.debug((Marker) null, source()); // $ Alert + logger.debug((Marker) null, (String) source()); // $ Alert + logger.debug((Marker) null, (String) source(), new Object[] {}); // $ Alert + logger.debug((Marker) null, (String) null, new Object[] {source()}); // $ Alert + logger.debug((Marker) null, (String) null, (Object) source()); // $ Alert + logger.debug((Marker) null, (String) source(), (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) source()); // $ Alert + logger.debug((Marker) null, (String) null, (Object) source(), (Object) null); // $ Alert + logger.debug((Marker) null, (String) source(), (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((Marker) null, (String) source(), (Supplier) null); // $ Alert + logger.debug((Marker) null, (String) null, (Supplier) source()); // $ Alert + logger.debug((Marker) null, (String) source(), (Throwable) null); // $ Alert + logger.debug((Marker) null, (Supplier) source()); // $ Alert + logger.debug((Marker) null, (Supplier) source(), (Throwable) null); // $ Alert + logger.debug((MessageSupplier) source()); // $ Alert + logger.debug((MessageSupplier) source(), (Throwable) null); // $ Alert + logger.debug((Message) source()); // $ Alert + logger.debug((Message) source(), (Throwable) null); // $ Alert + logger.debug(source()); // $ Alert + logger.debug(source(), (Throwable) null); // $ Alert + logger.debug((String) source()); // $ Alert + logger.debug((String) source(), (Object[]) null); // $ Alert + logger.debug((String) null, new Object[] {source()}); // $ Alert + logger.debug((String) null, (Object) source()); // $ Alert + logger.debug((String) source(), (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) source()); // $ Alert + logger.debug((String) null, (Object) source(), (Object) null); // $ Alert + logger.debug((String) source(), (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.debug((String) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.debug((String) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.debug((String) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.debug((String) source(), (Supplier) null); // $ Alert + logger.debug((String) null, (Supplier) source()); // $ Alert + logger.debug((String) source(), (Throwable) null); // $ Alert + logger.debug((Supplier) source()); // $ Alert + logger.debug((Supplier) source(), (Throwable) null); // $ Alert + logger.error((CharSequence) source()); // $ Alert + logger.error((CharSequence) source(), (Throwable) null); // $ Alert + logger.error((Marker) null, (CharSequence) source()); // $ Alert + logger.error((Marker) null, (CharSequence) source(), null); // $ Alert + logger.error((Marker) null, (Message) source()); // $ Alert + logger.error((Marker) null, (MessageSupplier) source()); // $ Alert + logger.error((Marker) null, (MessageSupplier) source(), null); // $ Alert + logger.error((Marker) null, source()); // $ Alert + logger.error((Marker) null, (String) source()); // $ Alert + logger.error((Marker) null, (String) source(), new Object[] {}); // $ Alert + logger.error((Marker) null, (String) null, new Object[] {source()}); // $ Alert + logger.error((Marker) null, (String) null, (Object) source()); // $ Alert + logger.error((Marker) null, (String) source(), (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) source()); // $ Alert + logger.error((Marker) null, (String) null, (Object) source(), (Object) null); // $ Alert + logger.error((Marker) null, (String) source(), (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((Marker) null, (String) source(), (Supplier) null); // $ Alert + logger.error((Marker) null, (String) null, (Supplier) source()); // $ Alert + logger.error((Marker) null, (String) source(), (Throwable) null); // $ Alert + logger.error((Marker) null, (Supplier) source()); // $ Alert + logger.error((Marker) null, (Supplier) source(), (Throwable) null); // $ Alert + logger.error((MessageSupplier) source()); // $ Alert + logger.error((MessageSupplier) source(), (Throwable) null); // $ Alert + logger.error((Message) source()); // $ Alert + logger.error((Message) source(), (Throwable) null); // $ Alert + logger.error(source()); // $ Alert + logger.error(source(), (Throwable) null); // $ Alert + logger.error((String) source()); // $ Alert + logger.error((String) source(), (Object[]) null); // $ Alert + logger.error((String) null, new Object[] {source()}); // $ Alert + logger.error((String) null, (Object) source()); // $ Alert + logger.error((String) source(), (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) source()); // $ Alert + logger.error((String) null, (Object) source(), (Object) null); // $ Alert + logger.error((String) source(), (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.error((String) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.error((String) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.error((String) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.error((String) source(), (Supplier) null); // $ Alert + logger.error((String) null, (Supplier) source()); // $ Alert + logger.error((String) source(), (Throwable) null); // $ Alert + logger.error((Supplier) source()); // $ Alert + logger.error((Supplier) source(), (Throwable) null); // $ Alert + logger.fatal((CharSequence) source()); // $ Alert + logger.fatal((CharSequence) source(), (Throwable) null); // $ Alert + logger.fatal((Marker) null, (CharSequence) source()); // $ Alert + logger.fatal((Marker) null, (CharSequence) source(), null); // $ Alert + logger.fatal((Marker) null, (Message) source()); // $ Alert + logger.fatal((Marker) null, (MessageSupplier) source()); // $ Alert + logger.fatal((Marker) null, (MessageSupplier) source(), null); // $ Alert + logger.fatal((Marker) null, source()); // $ Alert + logger.fatal((Marker) null, (String) source()); // $ Alert + logger.fatal((Marker) null, (String) source(), new Object[] {}); // $ Alert + logger.fatal((Marker) null, (String) null, new Object[] {source()}); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) source()); // $ Alert + logger.fatal((Marker) null, (String) source(), (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) source()); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) source(), (Object) null); // $ Alert + logger.fatal((Marker) null, (String) source(), (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((Marker) null, (String) source(), (Supplier) null); // $ Alert + logger.fatal((Marker) null, (String) null, (Supplier) source()); // $ Alert + logger.fatal((Marker) null, (String) source(), (Throwable) null); // $ Alert + logger.fatal((Marker) null, (Supplier) source()); // $ Alert + logger.fatal((Marker) null, (Supplier) source(), (Throwable) null); // $ Alert + logger.fatal((MessageSupplier) source()); // $ Alert + logger.fatal((MessageSupplier) source(), (Throwable) null); // $ Alert + logger.fatal((Message) source()); // $ Alert + logger.fatal((Message) source(), (Throwable) null); // $ Alert + logger.fatal(source()); // $ Alert + logger.fatal(source(), (Throwable) null); // $ Alert + logger.fatal((String) source()); // $ Alert + logger.fatal((String) source(), (Object[]) null); // $ Alert + logger.fatal((String) null, new Object[] {source()}); // $ Alert + logger.fatal((String) null, (Object) source()); // $ Alert + logger.fatal((String) source(), (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) source()); // $ Alert + logger.fatal((String) null, (Object) source(), (Object) null); // $ Alert + logger.fatal((String) source(), (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.fatal((String) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.fatal((String) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.fatal((String) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.fatal((String) source(), (Supplier) null); // $ Alert + logger.fatal((String) null, (Supplier) source()); // $ Alert + logger.fatal((String) source(), (Throwable) null); // $ Alert + logger.fatal((Supplier) source()); // $ Alert + logger.fatal((Supplier) source(), (Throwable) null); // $ Alert + logger.info((CharSequence) source()); // $ Alert + logger.info((CharSequence) source(), (Throwable) null); // $ Alert + logger.info((Marker) null, (CharSequence) source()); // $ Alert + logger.info((Marker) null, (CharSequence) source(), null); // $ Alert + logger.info((Marker) null, (Message) source()); // $ Alert + logger.info((Marker) null, (MessageSupplier) source()); // $ Alert + logger.info((Marker) null, (MessageSupplier) source(), null); // $ Alert + logger.info((Marker) null, source()); // $ Alert + logger.info((Marker) null, (String) source()); // $ Alert + logger.info((Marker) null, (String) source(), new Object[] {}); // $ Alert + logger.info((Marker) null, (String) null, new Object[] {source()}); // $ Alert + logger.info((Marker) null, (String) null, (Object) source()); // $ Alert + logger.info((Marker) null, (String) source(), (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) source()); // $ Alert + logger.info((Marker) null, (String) null, (Object) source(), (Object) null); // $ Alert + logger.info((Marker) null, (String) source(), (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((Marker) null, (String) source(), (Supplier) null); // $ Alert + logger.info((Marker) null, (String) null, (Supplier) source()); // $ Alert + logger.info((Marker) null, (String) source(), (Throwable) null); // $ Alert + logger.info((Marker) null, (Supplier) source()); // $ Alert + logger.info((Marker) null, (Supplier) source(), (Throwable) null); // $ Alert + logger.info((MessageSupplier) source()); // $ Alert + logger.info((MessageSupplier) source(), (Throwable) null); // $ Alert + logger.info((Message) source()); // $ Alert + logger.info((Message) source(), (Throwable) null); // $ Alert + logger.info(source()); // $ Alert + logger.info(source(), (Throwable) null); // $ Alert + logger.info((String) source()); // $ Alert + logger.info((String) source(), (Object[]) null); // $ Alert + logger.info((String) null, new Object[] {source()}); // $ Alert + logger.info((String) null, (Object) source()); // $ Alert + logger.info((String) source(), (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) source()); // $ Alert + logger.info((String) null, (Object) source(), (Object) null); // $ Alert + logger.info((String) source(), (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.info((String) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.info((String) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.info((String) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.info((String) source(), (Supplier) null); // $ Alert + logger.info((String) null, (Supplier) source()); // $ Alert + logger.info((String) source(), (Throwable) null); // $ Alert + logger.info((Supplier) source()); // $ Alert + logger.info((Supplier) source(), (Throwable) null); // $ Alert + logger.log((Level) null, (CharSequence) source()); // $ Alert + logger.log((Level) null, (CharSequence) source(), (Throwable) null); // $ Alert + logger.log((Level) null, (Marker) null, (CharSequence) source()); // $ Alert + logger.log((Level) null, (Marker) null, (CharSequence) source(), null); // $ Alert + logger.log((Level) null, (Marker) null, (Message) source()); // $ Alert + logger.log((Level) null, (Marker) null, (MessageSupplier) source()); // $ Alert + logger.log((Level) null, (Marker) null, (MessageSupplier) source(), null); // $ Alert + logger.log((Level) null, (Marker) null, source()); // $ Alert + logger.log((Level) null, (Marker) null, (String) source()); // $ Alert + logger.log((Level) null, (Marker) null, (String) source(), new Object[] {}); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, new Object[] {source()}); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) source()); // $ Alert + logger.log((Level) null, (Marker) null, (String) source(), (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) source()); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) source(), (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) source(), (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) source(), (Supplier) null); // $ Alert + logger.log((Level) null, (Marker) null, (String) null, (Supplier) source()); // $ Alert + logger.log((Level) null, (Marker) null, (String) source(), (Throwable) null); // $ Alert + logger.log((Level) null, (Marker) null, (Supplier) source()); // $ Alert + logger.log((Level) null, (Marker) null, (Supplier) source(), (Throwable) null); // $ Alert + logger.log((Level) null, (MessageSupplier) source()); // $ Alert + logger.log((Level) null, (MessageSupplier) source(), (Throwable) null); // $ Alert + logger.log((Level) null, (Message) source()); // $ Alert + logger.log((Level) null, (Message) source(), (Throwable) null); // $ Alert + logger.log((Level) null, source()); // $ Alert + logger.log((Level) null, source(), (Throwable) null); // $ Alert + logger.log((Level) null, (String) source()); // $ Alert + logger.log((Level) null, (String) source(), (Object[]) null); // $ Alert + logger.log((Level) null, (String) null, new Object[] {source()}); // $ Alert + logger.log((Level) null, (String) null, (Object) source()); // $ Alert + logger.log((Level) null, (String) source(), (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) source()); // $ Alert + logger.log((Level) null, (String) null, (Object) source(), (Object) null); // $ Alert + logger.log((Level) null, (String) source(), (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.log((Level) null, (String) source(), (Supplier) null); // $ Alert + logger.log((Level) null, (String) null, (Supplier) source()); // $ Alert + logger.log((Level) null, (String) source(), (Throwable) null); // $ Alert + logger.log((Level) null, (Supplier) source()); // $ Alert + logger.log((Level) null, (Supplier) source(), (Throwable) null); // $ Alert + logger.trace((CharSequence) source()); // $ Alert + logger.trace((CharSequence) source(), (Throwable) null); // $ Alert + logger.trace((Marker) null, (CharSequence) source()); // $ Alert + logger.trace((Marker) null, (CharSequence) source(), null); // $ Alert + logger.trace((Marker) null, (Message) source()); // $ Alert + logger.trace((Marker) null, (MessageSupplier) source()); // $ Alert + logger.trace((Marker) null, (MessageSupplier) source(), null); // $ Alert + logger.trace((Marker) null, source()); // $ Alert + logger.trace((Marker) null, (String) source()); // $ Alert + logger.trace((Marker) null, (String) source(), new Object[] {}); // $ Alert + logger.trace((Marker) null, (String) null, new Object[] {source()}); // $ Alert + logger.trace((Marker) null, (String) null, (Object) source()); // $ Alert + logger.trace((Marker) null, (String) source(), (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) source()); // $ Alert + logger.trace((Marker) null, (String) null, (Object) source(), (Object) null); // $ Alert + logger.trace((Marker) null, (String) source(), (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((Marker) null, (String) source(), (Supplier) null); // $ Alert + logger.trace((Marker) null, (String) null, (Supplier) source()); // $ Alert + logger.trace((Marker) null, (String) source(), (Throwable) null); // $ Alert + logger.trace((Marker) null, (Supplier) source()); // $ Alert + logger.trace((Marker) null, (Supplier) source(), (Throwable) null); // $ Alert + logger.trace((MessageSupplier) source()); // $ Alert + logger.trace((MessageSupplier) source(), (Throwable) null); // $ Alert + logger.trace((Message) source()); // $ Alert + logger.trace((Message) source(), (Throwable) null); // $ Alert + logger.trace(source()); // $ Alert + logger.trace(source(), (Throwable) null); // $ Alert + logger.trace((String) source()); // $ Alert + logger.trace((String) source(), (Object[]) null); // $ Alert + logger.trace((String) null, new Object[] {source()}); // $ Alert + logger.trace((String) null, (Object) source()); // $ Alert + logger.trace((String) source(), (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) source()); // $ Alert + logger.trace((String) null, (Object) source(), (Object) null); // $ Alert + logger.trace((String) source(), (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.trace((String) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.trace((String) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.trace((String) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.trace((String) source(), (Supplier) null); // $ Alert + logger.trace((String) null, (Supplier) source()); // $ Alert + logger.trace((String) source(), (Throwable) null); // $ Alert + logger.trace((Supplier) source()); // $ Alert + logger.trace((Supplier) source(), (Throwable) null); // $ Alert + logger.warn((CharSequence) source()); // $ Alert + logger.warn((CharSequence) source(), (Throwable) null); // $ Alert + logger.warn((Marker) null, (CharSequence) source()); // $ Alert + logger.warn((Marker) null, (CharSequence) source(), null); // $ Alert + logger.warn((Marker) null, (Message) source()); // $ Alert + logger.warn((Marker) null, (MessageSupplier) source()); // $ Alert + logger.warn((Marker) null, (MessageSupplier) source(), null); // $ Alert + logger.warn((Marker) null, source()); // $ Alert + logger.warn((Marker) null, (String) source()); // $ Alert + logger.warn((Marker) null, (String) source(), new Object[] {}); // $ Alert + logger.warn((Marker) null, (String) null, new Object[] {source()}); // $ Alert + logger.warn((Marker) null, (String) null, (Object) source()); // $ Alert + logger.warn((Marker) null, (String) source(), (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) source()); // $ Alert + logger.warn((Marker) null, (String) null, (Object) source(), (Object) null); // $ Alert + logger.warn((Marker) null, (String) source(), (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((Marker) null, (String) source(), (Supplier) null); // $ Alert + logger.warn((Marker) null, (String) null, (Supplier) source()); // $ Alert + logger.warn((Marker) null, (String) source(), (Throwable) null); // $ Alert + logger.warn((Marker) null, (Supplier) source()); // $ Alert + logger.warn((Marker) null, (Supplier) source(), (Throwable) null); // $ Alert + logger.warn((MessageSupplier) source()); // $ Alert + logger.warn((MessageSupplier) source(), (Throwable) null); // $ Alert + logger.warn((Message) source()); // $ Alert + logger.warn((Message) source(), (Throwable) null); // $ Alert + logger.warn(source()); // $ Alert + logger.warn(source(), (Throwable) null); // $ Alert + logger.warn((String) source()); // $ Alert + logger.warn((String) source(), (Object[]) null); // $ Alert + logger.warn((String) null, new Object[] {source()}); // $ Alert + logger.warn((String) null, (Object) source()); // $ Alert + logger.warn((String) source(), (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) source()); // $ Alert + logger.warn((String) null, (Object) source(), (Object) null); // $ Alert + logger.warn((String) source(), (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.warn((String) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.warn((String) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.warn((String) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + logger.warn((String) source(), (Supplier) null); // $ Alert + logger.warn((String) null, (Supplier) source()); // $ Alert + logger.warn((String) source(), (Throwable) null); // $ Alert + logger.warn((Supplier) source()); // $ Alert + logger.warn((Supplier) source(), (Throwable) null); // $ Alert // @formatter:on - logger.logMessage(null, null, null, null, (Message) source(), null); - logger.printf(null, null, (String) source(), (Object[]) null); - logger.printf(null, null, null, new Object[] {source()}); - logger.printf(null, (String) source(), (Object[]) null); - logger.printf(null, null, new Object[] {source()}); + logger.logMessage(null, null, null, null, (Message) source(), null); // $ Alert + logger.printf(null, null, (String) source(), (Object[]) null); // $ Alert + logger.printf(null, null, null, new Object[] {source()}); // $ Alert + logger.printf(null, (String) source(), (Object[]) null); // $ Alert + logger.printf(null, null, new Object[] {source()}); // $ Alert logger.traceEntry((Message) source()); logger.traceEntry((String) source(), (Object[]) null); logger.traceEntry((String) null, new Object[] {source()}); @@ -1017,109 +1017,109 @@ public class Log4jJndiInjectionTest { } { LogBuilder builder = null; - builder.log((CharSequence) source()); - builder.log((Message) source()); - builder.log(source()); - builder.log((String) source()); - builder.log((String) source(), (Object[]) null); - builder.log((String) null, new Object[] {source()}); - builder.log((String) null, source()); + builder.log((CharSequence) source()); // $ Alert + builder.log((Message) source()); // $ Alert + builder.log(source()); // $ Alert + builder.log((String) source()); // $ Alert + builder.log((String) source(), (Object[]) null); // $ Alert + builder.log((String) null, new Object[] {source()}); // $ Alert + builder.log((String) null, source()); // $ Alert // @formatter:off - builder.log((String) null, (Object) source()); - builder.log((String) source(), (Object) null); - builder.log((String) null, (Object) null, (Object) source()); - builder.log((String) null, (Object) source(), (Object) null); - builder.log((String) source(), (Object) null, (Object) null); - builder.log((String) null, (Object) null, (Object) null, (Object) source()); - builder.log((String) null, (Object) null, (Object) source(), (Object) null); - builder.log((String) null, (Object) source(), (Object) null, (Object) null); - builder.log((String) source(), (Object) null, (Object) null, (Object) null); - builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) source()); - builder.log((String) null, (Object) null, (Object) null, (Object) source(), (Object) null); - builder.log((String) null, (Object) null, (Object) source(), (Object) null, (Object) null); - builder.log((String) null, (Object) source(), (Object) null, (Object) null, (Object) null); - builder.log((String) source(), (Object) null, (Object) null, (Object) null, (Object) null); - builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - builder.log((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - builder.log((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - builder.log((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - builder.log((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - builder.log((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - builder.log((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - builder.log((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - builder.log((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - builder.log((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - builder.log((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - builder.log((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - builder.log((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - builder.log((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - builder.log((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - builder.log((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - builder.log((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); - builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); - builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); - builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); - builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); - builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - builder.log((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - builder.log((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - builder.log((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); - builder.log((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); + builder.log((String) null, (Object) source()); // $ Alert + builder.log((String) source(), (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) source()); // $ Alert + builder.log((String) null, (Object) source(), (Object) null); // $ Alert + builder.log((String) source(), (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) source()); // $ Alert + builder.log((String) null, (Object) null, (Object) source(), (Object) null); // $ Alert + builder.log((String) null, (Object) source(), (Object) null, (Object) null); // $ Alert + builder.log((String) source(), (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source()); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) null, (Object) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert + builder.log((String) source(), (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null, (Object) null); // $ Alert // @formatter:on - builder.log((String) source(), (Supplier) null); - builder.log((String) null, (Supplier) source()); - builder.log((Supplier) source()); + builder.log((String) source(), (Supplier) null); // $ Alert + builder.log((String) null, (Supplier) source()); // $ Alert + builder.log((Supplier) source()); // $ Alert } { - ThreadContext.put("key", (String) source()); - ThreadContext.putIfNull("key", (String) source()); + ThreadContext.put("key", (String) source()); // $ Alert + ThreadContext.putIfNull("key", (String) source()); // $ Alert Map map = new HashMap(); map.put("key", (String) source()); - ThreadContext.putAll(map); + ThreadContext.putAll(map); // $ Alert } { MapMessage mmsg = new StringMapMessage().with("username", (String) source()); - logger.error(mmsg); + logger.error(mmsg); // $ Alert } { MapMessage mmsg = new StringMapMessage(); mmsg.with("username", (String) source()); - logger.error(mmsg); + logger.error(mmsg); // $ Alert } { MapMessage mmsg = new StringMapMessage(); mmsg.put("username", (String) source()); - logger.error(mmsg); + logger.error(mmsg); // $ Alert } { MapMessage mmsg = new StringMapMessage(); Map map = new HashMap(); map.put("username", (String) source()); mmsg.putAll(map); - logger.error(mmsg); + logger.error(mmsg); // $ Alert } { - CloseableThreadContext.put("username", (String) source()); - CloseableThreadContext.put("safe", "safe").put("username", (String) source()); + CloseableThreadContext.put("username", (String) source()); // $ Alert + CloseableThreadContext.put("safe", "safe").put("username", (String) source()); // $ Alert Map map = new HashMap(); map.put("username", (String) source()); - CloseableThreadContext.putAll(map); - CloseableThreadContext.put("safe", "safe").putAll(map); + CloseableThreadContext.putAll(map); // $ Alert + CloseableThreadContext.put("safe", "safe").putAll(map); // $ Alert } } -} \ No newline at end of file +} diff --git a/java/ql/test/experimental/query-tests/security/CWE-073/FilePathInjection.java b/java/ql/test/experimental/query-tests/security/CWE-073/FilePathInjection.java index 2534386a210..6080167987c 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-073/FilePathInjection.java +++ b/java/ql/test/experimental/query-tests/security/CWE-073/FilePathInjection.java @@ -18,12 +18,12 @@ public class FilePathInjection extends Controller { // BAD: Upload file to user specified path without validation public void uploadFile() throws IOException { - String savePath = getPara("dir"); + String savePath = getPara("dir"); // $ Source File file = getFile("fileParam").getFile(); String finalFilePath = BASE_PATH + savePath; FileInputStream fis = new FileInputStream(file); - FileOutputStream fos = new FileOutputStream(finalFilePath); + FileOutputStream fos = new FileOutputStream(finalFilePath); // $ Alert int i = 0; do { @@ -61,7 +61,7 @@ public class FilePathInjection extends Controller { // BAD: Upload file to user specified path without validation through session attribute public void uploadFile3() throws IOException { - String savePath = getPara("dir"); + String savePath = getPara("dir"); // $ Source setSessionAttr("uploadDir", savePath); String sessionUploadDir = getSessionAttr("uploadDir"); @@ -69,7 +69,7 @@ public class FilePathInjection extends Controller { String finalFilePath = BASE_PATH + sessionUploadDir; FileInputStream fis = new FileInputStream(file); - FileOutputStream fos = new FileOutputStream(finalFilePath); + FileOutputStream fos = new FileOutputStream(finalFilePath); // $ Alert int i = 0; do { @@ -84,7 +84,7 @@ public class FilePathInjection extends Controller { // BAD: Upload file to user specified path without validation through request attribute public void uploadFile4() throws IOException { - String savePath = getPara("dir"); + String savePath = getPara("dir"); // $ Source setAttr("uploadDir2", savePath); String requestUploadDir = getAttr("uploadDir2"); @@ -92,7 +92,7 @@ public class FilePathInjection extends Controller { String finalFilePath = BASE_PATH + requestUploadDir; FileInputStream fis = new FileInputStream(file); - FileOutputStream fos = new FileOutputStream(finalFilePath); + FileOutputStream fos = new FileOutputStream(finalFilePath); // $ Alert int i = 0; do { @@ -179,7 +179,7 @@ public class FilePathInjection extends Controller { FileInputStream fis = null; try { os = resp.getOutputStream(); - fis = new FileInputStream(file); + fis = new FileInputStream(file); // $ Alert byte fileContent[] = new byte[(int) file.length()]; fis.read(fileContent); os.write(fileContent); @@ -202,12 +202,12 @@ public class FilePathInjection extends Controller { // BAD: Download file to user specified path without validation public void downloadFile() throws FileNotFoundException, IOException { HttpServletRequest request = getRequest(); - String path = request.getParameter("path"); + String path = request.getParameter("path"); // $ Source String filePath = BASE_PATH + path; HttpServletResponse resp = getResponse(); File file = new File(filePath); - if (path != null && file.exists()) { + if (path != null && file.exists()) { // $ Alert resp.setHeader("Content-type", "application/force-download"); resp.setHeader("Content-Disposition", "inline;filename=\"" + filePath + "\""); resp.setHeader("Content-Transfer-Encoding", "Binary"); diff --git a/java/ql/test/experimental/query-tests/security/CWE-073/FilePathInjection.qlref b/java/ql/test/experimental/query-tests/security/CWE-073/FilePathInjection.qlref index e0dc75098eb..c541d90b184 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-073/FilePathInjection.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-073/FilePathInjection.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-073/FilePathInjection.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-078/CommandInjectionRuntimeExecLocal.qlref b/java/ql/test/experimental/query-tests/security/CWE-078/CommandInjectionRuntimeExecLocal.qlref index 24bd62c5a2e..9916b156289 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-078/CommandInjectionRuntimeExecLocal.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-078/CommandInjectionRuntimeExecLocal.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-078/CommandInjectionRuntimeExecLocal.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-078/ExecTainted.qlref b/java/ql/test/experimental/query-tests/security/CWE-078/ExecTainted.qlref index ddd01d29539..4db90bad013 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-078/ExecTainted.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-078/ExecTainted.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-078/ExecTainted.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-078/JSchOSInjectionTest.java b/java/ql/test/experimental/query-tests/security/CWE-078/JSchOSInjectionTest.java index 7b8c5a1181c..3b21f0de7f4 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-078/JSchOSInjectionTest.java +++ b/java/ql/test/experimental/query-tests/security/CWE-078/JSchOSInjectionTest.java @@ -11,7 +11,7 @@ public class JSchOSInjectionTest extends HttpServlet { String host = "sshHost"; String user = "user"; String password = "password"; - String command = request.getParameter("command"); + String command = request.getParameter("command"); // $ Source[java/command-line-injection-experimental] java.util.Properties config = new java.util.Properties(); config.put("StrictHostKeyChecking", "no"); @@ -24,7 +24,7 @@ public class JSchOSInjectionTest extends HttpServlet { session.connect(); Channel channel = session.openChannel("exec"); - ((ChannelExec) channel).setCommand("ping " + command); + ((ChannelExec) channel).setCommand("ping " + command); // $ Alert[java/command-line-injection-experimental] channel.setInputStream(null); ((ChannelExec) channel).setErrStream(System.err); @@ -37,7 +37,7 @@ public class JSchOSInjectionTest extends HttpServlet { String host = "sshHost"; String user = "user"; String password = "password"; - String command = request.getParameter("command"); + String command = request.getParameter("command"); // $ Source[java/command-line-injection-experimental] java.util.Properties config = new java.util.Properties(); config.put("StrictHostKeyChecking", "no"); @@ -50,7 +50,7 @@ public class JSchOSInjectionTest extends HttpServlet { session.connect(); ChannelExec channel = (ChannelExec)session.openChannel("exec"); - channel.setCommand("ping " + command); + channel.setCommand("ping " + command); // $ Alert[java/command-line-injection-experimental] channel.setInputStream(null); channel.setErrStream(System.err); diff --git a/java/ql/test/experimental/query-tests/security/CWE-078/RuntimeExecTest.java b/java/ql/test/experimental/query-tests/security/CWE-078/RuntimeExecTest.java index 203c3855c87..9d1ec9d73f7 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-078/RuntimeExecTest.java +++ b/java/ql/test/experimental/query-tests/security/CWE-078/RuntimeExecTest.java @@ -14,29 +14,29 @@ public class RuntimeExecTest { public static void test() { System.out.println("Command injection test"); - String script = System.getenv("SCRIPTNAME"); + String script = System.getenv("SCRIPTNAME"); // $ Source[java/command-line-injection-extra-local] if (script != null) { try { // 1. array literal in the args - Runtime.getRuntime().exec(new String[]{"/bin/sh", script}); + Runtime.getRuntime().exec(new String[]{"/bin/sh", script}); // $ Alert[java/command-line-injection-extra-local] // 2. array literal with dataflow String[] commandArray1 = new String[]{"/bin/sh", script}; - Runtime.getRuntime().exec(commandArray1); + Runtime.getRuntime().exec(commandArray1); // $ Alert[java/command-line-injection-extra-local] // 3. array assignment after it is created String[] commandArray2 = new String[4]; commandArray2[0] = "/bin/sh"; commandArray2[1] = script; - Runtime.getRuntime().exec(commandArray2); + Runtime.getRuntime().exec(commandArray2); // $ Alert[java/command-line-injection-extra-local] // 4. Stream concatenation Runtime.getRuntime().exec( - Stream.concat( + Stream.concat( // $ Arrays.stream(new String[]{"/bin/sh"}), Arrays.stream(new String[]{script}) - ).toArray(String[]::new) + ).toArray(String[]::new) // $ Alert[java/command-line-injection-extra-local] ); } catch (Exception e) { diff --git a/java/ql/test/experimental/query-tests/security/CWE-089/src/main/MyBatisAnnotationSqlInjection.qlref b/java/ql/test/experimental/query-tests/security/CWE-089/src/main/MyBatisAnnotationSqlInjection.qlref index 44302277a79..2ed491d5df0 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-089/src/main/MyBatisAnnotationSqlInjection.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-089/src/main/MyBatisAnnotationSqlInjection.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-089/MyBatisAnnotationSqlInjection.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-089/src/main/MyBatisMapperXmlSqlInjection.qlref b/java/ql/test/experimental/query-tests/security/CWE-089/src/main/MyBatisMapperXmlSqlInjection.qlref index 19e95a85de4..404b67d5001 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-089/src/main/MyBatisMapperXmlSqlInjection.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-089/src/main/MyBatisMapperXmlSqlInjection.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-089/MyBatisMapperXmlSqlInjection.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-089/src/main/MybatisSqlInjection.java b/java/ql/test/experimental/query-tests/security/CWE-089/src/main/MybatisSqlInjection.java index 856c1d0b299..7ea49efbf9a 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-089/src/main/MybatisSqlInjection.java +++ b/java/ql/test/experimental/query-tests/security/CWE-089/src/main/MybatisSqlInjection.java @@ -16,55 +16,55 @@ public class MybatisSqlInjection { private MybatisSqlInjectionService mybatisSqlInjectionService; @GetMapping(value = "msi1") - public List bad1(@RequestParam String name) { + public List bad1(@RequestParam String name) { // $ Source[java/mybatis-xml-sql-injection] List result = mybatisSqlInjectionService.bad1(name); return result; } @GetMapping(value = "msi2") - public List bad2(@RequestParam String name) { + public List bad2(@RequestParam String name) { // $ Source[java/mybatis-xml-sql-injection] List result = mybatisSqlInjectionService.bad2(name); return result; } @GetMapping(value = "msi3") - public List bad3(@ModelAttribute Test test) { + public List bad3(@ModelAttribute Test test) { // $ Source[java/mybatis-xml-sql-injection] List result = mybatisSqlInjectionService.bad3(test); return result; } @RequestMapping(value = "msi4", method = RequestMethod.POST, produces = "application/json") - public void bad4(@RequestBody Test test) { + public void bad4(@RequestBody Test test) { // $ Source[java/mybatis-xml-sql-injection] mybatisSqlInjectionService.bad4(test); } @RequestMapping(value = "msi5", method = RequestMethod.PUT, produces = "application/json") - public void bad5(@RequestBody Test test) { + public void bad5(@RequestBody Test test) { // $ Source[java/mybatis-xml-sql-injection] mybatisSqlInjectionService.bad5(test); } @RequestMapping(value = "msi6", method = RequestMethod.POST, produces = "application/json") - public void bad6(@RequestBody Map params) { + public void bad6(@RequestBody Map params) { // $ Source[java/mybatis-xml-sql-injection] mybatisSqlInjectionService.bad6(params); } @RequestMapping(value = "msi7", method = RequestMethod.POST, produces = "application/json") - public void bad7(@RequestBody List params) { + public void bad7(@RequestBody List params) { // $ Source[java/mybatis-xml-sql-injection] mybatisSqlInjectionService.bad7(params); } @RequestMapping(value = "msi8", method = RequestMethod.POST, produces = "application/json") - public void bad8(@RequestBody String[] params) { + public void bad8(@RequestBody String[] params) { // $ Source[java/mybatis-xml-sql-injection] mybatisSqlInjectionService.bad8(params); } @GetMapping(value = "msi9") - public void bad9(@RequestParam String name) { + public void bad9(@RequestParam String name) { // $ Source[java/mybatis-annotation-sql-injection] mybatisSqlInjectionService.bad9(name); } @GetMapping(value = "msi10") - public void bad10(@RequestParam Integer id, @RequestParam String name) { + public void bad10(@RequestParam Integer id, @RequestParam String name) { // $ Source[java/mybatis-annotation-sql-injection] mybatisSqlInjectionService.bad10(id, name); } diff --git a/java/ql/test/experimental/query-tests/security/CWE-089/src/main/MybatisSqlInjectionService.java b/java/ql/test/experimental/query-tests/security/CWE-089/src/main/MybatisSqlInjectionService.java index 6e334ea35dd..7a686c0498a 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-089/src/main/MybatisSqlInjectionService.java +++ b/java/ql/test/experimental/query-tests/security/CWE-089/src/main/MybatisSqlInjectionService.java @@ -11,48 +11,48 @@ public class MybatisSqlInjectionService { private SqlInjectionMapper sqlInjectionMapper; public List bad1(String name) { - List result = sqlInjectionMapper.bad1(name); + List result = sqlInjectionMapper.bad1(name); // $ Alert[java/mybatis-xml-sql-injection] return result; } public List bad2(String name) { - List result = sqlInjectionMapper.bad2(name); + List result = sqlInjectionMapper.bad2(name); // $ Alert[java/mybatis-xml-sql-injection] return result; } public List bad3(Test test) { - List result = sqlInjectionMapper.bad3(test); + List result = sqlInjectionMapper.bad3(test); // $ Alert[java/mybatis-xml-sql-injection] return result; } public void bad4(Test test) { - sqlInjectionMapper.bad4(test); + sqlInjectionMapper.bad4(test); // $ Alert[java/mybatis-xml-sql-injection] } public void bad5(Test test) { - sqlInjectionMapper.bad5(test); + sqlInjectionMapper.bad5(test); // $ Alert[java/mybatis-xml-sql-injection] } public void bad6(Map params) { - sqlInjectionMapper.bad6(params); + sqlInjectionMapper.bad6(params); // $ Alert[java/mybatis-xml-sql-injection] } public void bad7(List params) { - sqlInjectionMapper.bad7(params); + sqlInjectionMapper.bad7(params); // $ Alert[java/mybatis-xml-sql-injection] } public void bad8(String[] params) { - sqlInjectionMapper.bad8(params); + sqlInjectionMapper.bad8(params); // $ Alert[java/mybatis-xml-sql-injection] } public void bad9(String name) { HashMap hashMap = new HashMap(); hashMap.put("name", name); - sqlInjectionMapper.bad9(hashMap); + sqlInjectionMapper.bad9(hashMap); // $ Alert[java/mybatis-annotation-sql-injection] } public void bad10(Integer id, String name) { - sqlInjectionMapper.bad10(id, name); + sqlInjectionMapper.bad10(id, name); // $ Alert[java/mybatis-annotation-sql-injection] } public List good1(Integer id) { diff --git a/java/ql/test/experimental/query-tests/security/CWE-094/BeanShellInjection.java b/java/ql/test/experimental/query-tests/security/CWE-094/BeanShellInjection.java index ee98929312b..015c1569df4 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-094/BeanShellInjection.java +++ b/java/ql/test/experimental/query-tests/security/CWE-094/BeanShellInjection.java @@ -10,24 +10,24 @@ public class BeanShellInjection { @GetMapping(value = "bad1") public void bad1(HttpServletRequest request) { - String code = request.getParameter("code"); + String code = request.getParameter("code"); // $ Source[java/beanshell-injection] BshScriptEvaluator evaluator = new BshScriptEvaluator(); - evaluator.evaluate(new StaticScriptSource(code)); //bad + evaluator.evaluate(new StaticScriptSource(code)); // $ Alert[java/beanshell-injection] //bad } @GetMapping(value = "bad2") public void bad2(HttpServletRequest request) throws Exception { - String code = request.getParameter("code"); + String code = request.getParameter("code"); // $ Source[java/beanshell-injection] Interpreter interpreter = new Interpreter(); - interpreter.eval(code); //bad + interpreter.eval(code); // $ Alert[java/beanshell-injection] //bad } @GetMapping(value = "bad3") public void bad3(HttpServletRequest request) { - String code = request.getParameter("code"); + String code = request.getParameter("code"); // $ Source[java/beanshell-injection] StaticScriptSource staticScriptSource = new StaticScriptSource("test"); staticScriptSource.setScript(code); BshScriptEvaluator evaluator = new BshScriptEvaluator(); - evaluator.evaluate(staticScriptSource); //bad + evaluator.evaluate(staticScriptSource); // $ Alert[java/beanshell-injection] //bad } } diff --git a/java/ql/test/experimental/query-tests/security/CWE-094/BeanShellInjection.qlref b/java/ql/test/experimental/query-tests/security/CWE-094/BeanShellInjection.qlref index 00de8652203..8476fa9ca1a 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-094/BeanShellInjection.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-094/BeanShellInjection.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-094/BeanShellInjection.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-094/JShellInjection.java b/java/ql/test/experimental/query-tests/security/CWE-094/JShellInjection.java index 115030087ff..5e37c77e754 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-094/JShellInjection.java +++ b/java/ql/test/experimental/query-tests/security/CWE-094/JShellInjection.java @@ -9,24 +9,24 @@ public class JShellInjection { @GetMapping(value = "bad1") public void bad1(HttpServletRequest request) { - String input = request.getParameter("code"); + String input = request.getParameter("code"); // $ Source[java/jshell-injection] JShell jShell = JShell.builder().build(); // BAD: allow execution of arbitrary Java code - jShell.eval(input); + jShell.eval(input); // $ Alert[java/jshell-injection] } @GetMapping(value = "bad2") public void bad2(HttpServletRequest request) { - String input = request.getParameter("code"); + String input = request.getParameter("code"); // $ Source[java/jshell-injection] JShell jShell = JShell.builder().build(); SourceCodeAnalysis sourceCodeAnalysis = jShell.sourceCodeAnalysis(); // BAD: allow execution of arbitrary Java code - sourceCodeAnalysis.wrappers(input); + sourceCodeAnalysis.wrappers(input); // $ Alert[java/jshell-injection] } @GetMapping(value = "bad3") public void bad3(HttpServletRequest request) { - String input = request.getParameter("code"); + String input = request.getParameter("code"); // $ Source[java/jshell-injection] JShell jShell = JShell.builder().build(); SourceCodeAnalysis.CompletionInfo info; SourceCodeAnalysis sca = jShell.sourceCodeAnalysis(); @@ -34,7 +34,7 @@ public class JShellInjection { info.completeness().isComplete(); info = sca.analyzeCompletion(info.remaining())) { // BAD: allow execution of arbitrary Java code - jShell.eval(info.source()); + jShell.eval(info.source()); // $ Alert[java/jshell-injection] } } -} \ No newline at end of file +} diff --git a/java/ql/test/experimental/query-tests/security/CWE-094/JShellInjection.qlref b/java/ql/test/experimental/query-tests/security/CWE-094/JShellInjection.qlref index d5b2db58b53..ec418d1a57d 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-094/JShellInjection.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-094/JShellInjection.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-094/JShellInjection.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-094/JakartaExpressionInjection.java b/java/ql/test/experimental/query-tests/security/CWE-094/JakartaExpressionInjection.java index ae5b6a8d5e4..93cbddd5778 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-094/JakartaExpressionInjection.java +++ b/java/ql/test/experimental/query-tests/security/CWE-094/JakartaExpressionInjection.java @@ -20,7 +20,7 @@ public class JakartaExpressionInjection { try (ServerSocket serverSocket = new ServerSocket(0)) { try (Socket socket = serverSocket.accept()) { byte[] bytes = new byte[1024]; - int n = socket.getInputStream().read(bytes); + int n = socket.getInputStream().read(bytes); // $ Source[java/javaee-expression-injection] String expression = new String(bytes, 0, n); action.accept(expression); } @@ -31,7 +31,7 @@ public class JakartaExpressionInjection { private static void testWithELProcessorEval() throws IOException { testWithSocket(expression -> { ELProcessor processor = new ELProcessor(); - processor.eval(expression); + processor.eval(expression); // $ Alert[java/javaee-expression-injection] }); } @@ -39,7 +39,7 @@ public class JakartaExpressionInjection { private static void testWithELProcessorGetValue() throws IOException { testWithSocket(expression -> { ELProcessor processor = new ELProcessor(); - processor.getValue(expression, Object.class); + processor.getValue(expression, Object.class); // $ Alert[java/javaee-expression-injection] }); } @@ -50,7 +50,7 @@ public class JakartaExpressionInjection { StandardELContext context = new StandardELContext(factory); ValueExpression valueExpression = factory.createValueExpression(context, expression, Object.class); LambdaExpression lambdaExpression = new LambdaExpression(new ArrayList<>(), valueExpression); - lambdaExpression.invoke(context, new Object[0]); + lambdaExpression.invoke(context, new Object[0]); // $ Alert[java/javaee-expression-injection] }); } @@ -58,7 +58,7 @@ public class JakartaExpressionInjection { private static void testWithELProcessorSetValue() throws IOException { testWithSocket(expression -> { ELProcessor processor = new ELProcessor(); - processor.setValue(expression, new Object()); + processor.setValue(expression, new Object()); // $ Alert[java/javaee-expression-injection] }); } @@ -66,7 +66,7 @@ public class JakartaExpressionInjection { private static void testWithELProcessorSetVariable() throws IOException { testWithSocket(expression -> { ELProcessor processor = new ELProcessor(); - processor.setVariable("test", expression); + processor.setVariable("test", expression); // $ Alert[java/javaee-expression-injection] }); } @@ -76,7 +76,7 @@ public class JakartaExpressionInjection { ExpressionFactory factory = new de.odysseus.el.ExpressionFactoryImpl(); ELContext context = new de.odysseus.el.util.SimpleContext(); ValueExpression e = factory.createValueExpression(context, expression, Object.class); - e.getValue(context); + e.getValue(context); // $ Alert[java/javaee-expression-injection] }); } @@ -86,7 +86,7 @@ public class JakartaExpressionInjection { ExpressionFactory factory = new de.odysseus.el.ExpressionFactoryImpl(); ELContext context = new de.odysseus.el.util.SimpleContext(); ValueExpression e = factory.createValueExpression(context, expression, Object.class); - e.setValue(context, new Object()); + e.setValue(context, new Object()); // $ Alert[java/javaee-expression-injection] }); } @@ -96,7 +96,7 @@ public class JakartaExpressionInjection { ExpressionFactory factory = new de.odysseus.el.ExpressionFactoryImpl(); ELContext context = new de.odysseus.el.util.SimpleContext(); MethodExpression e = factory.createMethodExpression(context, expression, Object.class, new Class[0]); - e.invoke(context, new Object[0]); + e.invoke(context, new Object[0]); // $ Alert[java/javaee-expression-injection] }); } diff --git a/java/ql/test/experimental/query-tests/security/CWE-094/JakartaExpressionInjection.qlref b/java/ql/test/experimental/query-tests/security/CWE-094/JakartaExpressionInjection.qlref index e00d8a11658..a1e03eeadcb 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-094/JakartaExpressionInjection.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-094/JakartaExpressionInjection.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-094/JakartaExpressionInjection.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-094/JythonInjection.java b/java/ql/test/experimental/query-tests/security/CWE-094/JythonInjection.java index f9b29fec6cc..653e7fd4afb 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-094/JythonInjection.java +++ b/java/ql/test/experimental/query-tests/security/CWE-094/JythonInjection.java @@ -25,7 +25,7 @@ public class JythonInjection extends HttpServlet { // BAD: allow execution of arbitrary Python code protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain"); - String code = request.getParameter("code"); + String code = request.getParameter("code"); // $ Source[java/jython-injection] PythonInterpreter interpreter = null; ByteArrayOutputStream out = new ByteArrayOutputStream(); @@ -33,7 +33,7 @@ public class JythonInjection extends HttpServlet { interpreter = new PythonInterpreter(); interpreter.setOut(out); interpreter.setErr(out); - interpreter.exec(code); + interpreter.exec(code); // $ Alert[java/jython-injection] out.flush(); response.getWriter().print(out.toString()); @@ -50,12 +50,12 @@ public class JythonInjection extends HttpServlet { // BAD: allow execution of arbitrary Python code protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain"); - String code = request.getParameter("code"); + String code = request.getParameter("code"); // $ Source[java/jython-injection] PythonInterpreter interpreter = null; try { interpreter = new PythonInterpreter(); - PyObject py = interpreter.eval(code); + PyObject py = interpreter.eval(code); // $ Alert[java/jython-injection] response.getWriter().print(py.toString()); } catch(PyException ex) { @@ -70,7 +70,7 @@ public class JythonInjection extends HttpServlet { // BAD: allow arbitrary Jython expression to run protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain"); - String code = request.getParameter("code"); + String code = request.getParameter("code"); // $ Source[java/jython-injection] InteractiveInterpreter interpreter = null; ByteArrayOutputStream out = new ByteArrayOutputStream(); @@ -78,7 +78,7 @@ public class JythonInjection extends HttpServlet { interpreter = new InteractiveInterpreter(); interpreter.setOut(out); interpreter.setErr(out); - interpreter.runsource(code); + interpreter.runsource(code); // $ Alert[java/jython-injection] out.flush(); response.getWriter().print(out.toString()); @@ -94,7 +94,7 @@ public class JythonInjection extends HttpServlet { // BAD: load arbitrary class file to execute protected void doTrace(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain"); - String code = request.getParameter("code"); + String code = request.getParameter("code"); // $ Source[java/jython-injection] PythonInterpreter interpreter = null; ByteArrayOutputStream out = new ByteArrayOutputStream(); @@ -103,7 +103,7 @@ public class JythonInjection extends HttpServlet { interpreter.setOut(out); interpreter.setErr(out); - PyCode pyCode = BytecodeLoader.makeCode("test", code.getBytes(), getServletContext().getRealPath("/com/example/test.pyc")); + PyCode pyCode = BytecodeLoader.makeCode("test", code.getBytes(), getServletContext().getRealPath("/com/example/test.pyc")); // $ Alert[java/jython-injection] interpreter.exec(pyCode); out.flush(); @@ -128,7 +128,7 @@ public class JythonInjection extends HttpServlet { interpreter.setOut(out); interpreter.setErr(out); - PyCode pyCode = Py.compile(request.getInputStream(), "Test.py", org.python.core.CompileMode.eval); + PyCode pyCode = Py.compile(request.getInputStream(), "Test.py", org.python.core.CompileMode.eval); // $ Alert[java/jython-injection] interpreter.exec(pyCode); out.flush(); diff --git a/java/ql/test/experimental/query-tests/security/CWE-094/JythonInjection.qlref b/java/ql/test/experimental/query-tests/security/CWE-094/JythonInjection.qlref index 7448a79394e..3d3b09f4801 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-094/JythonInjection.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-094/JythonInjection.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-094/JythonInjection.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-094/RhinoServlet.java b/java/ql/test/experimental/query-tests/security/CWE-094/RhinoServlet.java index e76a9543f87..129c1903466 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-094/RhinoServlet.java +++ b/java/ql/test/experimental/query-tests/security/CWE-094/RhinoServlet.java @@ -25,11 +25,11 @@ public class RhinoServlet extends HttpServlet { // BAD: allow arbitrary Java and JavaScript code to be executed protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain"); - String code = request.getParameter("code"); + String code = request.getParameter("code"); // $ Source[java/unsafe-eval] Context ctx = Context.enter(); try { Scriptable scope = ctx.initStandardObjects(); - Object result = ctx.evaluateString(scope, code, "", 1, null); + Object result = ctx.evaluateString(scope, code, "", 1, null); // $ Alert[java/unsafe-eval] response.getWriter().print(Context.toString(result)); } catch(RhinoException ex) { response.getWriter().println(ex.getMessage()); @@ -78,14 +78,14 @@ public class RhinoServlet extends HttpServlet { // BAD: allow arbitrary code to be compiled for subsequent execution protected void doGet2(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - String code = request.getParameter("code"); + String code = request.getParameter("code"); // $ Source[java/unsafe-eval] ClassCompiler compiler = new ClassCompiler(new CompilerEnvirons()); - Object[] objs = compiler.compileToClassFiles(code, "/sourceLocation", 1, "mainClassName"); + Object[] objs = compiler.compileToClassFiles(code, "/sourceLocation", 1, "mainClassName"); // $ Alert[java/unsafe-eval] } // BAD: allow arbitrary code to be loaded for subsequent execution protected void doPost2(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - String code = request.getParameter("code"); - Class clazz = new DefiningClassLoader().defineClass("Powerfunc", code.getBytes()); + String code = request.getParameter("code"); // $ Source[java/unsafe-eval] + Class clazz = new DefiningClassLoader().defineClass("Powerfunc", code.getBytes()); // $ Alert[java/unsafe-eval] } } diff --git a/java/ql/test/experimental/query-tests/security/CWE-094/ScriptEngineTest.java b/java/ql/test/experimental/query-tests/security/CWE-094/ScriptEngineTest.java index ed7099d7598..a80003fe5eb 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-094/ScriptEngineTest.java +++ b/java/ql/test/experimental/query-tests/security/CWE-094/ScriptEngineTest.java @@ -21,14 +21,14 @@ public class ScriptEngineTest extends HttpServlet { ScriptEngineManager scriptEngineManager = new ScriptEngineManager(); // Create with ScriptEngine reference ScriptEngine scriptEngine = scriptEngineManager.getEngineByExtension("js"); - Object result = scriptEngine.eval(input); + Object result = scriptEngine.eval(input); // $ Alert[java/unsafe-eval] } public void testNashornWithScriptEngineReference(String input) throws ScriptException { NashornScriptEngineFactory factory = new NashornScriptEngineFactory(); // Create Nashorn with ScriptEngine reference ScriptEngine engine = (NashornScriptEngine) factory.getScriptEngine(new String[] { "-scripting" }); - Object result = engine.eval(input); + Object result = engine.eval(input); // $ Alert[java/unsafe-eval] } @@ -36,27 +36,27 @@ public class ScriptEngineTest extends HttpServlet { NashornScriptEngineFactory factory = new NashornScriptEngineFactory(); // Create Nashorn with NashornScriptEngine reference NashornScriptEngine engine = (NashornScriptEngine) factory.getScriptEngine(new String[] { "-scripting" }); - Object result = engine.eval(input); + Object result = engine.eval(input); // $ Alert[java/unsafe-eval] } public void testCustomScriptEngineReference(String input) throws ScriptException { MyCustomFactory factory = new MyCustomFactory(); //Create with Custom Script Engine reference MyCustomScriptEngine engine = (MyCustomScriptEngine) factory.getScriptEngine(new String[] { "-scripting" }); - Object result = engine.eval(input); + Object result = engine.eval(input); // $ Alert[java/unsafe-eval] } public void testScriptEngineCompilable(String input) throws ScriptException { NashornScriptEngineFactory factory = new NashornScriptEngineFactory(); Compilable engine = (Compilable) factory.getScriptEngine(new String[] { "-scripting" }); - CompiledScript script = engine.compile(input); + CompiledScript script = engine.compile(input); // $ Alert[java/unsafe-eval] Object result = script.eval(); } public void testScriptEngineGetProgram(String input) throws ScriptException { ScriptEngineManager scriptEngineManager = new ScriptEngineManager(); ScriptEngine engine = scriptEngineManager.getEngineByName("nashorn"); - String program = engine.getFactory().getProgram(input); + String program = engine.getFactory().getProgram(input); // $ Alert[java/unsafe-eval] Object result = engine.eval(program); } @@ -88,7 +88,7 @@ public class ScriptEngineTest extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { - String code = request.getParameter("code"); + String code = request.getParameter("code"); // $ Source[java/unsafe-eval] new ScriptEngineTest().testWithScriptEngineReference(code); new ScriptEngineTest().testNashornWithScriptEngineReference(code); diff --git a/java/ql/test/experimental/query-tests/security/CWE-094/ScriptInjection.qlref b/java/ql/test/experimental/query-tests/security/CWE-094/ScriptInjection.qlref index 8bd566cf4fd..6aabb565b8b 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-094/ScriptInjection.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-094/ScriptInjection.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-094/ScriptInjection.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-200/FileService.java b/java/ql/test/experimental/query-tests/security/CWE-200/FileService.java index 4641a975429..e3a89e3999a 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-200/FileService.java +++ b/java/ql/test/experimental/query-tests/security/CWE-200/FileService.java @@ -42,7 +42,7 @@ public class FileService extends Service { try { String[] uris = (String[]) params[1]; - outputStream = new FileOutputStream(uris[0]); + outputStream = new FileOutputStream(uris[0]); // $ Alert[java/sensitive-android-file-leak] return "success"; } catch (Exception e) { } diff --git a/java/ql/test/experimental/query-tests/security/CWE-200/InsecureWebResourceResponse.java b/java/ql/test/experimental/query-tests/security/CWE-200/InsecureWebResourceResponse.java index 1405484c56a..275286e2710 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-200/InsecureWebResourceResponse.java +++ b/java/ql/test/experimental/query-tests/security/CWE-200/InsecureWebResourceResponse.java @@ -25,7 +25,7 @@ public class InsecureWebResourceResponse extends Activity { super.onCreate(savedInstanceState); setContentView(-1); - String inputUrl = getIntent().getStringExtra("inputUrl"); + String inputUrl = getIntent().getStringExtra("inputUrl"); // $ Source[java/insecure-webview-resource-response] getBadResponse1(inputUrl); @@ -65,7 +65,7 @@ public class InsecureWebResourceResponse extends Activity { Uri uri = Uri.parse(url); FileInputStream inputStream = new FileInputStream(uri.getPath()); String mimeType = getMimeTypeFromPath(uri.getPath()); - return new WebResourceResponse(mimeType, "UTF-8", inputStream); + return new WebResourceResponse(mimeType, "UTF-8", inputStream); // $ Alert[java/insecure-webview-resource-response] } catch (IOException ie) { return new WebResourceResponse("text/plain", "UTF-8", null); } @@ -88,7 +88,7 @@ public class InsecureWebResourceResponse extends Activity { File cacheFile = new File(getCacheDir(), uri.getLastPathSegment()); FileInputStream inputStream = new FileInputStream(cacheFile); String mimeType = getMimeTypeFromPath(uri.getPath()); - return new WebResourceResponse(mimeType, "UTF-8", inputStream); + return new WebResourceResponse(mimeType, "UTF-8", inputStream); // $ Alert[java/insecure-webview-resource-response] } else { return new WebResourceResponse("text/plain", "UTF-8", null); } @@ -114,7 +114,7 @@ public class InsecureWebResourceResponse extends Activity { if (path.startsWith("files/")) { FileInputStream inputStream = new FileInputStream(path.substring("files/".length())); String mimeType = getMimeTypeFromPath(uri.getPath()); - return new WebResourceResponse(mimeType, "UTF-8", inputStream); + return new WebResourceResponse(mimeType, "UTF-8", inputStream); // $ Alert[java/insecure-webview-resource-response] } else { return new WebResourceResponse("text/plain", "UTF-8", null); } @@ -196,7 +196,7 @@ public class InsecureWebResourceResponse extends Activity { File cacheFile = new File(getCacheDir(), uri.getLastPathSegment()); FileInputStream inputStream = new FileInputStream(cacheFile); String mimeType = getMimeTypeFromPath(uri.getPath()); - return new WebResourceResponse(mimeType, "UTF-8", inputStream); + return new WebResourceResponse(mimeType, "UTF-8", inputStream); // $ Alert[java/insecure-webview-resource-response] } else { return new WebResourceResponse("text/plain", "UTF-8", null); } @@ -234,7 +234,7 @@ class VulnerableWebViewClient extends WebViewClient { Uri uri = Uri.parse(url); FileInputStream inputStream = new FileInputStream(uri.getPath()); String mimeType = InsecureWebResourceResponse.getMimeTypeFromPath(uri.getPath()); - return new WebResourceResponse(mimeType, "UTF-8", inputStream); + return new WebResourceResponse(mimeType, "UTF-8", inputStream); // $ Alert[java/insecure-webview-resource-response] } catch (IOException ie) { return new WebResourceResponse("text/plain", "UTF-8", null); } diff --git a/java/ql/test/experimental/query-tests/security/CWE-200/InsecureWebResourceResponse.qlref b/java/ql/test/experimental/query-tests/security/CWE-200/InsecureWebResourceResponse.qlref index 09049772ede..f592d7c83a7 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-200/InsecureWebResourceResponse.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-200/InsecureWebResourceResponse.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-200/InsecureWebResourceResponse.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-200/InsecureWebViewActivity.java b/java/ql/test/experimental/query-tests/security/CWE-200/InsecureWebViewActivity.java index 6644eb97289..e63de5c9d4e 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-200/InsecureWebViewActivity.java +++ b/java/ql/test/experimental/query-tests/security/CWE-200/InsecureWebViewActivity.java @@ -24,7 +24,7 @@ public class InsecureWebViewActivity extends Activity { setContentView(-1); webview = (VulnerableWebView) findViewById(-1); - String inputUrl = getIntent().getStringExtra("inputUrl"); + String inputUrl = getIntent().getStringExtra("inputUrl"); // $ Source[java/insecure-webview-resource-response] loadWebUrl(inputUrl); } @@ -55,7 +55,7 @@ class VulnerableWebView extends WebView { Uri uri = Uri.parse(url); FileInputStream inputStream = new FileInputStream(uri.getPath()); String mimeType = InsecureWebViewActivity.getMimeTypeFromPath(uri.getPath()); - return new WebResourceResponse(mimeType, "UTF-8", inputStream); + return new WebResourceResponse(mimeType, "UTF-8", inputStream); // $ Alert[java/insecure-webview-resource-response] } catch (IOException ie) { return new WebResourceResponse("text/plain", "UTF-8", null); } diff --git a/java/ql/test/experimental/query-tests/security/CWE-200/LeakFileActivity.java b/java/ql/test/experimental/query-tests/security/CWE-200/LeakFileActivity.java index 3520ed0fd40..6d7cf90ce0b 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-200/LeakFileActivity.java +++ b/java/ql/test/experimental/query-tests/security/CWE-200/LeakFileActivity.java @@ -11,14 +11,14 @@ public class LeakFileActivity extends Activity { protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == GetFileActivity.REQUEST_CODE__SELECT_CONTENT_FROM_APPS && resultCode == RESULT_OK) { - loadOfContentFromApps(data, resultCode); + loadOfContentFromApps(data, resultCode); // $ Source[java/sensitive-android-file-leak] } } private void loadOfContentFromApps(Intent contentIntent, int resultCode) { Uri streamsToUpload = contentIntent.getData(); try { - RandomAccessFile file = new RandomAccessFile(streamsToUpload.getPath(), "r"); + RandomAccessFile file = new RandomAccessFile(streamsToUpload.getPath(), "r"); // $ Alert[java/sensitive-android-file-leak] } catch (Exception ex) { ex.printStackTrace(); } diff --git a/java/ql/test/experimental/query-tests/security/CWE-200/LeakFileActivity2.java b/java/ql/test/experimental/query-tests/security/CWE-200/LeakFileActivity2.java index 56e695ec97a..c3fa282fc0e 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-200/LeakFileActivity2.java +++ b/java/ql/test/experimental/query-tests/security/CWE-200/LeakFileActivity2.java @@ -12,8 +12,8 @@ public class LeakFileActivity2 extends Activity { if (requestCode == GetFileActivity.REQUEST_CODE__SELECT_CONTENT_FROM_APPS && resultCode == RESULT_OK) { Intent intent = new Intent(this, FileService.class); - intent.putExtra(FileService.KEY_LOCAL_FILE, localPath); - startService(intent); + intent.putExtra(FileService.KEY_LOCAL_FILE, localPath); // $ Source[java/sensitive-android-file-leak] + startService(intent); // $ Source[java/sensitive-android-file-leak] } } } diff --git a/java/ql/test/experimental/query-tests/security/CWE-200/SensitiveAndroidFileLeak.qlref b/java/ql/test/experimental/query-tests/security/CWE-200/SensitiveAndroidFileLeak.qlref index a98eeb21914..d4cad711fc2 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-200/SensitiveAndroidFileLeak.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-200/SensitiveAndroidFileLeak.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-200/SensitiveAndroidFileLeak.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-208/NotConstantTimeCheckOnSignature/Test.java b/java/ql/test/experimental/query-tests/security/CWE-208/NotConstantTimeCheckOnSignature/Test.java index 7a4433e485d..20a61b88c36 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-208/NotConstantTimeCheckOnSignature/Test.java +++ b/java/ql/test/experimental/query-tests/security/CWE-208/NotConstantTimeCheckOnSignature/Test.java @@ -11,8 +11,8 @@ public class Test { // BAD: compare MACs using a not-constant time method public boolean unsafeMacCheck(byte[] expectedMac, byte[] data) throws Exception { Mac mac = Mac.getInstance("HmacSHA256"); - byte[] actualMac = mac.doFinal(data); - return Arrays.equals(expectedMac, actualMac); + byte[] actualMac = mac.doFinal(data); // $ Source + return Arrays.equals(expectedMac, actualMac); // $ Alert } // GOOD: compare MACs using a constant time method @@ -27,8 +27,8 @@ public class Test { Signature engine = Signature.getInstance("SHA256withRSA"); engine.initSign(key); engine.update(data); - byte[] signature = engine.sign(); - return Arrays.equals(expected, signature); + byte[] signature = engine.sign(); // $ Source + return Arrays.equals(expected, signature); // $ Alert } // GOOD: compare signatures using a constant time method @@ -44,8 +44,8 @@ public class Test { public boolean unsafeCheckCustomMac(byte[] expected, byte[] plaintext, Key key) throws Exception { Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, key); - byte[] tag = cipher.doFinal(plaintext); - return Arrays.equals(expected, tag); + byte[] tag = cipher.doFinal(plaintext); // $ Source + return Arrays.equals(expected, tag); // $ Alert } // GOOD: compare ciphertexts using a constant time method @@ -56,4 +56,4 @@ public class Test { return MessageDigest.isEqual(expected, tag); } -} \ No newline at end of file +} diff --git a/java/ql/test/experimental/query-tests/security/CWE-208/NotConstantTimeCheckOnSignature/Test.qlref b/java/ql/test/experimental/query-tests/security/CWE-208/NotConstantTimeCheckOnSignature/Test.qlref index 7a83f56cbd6..b426adf811f 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-208/NotConstantTimeCheckOnSignature/Test.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-208/NotConstantTimeCheckOnSignature/Test.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-208/PossibleTimingAttackAgainstSignature.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-208/TimingAttackAgainstHeader/Test.java b/java/ql/test/experimental/query-tests/security/CWE-208/TimingAttackAgainstHeader/Test.java index 3e9dbc11fff..73b0b1fcafc 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-208/TimingAttackAgainstHeader/Test.java +++ b/java/ql/test/experimental/query-tests/security/CWE-208/TimingAttackAgainstHeader/Test.java @@ -7,7 +7,7 @@ import java.lang.String; public class Test { private boolean UnsafeComparison(HttpServletRequest request) { String Key = "secret"; - return Key.equals(request.getHeader("X-Auth-Token")); + return Key.equals(request.getHeader("X-Auth-Token")); // $ Alert } private boolean safeComparison(HttpServletRequest request) { diff --git a/java/ql/test/experimental/query-tests/security/CWE-208/TimingAttackAgainstHeader/TimingAttackAgainstHeader.qlref b/java/ql/test/experimental/query-tests/security/CWE-208/TimingAttackAgainstHeader/TimingAttackAgainstHeader.qlref index 086df8ab1bb..0c95df907ba 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-208/TimingAttackAgainstHeader/TimingAttackAgainstHeader.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-208/TimingAttackAgainstHeader/TimingAttackAgainstHeader.qlref @@ -1 +1,2 @@ -experimental/Security/CWE/CWE-208/TimingAttackAgainstHeader.ql +query: experimental/Security/CWE/CWE-208/TimingAttackAgainstHeader.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-208/TimingAttackAgainstSignagure/Test.java b/java/ql/test/experimental/query-tests/security/CWE-208/TimingAttackAgainstSignagure/Test.java index 0755f1fe668..9613dd2d3df 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-208/TimingAttackAgainstSignagure/Test.java +++ b/java/ql/test/experimental/query-tests/security/CWE-208/TimingAttackAgainstSignagure/Test.java @@ -18,9 +18,9 @@ public class Test { Mac mac = Mac.getInstance("HmacSHA256"); byte[] data = new byte[1024]; is.read(data); - byte[] actualMac = mac.doFinal(data); + byte[] actualMac = mac.doFinal(data); // $ Source byte[] expectedMac = is.readNBytes(32); - return Arrays.equals(expectedMac, actualMac); + return Arrays.equals(expectedMac, actualMac); // $ Alert } } @@ -31,9 +31,9 @@ public class Test { Mac mac = Mac.getInstance("HmacSHA256"); byte[] actualMac = new byte[256]; mac.update(data); - mac.doFinal(actualMac, 0); + mac.doFinal(actualMac, 0); // $ Source byte[] expectedMac = socket.getInputStream().readNBytes(256); - return Arrays.equals(expectedMac, actualMac); + return Arrays.equals(expectedMac, actualMac); // $ Alert } } @@ -56,9 +56,9 @@ public class Test { engine.initSign(key); byte[] data = socket.getInputStream().readAllBytes(); engine.update(data); - byte[] signature = engine.sign(); + byte[] signature = engine.sign(); // $ Source byte[] expected = is.readNBytes(256); - return Arrays.equals(expected, signature); + return Arrays.equals(expected, signature); // $ Alert } } @@ -70,9 +70,9 @@ public class Test { byte[] data = socket.getInputStream().readAllBytes(); engine.update(data); byte[] signature = new byte[1024]; - engine.sign(signature, 0, 1024); + engine.sign(signature, 0, 1024); // $ Source byte[] expected = is.readNBytes(256); - return Arrays.equals(expected, signature); + return Arrays.equals(expected, signature); // $ Alert } } @@ -96,9 +96,9 @@ public class Test { byte[] hash = MessageDigest.getInstance("SHA-256").digest(plaintext); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, key); - byte[] tag = cipher.doFinal(hash); + byte[] tag = cipher.doFinal(hash); // $ Source byte[] expected = socket.getInputStream().readAllBytes(); - return Objects.deepEquals(expected, tag); + return Objects.deepEquals(expected, tag); // $ Alert } } @@ -113,9 +113,9 @@ public class Test { cipher.init(Cipher.ENCRYPT_MODE, key); cipher.update(hash); byte[] tag = new byte[1024]; - cipher.doFinal(tag, 0); + cipher.doFinal(tag, 0); // $ Source byte[] expected = is.readNBytes(32); - return Arrays.equals(expected, tag); + return Arrays.equals(expected, tag); // $ Alert } } @@ -131,9 +131,9 @@ public class Test { cipher.init(Cipher.ENCRYPT_MODE, key); cipher.update(hash); ByteBuffer tag = ByteBuffer.wrap(new byte[1024]); - cipher.doFinal(ByteBuffer.wrap(plaintext), tag); + cipher.doFinal(ByteBuffer.wrap(plaintext), tag); // $ Source byte[] expected = socket.getInputStream().readNBytes(1024); - return Arrays.equals(expected, tag.array()); + return Arrays.equals(expected, tag.array()); // $ Alert } } @@ -145,9 +145,9 @@ public class Test { byte[] plaintext = socket.getInputStream().readAllBytes(); cipher.update(plaintext); ByteBuffer tag = ByteBuffer.wrap(new byte[1024]); - cipher.doFinal(ByteBuffer.wrap(plaintext), tag); + cipher.doFinal(ByteBuffer.wrap(plaintext), tag); // $ Source byte[] expected = is.readNBytes(32); - return ByteBuffer.wrap(expected).equals(tag); + return ByteBuffer.wrap(expected).equals(tag); // $ Alert } } @@ -171,9 +171,9 @@ public class Test { byte[] plaintext = is.readNBytes(100); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, key); - byte[] tag = cipher.doFinal(plaintext); + byte[] tag = cipher.doFinal(plaintext); // $ Source byte[] expected = is.readNBytes(32); - return Arrays.equals(expected, tag); + return Arrays.equals(expected, tag); // $ Alert } } @@ -233,4 +233,4 @@ public class Test { } } -} \ No newline at end of file +} diff --git a/java/ql/test/experimental/query-tests/security/CWE-208/TimingAttackAgainstSignagure/Test.qlref b/java/ql/test/experimental/query-tests/security/CWE-208/TimingAttackAgainstSignagure/Test.qlref index f8275271b6b..fc815564ac0 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-208/TimingAttackAgainstSignagure/Test.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-208/TimingAttackAgainstSignagure/Test.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-208/TimingAttackAgainstSignature.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-295/jxbrowser-6.23.1/JxBrowserWithoutCertValidation.qlref b/java/ql/test/experimental/query-tests/security/CWE-295/jxbrowser-6.23.1/JxBrowserWithoutCertValidation.qlref index cab6f2a4962..fc54893242c 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-295/jxbrowser-6.23.1/JxBrowserWithoutCertValidation.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-295/jxbrowser-6.23.1/JxBrowserWithoutCertValidation.qlref @@ -1 +1,2 @@ -experimental/Security/CWE/CWE-295/JxBrowserWithoutCertValidation.ql +query: experimental/Security/CWE/CWE-295/JxBrowserWithoutCertValidation.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-295/jxbrowser-6.23.1/JxBrowserWithoutCertValidationV6_23_1.java b/java/ql/test/experimental/query-tests/security/CWE-295/jxbrowser-6.23.1/JxBrowserWithoutCertValidationV6_23_1.java index 8f7be261413..a0035959217 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-295/jxbrowser-6.23.1/JxBrowserWithoutCertValidationV6_23_1.java +++ b/java/ql/test/experimental/query-tests/security/CWE-295/jxbrowser-6.23.1/JxBrowserWithoutCertValidationV6_23_1.java @@ -14,7 +14,7 @@ public class JxBrowserWithoutCertValidationV6_23_1 { } private static void badUsage() { - Browser browser = new Browser(); + Browser browser = new Browser(); // $ Alert browser.loadURL("https://example.com"); // no further calls // BAD: The browser ignores any certificate error by default! @@ -33,4 +33,4 @@ public class JxBrowserWithoutCertValidationV6_23_1 { }); // GOOD: A secure `LoadHandler` is used. browser.loadURL("https://example.com"); } -} \ No newline at end of file +} diff --git a/java/ql/test/experimental/query-tests/security/CWE-295/jxbrowser-6.24/JxBrowserWithoutCertValidation.qlref b/java/ql/test/experimental/query-tests/security/CWE-295/jxbrowser-6.24/JxBrowserWithoutCertValidation.qlref index cab6f2a4962..fc54893242c 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-295/jxbrowser-6.24/JxBrowserWithoutCertValidation.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-295/jxbrowser-6.24/JxBrowserWithoutCertValidation.qlref @@ -1 +1,2 @@ -experimental/Security/CWE/CWE-295/JxBrowserWithoutCertValidation.ql +query: experimental/Security/CWE/CWE-295/JxBrowserWithoutCertValidation.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-297/IgnoredHostnameVerification.java b/java/ql/test/experimental/query-tests/security/CWE-297/IgnoredHostnameVerification.java index f79fd15af23..fd4d0d7103e 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-297/IgnoredHostnameVerification.java +++ b/java/ql/test/experimental/query-tests/security/CWE-297/IgnoredHostnameVerification.java @@ -13,7 +13,7 @@ public class IgnoredHostnameVerification { SSLSocket socket = (SSLSocket) SSLSocketFactory.getDefault().createSocket(host, port); socket.startHandshake(); - verifier.verify(host, socket.getSession()); + verifier.verify(host, socket.getSession()); // $ Alert[java/ignored-hostname-verification] return socket; } @@ -109,4 +109,4 @@ public class IgnoredHostnameVerification { } -} \ No newline at end of file +} diff --git a/java/ql/test/experimental/query-tests/security/CWE-297/IgnoredHostnameVerification.qlref b/java/ql/test/experimental/query-tests/security/CWE-297/IgnoredHostnameVerification.qlref index 454b421f7b2..20387fe9f62 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-297/IgnoredHostnameVerification.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-297/IgnoredHostnameVerification.qlref @@ -1 +1,2 @@ -experimental/Security/CWE/CWE-297/IgnoredHostnameVerification.ql \ No newline at end of file +query: experimental/Security/CWE/CWE-297/IgnoredHostnameVerification.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-297/InsecureLdapEndpoint.java b/java/ql/test/experimental/query-tests/security/CWE-297/InsecureLdapEndpoint.java index 72f6bee118a..e04acd919b0 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-297/InsecureLdapEndpoint.java +++ b/java/ql/test/experimental/query-tests/security/CWE-297/InsecureLdapEndpoint.java @@ -16,7 +16,7 @@ public class InsecureLdapEndpoint { env.put(Context.SECURITY_CREDENTIALS, "secpassword"); // Disable SSL endpoint check - System.setProperty("com.sun.jndi.ldap.object.disableEndpointIdentification", "true"); + System.setProperty("com.sun.jndi.ldap.object.disableEndpointIdentification", "true"); // $ Alert[java/insecure-ldaps-endpoint] return env; } @@ -47,7 +47,7 @@ public class InsecureLdapEndpoint { // Disable SSL endpoint check Properties properties = new Properties(); properties.setProperty("com.sun.jndi.ldap.object.disableEndpointIdentification", "true"); - System.setProperties(properties); + System.setProperties(properties); // $ Alert[java/insecure-ldaps-endpoint] return env; } @@ -65,7 +65,7 @@ public class InsecureLdapEndpoint { // Disable SSL endpoint check Properties properties = new Properties(); properties.put("com.sun.jndi.ldap.object.disableEndpointIdentification", "true"); - System.setProperties(properties); + System.setProperties(properties); // $ Alert[java/insecure-ldaps-endpoint] return env; } @@ -81,7 +81,7 @@ public class InsecureLdapEndpoint { env.put(Context.SECURITY_CREDENTIALS, "secpassword"); // Disable SSL endpoint check - System.setProperty(PROP_DISABLE_LDAP_ENDPOINT_IDENTIFICATION, Boolean.TRUE.toString()); + System.setProperty(PROP_DISABLE_LDAP_ENDPOINT_IDENTIFICATION, Boolean.TRUE.toString()); // $ Alert[java/insecure-ldaps-endpoint] return env; } @@ -99,7 +99,7 @@ public class InsecureLdapEndpoint { // Disable SSL endpoint check Properties properties = new Properties(); properties.put("com.sun.jndi.ldap.object.disableEndpointIdentification", true); - System.setProperties(properties); + System.setProperties(properties); // $ Alert[java/insecure-ldaps-endpoint] return env; } diff --git a/java/ql/test/experimental/query-tests/security/CWE-297/InsecureLdapEndpoint.qlref b/java/ql/test/experimental/query-tests/security/CWE-297/InsecureLdapEndpoint.qlref index 1c4d99bb6a3..5fdd2fbfcf0 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-297/InsecureLdapEndpoint.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-297/InsecureLdapEndpoint.qlref @@ -1 +1,2 @@ -experimental/Security/CWE/CWE-297/InsecureLdapEndpoint.ql +query: experimental/Security/CWE/CWE-297/InsecureLdapEndpoint.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-299/DisabledRevocationChecking.java b/java/ql/test/experimental/query-tests/security/CWE-299/DisabledRevocationChecking.java index 41b470b62d0..4b377a34f94 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-299/DisabledRevocationChecking.java +++ b/java/ql/test/experimental/query-tests/security/CWE-299/DisabledRevocationChecking.java @@ -14,7 +14,7 @@ public class DisabledRevocationChecking { private boolean flag = true; public void disableRevocationChecking() { - flag = false; + flag = false; // $ Alert } public void testDisabledRevocationChecking(KeyStore cacerts, CertPath certPath) throws Exception { @@ -25,7 +25,7 @@ public class DisabledRevocationChecking { public void validate(KeyStore cacerts, CertPath certPath) throws Exception { CertPathValidator validator = CertPathValidator.getInstance("PKIX"); PKIXParameters params = new PKIXParameters(cacerts); - params.setRevocationEnabled(flag); + params.setRevocationEnabled(flag); // $ Sink validator.validate(certPath, params); } diff --git a/java/ql/test/experimental/query-tests/security/CWE-299/DisabledRevocationChecking.qlref b/java/ql/test/experimental/query-tests/security/CWE-299/DisabledRevocationChecking.qlref index cc9089b4951..6902ecb5905 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-299/DisabledRevocationChecking.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-299/DisabledRevocationChecking.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-299/DisabledRevocationChecking.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-327/UnsafeTlsVersion.java b/java/ql/test/experimental/query-tests/security/CWE-327/UnsafeTlsVersion.java index 11649621c85..ae87251ea3a 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-327/UnsafeTlsVersion.java +++ b/java/ql/test/experimental/query-tests/security/CWE-327/UnsafeTlsVersion.java @@ -13,12 +13,12 @@ public class UnsafeTlsVersion { public static void testSslContextWithProtocol() throws NoSuchAlgorithmException { // unsafe - SSLContext.getInstance("SSL"); - SSLContext.getInstance("SSLv2"); - SSLContext.getInstance("SSLv3"); - SSLContext.getInstance("TLS"); - SSLContext.getInstance("TLSv1"); - SSLContext.getInstance("TLSv1.1"); + SSLContext.getInstance("SSL"); // $ Alert + SSLContext.getInstance("SSLv2"); // $ Alert + SSLContext.getInstance("SSLv3"); // $ Alert + SSLContext.getInstance("TLS"); // $ Alert + SSLContext.getInstance("TLSv1"); // $ Alert + SSLContext.getInstance("TLSv1.1"); // $ Alert // safe SSLContext.getInstance("TLSv1.2"); @@ -28,11 +28,11 @@ public class UnsafeTlsVersion { public static void testCreateSslParametersWithProtocol(String[] cipherSuites) { // unsafe - createSslParameters(cipherSuites, "SSLv3"); - createSslParameters(cipherSuites, "TLS"); - createSslParameters(cipherSuites, "TLSv1"); - createSslParameters(cipherSuites, "TLSv1.1"); - createSslParameters(cipherSuites, "TLSv1", "TLSv1.1", "TLSv1.2"); + createSslParameters(cipherSuites, "SSLv3"); // $ Source + createSslParameters(cipherSuites, "TLS"); // $ Source + createSslParameters(cipherSuites, "TLSv1"); // $ Source + createSslParameters(cipherSuites, "TLSv1.1"); // $ Source + createSslParameters(cipherSuites, "TLSv1", "TLSv1.1", "TLSv1.2"); // $ Source createSslParameters(cipherSuites, "TLSv1.2"); // safe @@ -41,19 +41,19 @@ public class UnsafeTlsVersion { } public static SSLParameters createSslParameters(String[] cipherSuites, String... protocols) { - return new SSLParameters(cipherSuites, protocols); + return new SSLParameters(cipherSuites, protocols); // $ Alert } public static void testSettingProtocolsForSslParameters() { // unsafe - new SSLParameters().setProtocols(new String[] { "SSLv3" }); - new SSLParameters().setProtocols(new String[] { "TLS" }); - new SSLParameters().setProtocols(new String[] { "TLSv1" }); - new SSLParameters().setProtocols(new String[] { "TLSv1.1" }); + new SSLParameters().setProtocols(new String[] { "SSLv3" }); // $ Alert + new SSLParameters().setProtocols(new String[] { "TLS" }); // $ Alert + new SSLParameters().setProtocols(new String[] { "TLSv1" }); // $ Alert + new SSLParameters().setProtocols(new String[] { "TLSv1.1" }); // $ Alert SSLParameters parameters = new SSLParameters(); - parameters.setProtocols(new String[] { "TLSv1.1", "TLSv1.2" }); + parameters.setProtocols(new String[] { "TLSv1.1", "TLSv1.2" }); // $ Alert // safe new SSLParameters().setProtocols(new String[] { "TLSv1.2" }); @@ -65,11 +65,11 @@ public class UnsafeTlsVersion { public static void testSettingProtocolForSslSocket() throws IOException { // unsafe - createSslSocket("SSLv3"); - createSslSocket("TLS"); - createSslSocket("TLSv1"); - createSslSocket("TLSv1.1"); - createSslSocket("TLSv1.1", "TLSv1.2"); + createSslSocket("SSLv3"); // $ Source + createSslSocket("TLS"); // $ Source + createSslSocket("TLSv1"); // $ Source + createSslSocket("TLSv1.1"); // $ Source + createSslSocket("TLSv1.1", "TLSv1.2"); // $ Source // safe createSslSocket("TLSv1.2"); @@ -78,18 +78,18 @@ public class UnsafeTlsVersion { public static SSLSocket createSslSocket(String... protocols) throws IOException { SSLSocket socket = (SSLSocket) SSLSocketFactory.getDefault().createSocket(); - socket.setEnabledProtocols(protocols); + socket.setEnabledProtocols(protocols); // $ Alert return socket; } public static void testSettingProtocolForSslServerSocket() throws IOException { // unsafe - createSslServerSocket("SSLv3"); - createSslServerSocket("TLS"); - createSslServerSocket("TLSv1"); - createSslServerSocket("TLSv1.1"); - createSslServerSocket("TLSv1.1", "TLSv1.2"); + createSslServerSocket("SSLv3"); // $ Source + createSslServerSocket("TLS"); // $ Source + createSslServerSocket("TLSv1"); // $ Source + createSslServerSocket("TLSv1.1"); // $ Source + createSslServerSocket("TLSv1.1", "TLSv1.2"); // $ Source // safe createSslServerSocket("TLSv1.2"); @@ -98,18 +98,18 @@ public class UnsafeTlsVersion { public static SSLServerSocket createSslServerSocket(String... protocols) throws IOException { SSLServerSocket socket = (SSLServerSocket) SSLServerSocketFactory.getDefault().createServerSocket(); - socket.setEnabledProtocols(protocols); + socket.setEnabledProtocols(protocols); // $ Alert return socket; } public static void testSettingProtocolForSslEngine() throws NoSuchAlgorithmException { // unsafe - createSslEngine("SSLv3"); - createSslEngine("TLS"); - createSslEngine("TLSv1"); - createSslEngine("TLSv1.1"); - createSslEngine("TLSv1.1", "TLSv1.2"); + createSslEngine("SSLv3"); // $ Source + createSslEngine("TLS"); // $ Source + createSslEngine("TLSv1"); // $ Source + createSslEngine("TLSv1.1"); // $ Source + createSslEngine("TLSv1.1", "TLSv1.2"); // $ Source // safe createSslEngine("TLSv1.2"); @@ -118,7 +118,7 @@ public class UnsafeTlsVersion { public static SSLEngine createSslEngine(String... protocols) throws NoSuchAlgorithmException { SSLEngine engine = SSLContext.getDefault().createSSLEngine(); - engine.setEnabledProtocols(protocols); + engine.setEnabledProtocols(protocols); // $ Alert return engine; } } diff --git a/java/ql/test/experimental/query-tests/security/CWE-327/UnsafeTlsVersion.qlref b/java/ql/test/experimental/query-tests/security/CWE-327/UnsafeTlsVersion.qlref index f29bf9a7836..5f599e917bd 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-327/UnsafeTlsVersion.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-327/UnsafeTlsVersion.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-327/UnsafeTlsVersion.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-346/UnvalidatedCors.java b/java/ql/test/experimental/query-tests/security/CWE-346/UnvalidatedCors.java index 9ec3c8466be..d6f0ce5ab2d 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-346/UnvalidatedCors.java +++ b/java/ql/test/experimental/query-tests/security/CWE-346/UnvalidatedCors.java @@ -18,13 +18,13 @@ public class UnvalidatedCors implements Filter { FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; - String url = request.getHeader("Origin"); + String url = request.getHeader("Origin"); // $ Source if (!StringUtils.isEmpty(url)) { String val = response.getHeader("Access-Control-Allow-Origin"); if (StringUtils.isEmpty(val)) { - response.addHeader("Access-Control-Allow-Origin", url); + response.addHeader("Access-Control-Allow-Origin", url); // $ Alert response.addHeader("Access-Control-Allow-Credentials", "true"); } } diff --git a/java/ql/test/experimental/query-tests/security/CWE-346/UnvalidatedCors.qlref b/java/ql/test/experimental/query-tests/security/CWE-346/UnvalidatedCors.qlref index 90fde66959b..fdd2a5c3f79 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-346/UnvalidatedCors.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-346/UnvalidatedCors.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-346/UnvalidatedCors.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-347/Auth0NoVerifier.qlref b/java/ql/test/experimental/query-tests/security/CWE-347/Auth0NoVerifier.qlref index 0cd8baf6d34..5a642823c7c 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-347/Auth0NoVerifier.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-347/Auth0NoVerifier.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-347/Auth0NoVerifier.ql -postprocess: utils/test/PrettyPrintModels.ql \ No newline at end of file +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-347/JwtNoVerifier.java b/java/ql/test/experimental/query-tests/security/CWE-347/JwtNoVerifier.java index 15a31bcc476..b6814f36abf 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-347/JwtNoVerifier.java +++ b/java/ql/test/experimental/query-tests/security/CWE-347/JwtNoVerifier.java @@ -41,7 +41,7 @@ public class JwtNoVerifier extends HttpServlet { PrintWriter out = response.getWriter(); // NOT OK: only decode, no verification - String JwtToken1 = request.getParameter("JWT2"); + String JwtToken1 = request.getParameter("JWT2"); // $ Source String userName = decodeToken(JwtToken1); if (Objects.equals(userName, "Admin")) { out.println(""); @@ -55,7 +55,7 @@ public class JwtNoVerifier extends HttpServlet { JWT.decode(JwtToken2); // NOT OK: only decode, no verification - String JwtToken3 = (String) authToken.getCredentials(); + String JwtToken3 = (String) authToken.getCredentials(); // $ Source userName = decodeToken(JwtToken3); if (Objects.equals(userName, "Admin")) { out.println(""); @@ -88,7 +88,7 @@ public class JwtNoVerifier extends HttpServlet { public static String decodeToken(final String token) { DecodedJWT jwt = JWT.decode(token); - return Optional.of(jwt).map(item -> item.getClaim("userName").asString()).orElse(""); + return Optional.of(jwt).map(item -> item.getClaim("userName").asString()).orElse(""); // $ Alert } diff --git a/java/ql/test/experimental/query-tests/security/CWE-348/ClientSuppliedIpUsedInSecurityCheck.java b/java/ql/test/experimental/query-tests/security/CWE-348/ClientSuppliedIpUsedInSecurityCheck.java index 93a860981d1..1e0175fcd35 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-348/ClientSuppliedIpUsedInSecurityCheck.java +++ b/java/ql/test/experimental/query-tests/security/CWE-348/ClientSuppliedIpUsedInSecurityCheck.java @@ -14,7 +14,7 @@ public class ClientSuppliedIpUsedInSecurityCheck { @GetMapping(value = "bad1") public void bad1(HttpServletRequest request) { String ip = getClientIP(); - if (!StringUtils.startsWith(ip, "192.168.")) { + if (!StringUtils.startsWith(ip, "192.168.")) { // $ Alert new Exception("ip illegal"); } } @@ -22,7 +22,7 @@ public class ClientSuppliedIpUsedInSecurityCheck { @GetMapping(value = "bad2") public void bad2(HttpServletRequest request) { String ip = getClientIP(); - if (!"127.0.0.1".equals(ip)) { + if (!"127.0.0.1".equals(ip)) { // $ Alert new Exception("ip illegal"); } } @@ -40,7 +40,7 @@ public class ClientSuppliedIpUsedInSecurityCheck { } protected String getClientIP() { - String xfHeader = request.getHeader("X-Forwarded-For"); + String xfHeader = request.getHeader("X-Forwarded-For"); // $ Source if (xfHeader == null) { return request.getRemoteAddr(); } diff --git a/java/ql/test/experimental/query-tests/security/CWE-348/ClientSuppliedIpUsedInSecurityCheck.qlref b/java/ql/test/experimental/query-tests/security/CWE-348/ClientSuppliedIpUsedInSecurityCheck.qlref index 8ca6ac71c9a..78f375ab1ee 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-348/ClientSuppliedIpUsedInSecurityCheck.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-348/ClientSuppliedIpUsedInSecurityCheck.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-348/ClientSuppliedIpUsedInSecurityCheck.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-352/JsonpController.java b/java/ql/test/experimental/query-tests/security/CWE-352/JsonpController.java index c7fd850bb09..ec3e070b342 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-352/JsonpController.java +++ b/java/ql/test/experimental/query-tests/security/CWE-352/JsonpController.java @@ -30,79 +30,79 @@ public class JsonpController { @ResponseBody public String bad1(HttpServletRequest request) { String resultStr = null; - String jsonpCallback = request.getParameter("jsonpCallback"); + String jsonpCallback = request.getParameter("jsonpCallback"); // $ Source Gson gson = new Gson(); String result = gson.toJson(hashMap); resultStr = jsonpCallback + "(" + result + ")"; - return resultStr; + return resultStr; // $ Alert } @GetMapping(value = "jsonp2") @ResponseBody public String bad2(HttpServletRequest request) { String resultStr = null; - String jsonpCallback = request.getParameter("jsonpCallback"); + String jsonpCallback = request.getParameter("jsonpCallback"); // $ Source resultStr = jsonpCallback + "(" + JSONObject.toJSONString(hashMap) + ")"; - return resultStr; + return resultStr; // $ Alert } @GetMapping(value = "jsonp3") @ResponseBody public String bad3(HttpServletRequest request) { String resultStr = null; - String jsonpCallback = request.getParameter("jsonpCallback"); + String jsonpCallback = request.getParameter("jsonpCallback"); // $ Source String jsonStr = getJsonStr(hashMap); resultStr = jsonpCallback + "(" + jsonStr + ")"; - return resultStr; + return resultStr; // $ Alert } @GetMapping(value = "jsonp4") @ResponseBody public String bad4(HttpServletRequest request) { String resultStr = null; - String jsonpCallback = request.getParameter("jsonpCallback"); + String jsonpCallback = request.getParameter("jsonpCallback"); // $ Source String restr = JSONObject.toJSONString(hashMap); resultStr = jsonpCallback + "(" + restr + ");"; - return resultStr; + return resultStr; // $ Alert } @GetMapping(value = "jsonp5") @ResponseBody public void bad5(HttpServletRequest request, HttpServletResponse response) throws Exception { - String jsonpCallback = request.getParameter("jsonpCallback"); + String jsonpCallback = request.getParameter("jsonpCallback"); // $ Source PrintWriter pw = null; Gson gson = new Gson(); String result = gson.toJson(hashMap); String resultStr = null; pw = response.getWriter(); resultStr = jsonpCallback + "(" + result + ")"; - pw.println(resultStr); + pw.println(resultStr); // $ Alert } @GetMapping(value = "jsonp6") @ResponseBody public void bad6(HttpServletRequest request, HttpServletResponse response) throws Exception { - String jsonpCallback = request.getParameter("jsonpCallback"); + String jsonpCallback = request.getParameter("jsonpCallback"); // $ Source PrintWriter pw = null; ObjectMapper mapper = new ObjectMapper(); String result = mapper.writeValueAsString(hashMap); String resultStr = null; pw = response.getWriter(); resultStr = jsonpCallback + "(" + result + ")"; - pw.println(resultStr); + pw.println(resultStr); // $ Alert } @RequestMapping(value = "jsonp7", method = RequestMethod.GET) @ResponseBody public String bad7(HttpServletRequest request) { String resultStr = null; - String jsonpCallback = request.getParameter("jsonpCallback"); + String jsonpCallback = request.getParameter("jsonpCallback"); // $ Source Gson gson = new Gson(); String result = gson.toJson(hashMap); resultStr = jsonpCallback + "(" + result + ")"; - return resultStr; + return resultStr; // $ Alert } @RequestMapping(value = "jsonp11") @@ -158,4 +158,4 @@ public class JsonpController { public static String getJsonStr(Object result) { return JSONObject.toJSONString(result); } -} \ No newline at end of file +} diff --git a/java/ql/test/experimental/query-tests/security/CWE-352/JsonpInjection.qlref b/java/ql/test/experimental/query-tests/security/CWE-352/JsonpInjection.qlref index 15b579b57ea..86da535af89 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-352/JsonpInjection.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-352/JsonpInjection.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-352/JsonpInjection.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-400/LocalThreadResourceAbuse.qlref b/java/ql/test/experimental/query-tests/security/CWE-400/LocalThreadResourceAbuse.qlref index 12c247f1f3b..95485a215fe 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-400/LocalThreadResourceAbuse.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-400/LocalThreadResourceAbuse.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-400/LocalThreadResourceAbuse.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-400/ThreadResourceAbuse.java b/java/ql/test/experimental/query-tests/security/CWE-400/ThreadResourceAbuse.java index e5cd70c42f2..44d25320eef 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-400/ThreadResourceAbuse.java +++ b/java/ql/test/experimental/query-tests/security/CWE-400/ThreadResourceAbuse.java @@ -15,7 +15,7 @@ public class ThreadResourceAbuse extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // BAD: Get thread pause time from request parameter without validation - String delayTimeStr = request.getParameter("DelayTime"); + String delayTimeStr = request.getParameter("DelayTime"); // $ Source[java/thread-resource-abuse] try { int delayTime = Integer.valueOf(delayTimeStr); new UncheckedSyncAction(delayTime).start(); @@ -26,7 +26,7 @@ public class ThreadResourceAbuse extends HttpServlet { protected void doGet2(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // BAD: Get thread pause time from request parameter without validation try { - int delayTime = request.getParameter("nodelay") != null ? 0 : Integer.valueOf(request.getParameter("DelayTime")); + int delayTime = request.getParameter("nodelay") != null ? 0 : Integer.valueOf(request.getParameter("DelayTime")); // $ Source[java/thread-resource-abuse] new UncheckedSyncAction(delayTime).start(); } catch (NumberFormatException e) { } @@ -34,7 +34,7 @@ public class ThreadResourceAbuse extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // BAD: Get thread pause time from context init parameter without validation - String delayTimeStr = getServletContext().getInitParameter("DelayTime"); + String delayTimeStr = getServletContext().getInitParameter("DelayTime"); // $ Source[java/local-thread-resource-abuse] try { int delayTime = Integer.valueOf(delayTimeStr); new UncheckedSyncAction(delayTime).start(); @@ -71,7 +71,7 @@ public class ThreadResourceAbuse extends HttpServlet { public void run() { // BAD: no boundary check on wait time try { - Thread.sleep(waitTime); + Thread.sleep(waitTime); // $ Alert[java/thread-resource-abuse] Alert[java/local-thread-resource-abuse] // Do other updates } catch (InterruptedException e) { } @@ -138,10 +138,10 @@ public class ThreadResourceAbuse extends HttpServlet { Cookie cookie = cookies[i]; if (cookie.getName().equals("DelayTime")) { - String delayTimeStr = cookie.getValue(); + String delayTimeStr = cookie.getValue(); // $ Source[java/thread-resource-abuse] try { int delayTime = Integer.valueOf(delayTimeStr); - TimeUnit.MILLISECONDS.sleep(delayTime); + TimeUnit.MILLISECONDS.sleep(delayTime); // $ Alert[java/thread-resource-abuse] // Do other updates } catch (NumberFormatException ne) { } catch (InterruptedException ie) { @@ -169,11 +169,11 @@ public class ThreadResourceAbuse extends HttpServlet { protected void doHead2(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // BAD: Get thread pause time from request header without validation - String header = request.getHeader("Retry-After"); + String header = request.getHeader("Retry-After"); // $ Source[java/thread-resource-abuse] int retryAfter = Integer.parseInt(header); try { - Thread.sleep(retryAfter); + Thread.sleep(retryAfter); // $ Alert[java/thread-resource-abuse] } catch (InterruptedException ignore) { // ignore } @@ -203,7 +203,7 @@ public class ThreadResourceAbuse extends HttpServlet { protected void doHead4(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // BAD: Get thread pause time from request header without validation try { - String uploadDelayStr = request.getParameter("delay"); + String uploadDelayStr = request.getParameter("delay"); // $ Source[java/thread-resource-abuse] int uploadDelay = Integer.parseInt(uploadDelayStr); UploadListener listener = new UploadListener(uploadDelay, getContentLength(request)); @@ -212,11 +212,11 @@ public class ThreadResourceAbuse extends HttpServlet { protected void doHead5(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // BAD: Get thread pause time from request header with binary multiplication expression and without validation - String header = request.getHeader("Retry-After"); + String header = request.getHeader("Retry-After"); // $ Source[java/thread-resource-abuse] int retryAfter = Integer.parseInt(header); try { - Thread.sleep(retryAfter * 1000); + Thread.sleep(retryAfter * 1000); // $ Alert[java/thread-resource-abuse] } catch (InterruptedException ignore) { // ignore } @@ -224,13 +224,13 @@ public class ThreadResourceAbuse extends HttpServlet { protected void doHead6(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // BAD: Get thread pause time from request header with multiplication assignment operator and without validation - String header = request.getHeader("Retry-After"); + String header = request.getHeader("Retry-After"); // $ Source[java/thread-resource-abuse] int retryAfter = Integer.parseInt(header); retryAfter *= 1000; try { - Thread.sleep(retryAfter); + Thread.sleep(retryAfter); // $ Alert[java/thread-resource-abuse] } catch (InterruptedException ignore) { // ignore } diff --git a/java/ql/test/experimental/query-tests/security/CWE-400/ThreadResourceAbuse.qlref b/java/ql/test/experimental/query-tests/security/CWE-400/ThreadResourceAbuse.qlref index caf6f8da85b..bf6365944ba 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-400/ThreadResourceAbuse.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-400/ThreadResourceAbuse.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-400/ThreadResourceAbuse.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-400/UploadListener.java b/java/ql/test/experimental/query-tests/security/CWE-400/UploadListener.java index 9e213116872..d6df514518b 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-400/UploadListener.java +++ b/java/ql/test/experimental/query-tests/security/CWE-400/UploadListener.java @@ -32,7 +32,7 @@ public class UploadListener implements ProgressListener, Serializable { // Just a way to slow down the upload process and see the progress bar in fast networks. if (slowUploads > 0 && done < total) { try { - Thread.sleep(slowUploads); + Thread.sleep(slowUploads); // $ Alert[java/thread-resource-abuse] } catch (Exception e) { } } diff --git a/java/ql/test/experimental/query-tests/security/CWE-470/BadClassLoader.java b/java/ql/test/experimental/query-tests/security/CWE-470/BadClassLoader.java index 6fd6b9ccfa5..213dfa96196 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-470/BadClassLoader.java +++ b/java/ql/test/experimental/query-tests/security/CWE-470/BadClassLoader.java @@ -12,10 +12,10 @@ public class BadClassLoader extends Application { for (PackageInfo p : getPackageManager().getInstalledPackages(0)) { try { if (p.packageName.startsWith("some.package.")) { - Context appContext = createPackageContext(p.packageName, - CONTEXT_INCLUDE_CODE | CONTEXT_IGNORE_SECURITY); + Context appContext = createPackageContext(p.packageName, // $ + CONTEXT_INCLUDE_CODE | CONTEXT_IGNORE_SECURITY); // $ Source[java/android/unsafe-reflection] ClassLoader classLoader = appContext.getClassLoader(); - Object result = classLoader.loadClass("some.package.SomeClass") + Object result = classLoader.loadClass("some.package.SomeClass") // $ Alert[java/android/unsafe-reflection] .getMethod("someMethod") .invoke(null); } diff --git a/java/ql/test/experimental/query-tests/security/CWE-470/LoadClassNoSignatureCheck.qlref b/java/ql/test/experimental/query-tests/security/CWE-470/LoadClassNoSignatureCheck.qlref index 5feabdb8bec..d1d07a95f73 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-470/LoadClassNoSignatureCheck.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-470/LoadClassNoSignatureCheck.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-470/LoadClassNoSignatureCheck.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-470/UnsafeReflection.java b/java/ql/test/experimental/query-tests/security/CWE-470/UnsafeReflection.java index d9dc0573660..2822ad3dff2 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-470/UnsafeReflection.java +++ b/java/ql/test/experimental/query-tests/security/CWE-470/UnsafeReflection.java @@ -18,11 +18,11 @@ public class UnsafeReflection { @GetMapping(value = "uf1") public void bad1(HttpServletRequest request) { - String className = request.getParameter("className"); + String className = request.getParameter("className"); // $ Source[java/unsafe-reflection] String parameterValue = request.getParameter("parameterValue"); try { Class clazz = Class.forName(className); - Object object = clazz.getDeclaredConstructors()[0].newInstance(parameterValue); //bad + Object object = clazz.getDeclaredConstructors()[0].newInstance(parameterValue); // $ Alert[java/unsafe-reflection] //bad } catch (Exception e) { e.printStackTrace(); } @@ -30,20 +30,20 @@ public class UnsafeReflection { @GetMapping(value = "uf2") public void bad2(HttpServletRequest request) { - String className = request.getParameter("className"); + String className = request.getParameter("className"); // $ Source[java/unsafe-reflection] String parameterValue = request.getParameter("parameterValue"); try { ClassLoader classLoader = ClassLoader.getSystemClassLoader(); Class clazz = classLoader.loadClass(className); Object object = clazz.newInstance(); - clazz.getDeclaredMethods()[0].invoke(object, parameterValue); //bad + clazz.getDeclaredMethods()[0].invoke(object, parameterValue); // $ Alert[java/unsafe-reflection] //bad } catch (Exception e) { e.printStackTrace(); } } @RequestMapping(value = {"/service/{beanIdOrClassName}/{methodName}"}, method = {RequestMethod.POST}, consumes = {"application/json"}, produces = {"application/json"}) - public Object bad3(@PathVariable("beanIdOrClassName") String beanIdOrClassName, @PathVariable("methodName") String methodName, @RequestBody Map body) throws Exception { + public Object bad3(@PathVariable("beanIdOrClassName") String beanIdOrClassName, @PathVariable("methodName") String methodName, @RequestBody Map body) throws Exception { // $ Source[java/unsafe-reflection] List rawData = null; try { rawData = (List)body.get("methodInput"); @@ -116,7 +116,7 @@ public class UnsafeReflection { b++; continue; } - Object result = method.invoke(bean, data); + Object result = method.invoke(bean, data); // $ Alert[java/unsafe-reflection] Map map = new HashMap<>(); return map; } diff --git a/java/ql/test/experimental/query-tests/security/CWE-470/UnsafeReflection.qlref b/java/ql/test/experimental/query-tests/security/CWE-470/UnsafeReflection.qlref index 28822316a90..119312e6ae8 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-470/UnsafeReflection.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-470/UnsafeReflection.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-470/UnsafeReflection.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-489/ServiceBean.java b/java/ql/test/experimental/query-tests/security/CWE-489/ServiceBean.java index a29a82bb15b..056074f3b35 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-489/ServiceBean.java +++ b/java/ql/test/experimental/query-tests/security/CWE-489/ServiceBean.java @@ -52,7 +52,7 @@ public class ServiceBean implements SessionBean { } /** Local unit testing code */ - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws Exception { // $ Alert[java/main-method-in-enterprise-bean] ServiceBean b = new ServiceBean(); b.doService(); } diff --git a/java/ql/test/experimental/query-tests/security/CWE-489/ServiceBean.qlref b/java/ql/test/experimental/query-tests/security/CWE-489/ServiceBean.qlref index 38d09d01cfb..80869cba4ff 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-489/ServiceBean.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-489/ServiceBean.qlref @@ -1 +1,2 @@ -experimental/Security/CWE/CWE-489/EJBMain.ql +query: experimental/Security/CWE/CWE-489/EJBMain.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-489/ServletContextListenerMain.java b/java/ql/test/experimental/query-tests/security/CWE-489/ServletContextListenerMain.java index 38ce153aa5a..71351029f56 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-489/ServletContextListenerMain.java +++ b/java/ql/test/experimental/query-tests/security/CWE-489/ServletContextListenerMain.java @@ -14,7 +14,7 @@ public class ServletContextListenerMain implements ServletContextListener { } // BAD - Implement a main method in servlet listener. - public static void main(String[] args) { + public static void main(String[] args) { // $ Alert[java/main-method-in-web-components] try { URL url = new URL("https://www.example.com"); url.openConnection(); diff --git a/java/ql/test/experimental/query-tests/security/CWE-489/ServletMain.java b/java/ql/test/experimental/query-tests/security/CWE-489/ServletMain.java index 55b73bd3b72..4f3029b6d13 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-489/ServletMain.java +++ b/java/ql/test/experimental/query-tests/security/CWE-489/ServletMain.java @@ -25,7 +25,7 @@ public class ServletMain implements Servlet { } // BAD - Implement a main method in servlet. - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws Exception { // $ Alert[java/main-method-in-web-components] // Connect to my server URL url = new URL("https://www.example.com"); url.openConnection(); diff --git a/java/ql/test/experimental/query-tests/security/CWE-489/ServletMain.qlref b/java/ql/test/experimental/query-tests/security/CWE-489/ServletMain.qlref index bf8fc2aacce..71869fb862e 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-489/ServletMain.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-489/ServletMain.qlref @@ -1 +1,2 @@ -experimental/Security/CWE/CWE-489/WebComponentMain.ql +query: experimental/Security/CWE/CWE-489/WebComponentMain.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-502/SpringExporterUnsafeDeserialization.java b/java/ql/test/experimental/query-tests/security/CWE-502/SpringExporterUnsafeDeserialization.java index f1b2453ea15..5f5fcd56129 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-502/SpringExporterUnsafeDeserialization.java +++ b/java/ql/test/experimental/query-tests/security/CWE-502/SpringExporterUnsafeDeserialization.java @@ -11,7 +11,7 @@ import org.springframework.remoting.rmi.RmiServiceExporter; public class SpringExporterUnsafeDeserialization { @Bean(name = "/unsafeRmiServiceExporter") - RmiServiceExporter unsafeRmiServiceExporter() { + RmiServiceExporter unsafeRmiServiceExporter() { // $ Alert[java/unsafe-deserialization-spring-exporter-in-configuration-class] RmiServiceExporter exporter = new RmiServiceExporter(); exporter.setServiceInterface(AccountService.class); exporter.setService(new AccountServiceImpl()); @@ -21,7 +21,7 @@ public class SpringExporterUnsafeDeserialization { } @Bean(name = "/unsafeHessianServiceExporter") - HessianServiceExporter unsafeHessianServiceExporter() { + HessianServiceExporter unsafeHessianServiceExporter() { // $ Alert[java/unsafe-deserialization-spring-exporter-in-configuration-class] HessianServiceExporter exporter = new HessianServiceExporter(); exporter.setService(new AccountServiceImpl()); exporter.setServiceInterface(AccountService.class); @@ -29,7 +29,7 @@ public class SpringExporterUnsafeDeserialization { } @Bean(name = "/unsafeHttpInvokerServiceExporter") - HttpInvokerServiceExporter unsafeHttpInvokerServiceExporter() { + HttpInvokerServiceExporter unsafeHttpInvokerServiceExporter() { // $ Alert[java/unsafe-deserialization-spring-exporter-in-configuration-class] HttpInvokerServiceExporter exporter = new HttpInvokerServiceExporter(); exporter.setService(new AccountServiceImpl()); exporter.setServiceInterface(AccountService.class); @@ -37,7 +37,7 @@ public class SpringExporterUnsafeDeserialization { } @Bean(name = "/unsafeCustomeRemoteInvocationSerializingExporter") - RemoteInvocationSerializingExporter unsafeCustomeRemoteInvocationSerializingExporter() { + RemoteInvocationSerializingExporter unsafeCustomeRemoteInvocationSerializingExporter() { // $ Alert[java/unsafe-deserialization-spring-exporter-in-configuration-class] return new CustomeRemoteInvocationSerializingExporter(); } @@ -53,7 +53,7 @@ public class SpringExporterUnsafeDeserialization { class SpringBootTestApplication { @Bean(name = "/unsafeHttpInvokerServiceExporter") - HttpInvokerServiceExporter unsafeHttpInvokerServiceExporter() { + HttpInvokerServiceExporter unsafeHttpInvokerServiceExporter() { // $ Alert[java/unsafe-deserialization-spring-exporter-in-configuration-class] HttpInvokerServiceExporter exporter = new HttpInvokerServiceExporter(); exporter.setService(new AccountServiceImpl()); exporter.setServiceInterface(AccountService.class); @@ -65,7 +65,7 @@ class SpringBootTestApplication { class SpringBootTestConfiguration { @Bean(name = "/unsafeHttpInvokerServiceExporter") - HttpInvokerServiceExporter unsafeHttpInvokerServiceExporter() { + HttpInvokerServiceExporter unsafeHttpInvokerServiceExporter() { // $ Alert[java/unsafe-deserialization-spring-exporter-in-configuration-class] HttpInvokerServiceExporter exporter = new HttpInvokerServiceExporter(); exporter.setService(new AccountServiceImpl()); exporter.setServiceInterface(AccountService.class); diff --git a/java/ql/test/experimental/query-tests/security/CWE-502/UnsafeDeserializationRmi.java b/java/ql/test/experimental/query-tests/security/CWE-502/UnsafeDeserializationRmi.java index 197a1c47843..2f551e1205e 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-502/UnsafeDeserializationRmi.java +++ b/java/ql/test/experimental/query-tests/security/CWE-502/UnsafeDeserializationRmi.java @@ -12,9 +12,9 @@ public class UnsafeDeserializationRmi { // BAD (bind a remote object that has a vulnerable method) public static void testRegistryBindWithObjectParameter() throws Exception { Registry registry = LocateRegistry.createRegistry(1099); - registry.bind("unsafe", new UnsafeRemoteObjectImpl()); - registry.rebind("unsafe", new UnsafeRemoteObjectImpl()); - registry.rebind("unsafe", UnicastRemoteObject.exportObject(new UnsafeRemoteObjectImpl())); + registry.bind("unsafe", new UnsafeRemoteObjectImpl()); // $ Alert[java/unsafe-deserialization-rmi] + registry.rebind("unsafe", new UnsafeRemoteObjectImpl()); // $ Alert[java/unsafe-deserialization-rmi] + registry.rebind("unsafe", UnicastRemoteObject.exportObject(new UnsafeRemoteObjectImpl())); // $ Alert[java/unsafe-deserialization-rmi] } // GOOD (bind a remote object that has methods that takes safe parameters) @@ -26,8 +26,8 @@ public class UnsafeDeserializationRmi { // BAD (bind a remote object that has a vulnerable method) public static void testNamingBindWithObjectParameter() throws Exception { - Naming.bind("unsafe", new UnsafeRemoteObjectImpl()); - Naming.rebind("unsafe", new UnsafeRemoteObjectImpl()); + Naming.bind("unsafe", new UnsafeRemoteObjectImpl()); // $ Alert[java/unsafe-deserialization-rmi] + Naming.rebind("unsafe", new UnsafeRemoteObjectImpl()); // $ Alert[java/unsafe-deserialization-rmi] } // GOOD (bind a remote object that has methods that takes safe parameters) diff --git a/java/ql/test/experimental/query-tests/security/CWE-502/UnsafeDeserializationRmi.qlref b/java/ql/test/experimental/query-tests/security/CWE-502/UnsafeDeserializationRmi.qlref index f9691113cfa..711338908ee 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-502/UnsafeDeserializationRmi.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-502/UnsafeDeserializationRmi.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-502/UnsafeDeserializationRmi.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-502/UnsafeSpringExporterInConfigurationClass.qlref b/java/ql/test/experimental/query-tests/security/CWE-502/UnsafeSpringExporterInConfigurationClass.qlref index 823c7735ec5..e58985f0971 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-502/UnsafeSpringExporterInConfigurationClass.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-502/UnsafeSpringExporterInConfigurationClass.qlref @@ -1 +1,2 @@ -experimental/Security/CWE/CWE-502/UnsafeSpringExporterInConfigurationClass.ql \ No newline at end of file +query: experimental/Security/CWE/CWE-502/UnsafeSpringExporterInConfigurationClass.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-502/UnsafeSpringExporterInXMLConfiguration.qlref b/java/ql/test/experimental/query-tests/security/CWE-502/UnsafeSpringExporterInXMLConfiguration.qlref index 46024a0b6b3..4491a0d3225 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-502/UnsafeSpringExporterInXMLConfiguration.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-502/UnsafeSpringExporterInXMLConfiguration.qlref @@ -1 +1,2 @@ -experimental/Security/CWE/CWE-502/UnsafeSpringExporterInXMLConfiguration.ql \ No newline at end of file +query: experimental/Security/CWE/CWE-502/UnsafeSpringExporterInXMLConfiguration.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-502/beans.xml b/java/ql/test/experimental/query-tests/security/CWE-502/beans.xml index fbb936d901d..fc7536c7175 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-502/beans.xml +++ b/java/ql/test/experimental/query-tests/security/CWE-502/beans.xml @@ -10,21 +10,21 @@ - + - + - + - + diff --git a/java/ql/test/experimental/query-tests/security/CWE-548/InsecureDirectoryConfig.qlref b/java/ql/test/experimental/query-tests/security/CWE-548/InsecureDirectoryConfig.qlref index ead6d782be8..a6a93025c43 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-548/InsecureDirectoryConfig.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-548/InsecureDirectoryConfig.qlref @@ -1 +1,2 @@ -experimental/Security/CWE/CWE-548/InsecureDirectoryConfig.ql +query: experimental/Security/CWE/CWE-548/InsecureDirectoryConfig.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-548/insecure-web.xml b/java/ql/test/experimental/query-tests/security/CWE-548/insecure-web.xml index 346f98346b3..3e197e53fca 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-548/insecure-web.xml +++ b/java/ql/test/experimental/query-tests/security/CWE-548/insecure-web.xml @@ -16,7 +16,7 @@ listings true - + 1 @@ -26,4 +26,4 @@ / - \ No newline at end of file + diff --git a/java/ql/test/experimental/query-tests/security/CWE-555/PasswordInConfigurationFile.qlref b/java/ql/test/experimental/query-tests/security/CWE-555/PasswordInConfigurationFile.qlref index b996de13723..29138b5006d 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-555/PasswordInConfigurationFile.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-555/PasswordInConfigurationFile.qlref @@ -1 +1,2 @@ -experimental/Security/CWE/CWE-555/PasswordInConfigurationFile.ql +query: experimental/Security/CWE/CWE-555/PasswordInConfigurationFile.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-555/applicationContext.xml b/java/ql/test/experimental/query-tests/security/CWE-555/applicationContext.xml index 040c866759b..a4030150cb9 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-555/applicationContext.xml +++ b/java/ql/test/experimental/query-tests/security/CWE-555/applicationContext.xml @@ -6,7 +6,7 @@ - + diff --git a/java/ql/test/experimental/query-tests/security/CWE-555/context.xml b/java/ql/test/experimental/query-tests/security/CWE-555/context.xml index 6ea601bc6d7..f3e59bfcdb1 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-555/context.xml +++ b/java/ql/test/experimental/query-tests/security/CWE-555/context.xml @@ -5,7 +5,7 @@ maxTotal="100" maxIdle="30" maxWaitMillis="10000" username="root" password="1234" driverClassName="com.mysql.jdbc.Driver" - url="jdbc:mysql://www.example1.com:3306/proj"/> + url="jdbc:mysql://www.example1.com:3306/proj"/> - \ No newline at end of file + diff --git a/java/ql/test/experimental/query-tests/security/CWE-555/custom-config.xml b/java/ql/test/experimental/query-tests/security/CWE-555/custom-config.xml index 3569f0d09de..10ad6b30f7c 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-555/custom-config.xml +++ b/java/ql/test/experimental/query-tests/security/CWE-555/custom-config.xml @@ -1,4 +1,4 @@ - + diff --git a/java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery.java b/java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery.java index 2b7386bb600..d1a633be31c 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery.java +++ b/java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery.java @@ -9,13 +9,13 @@ public class SensitiveGetQuery extends HttpServlet { // BAD - Tests retrieving sensitive information through `request.getParameter()` in a GET request. public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String username = request.getParameter("username"); - String password = request.getParameter("password"); + String password = request.getParameter("password"); // $ Source - processUserInfo(username, password); + processUserInfo(username, password); // $ Alert } void processUserInfo(String username, String password) { - System.out.println("username = " + username+"; password "+password); + System.out.println("username = " + username+"; password "+password); // $ Alert } // GOOD - Tests retrieving sensitive information through `request.getParameter()` in a POST request. diff --git a/java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery.qlref b/java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery.qlref index 53c2523e041..20c3e79eb96 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-598/SensitiveGetQuery.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery2.java b/java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery2.java index 6b4fec0b331..97b929c792f 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery2.java +++ b/java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery2.java @@ -9,14 +9,14 @@ import javax.servlet.ServletException; public class SensitiveGetQuery2 extends HttpServlet { // BAD - Tests retrieving sensitive information through `request.getParameterMap()` in a GET request. public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - Map map = request.getParameterMap(); + Map map = request.getParameterMap(); // $ Source String username = (String) map.get("username"); String password = (String) map.get("password"); - processUserInfo(username, password); + processUserInfo(username, password); // $ Alert } void processUserInfo(String username, String password) { - System.out.println("username = " + username+"; password "+password); + System.out.println("username = " + username+"; password "+password); // $ Alert } // GOOD - Tests retrieving sensitive information through `request.getParameterMap()` in a POST request. diff --git a/java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery3.java b/java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery3.java index 5d191bb52b1..e34534236d0 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery3.java +++ b/java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery3.java @@ -10,11 +10,11 @@ public class SensitiveGetQuery3 extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String username = getRequestParameter(request, "username"); String password = getRequestParameter(request, "password"); - System.out.println("Username="+username+"; password="+password); + System.out.println("Username="+username+"; password="+password); // $ Alert } String getRequestParameter(HttpServletRequest request, String paramName) { - return request.getParameter(paramName); + return request.getParameter(paramName); // $ Source } // GOOD - Tests retrieving sensitive information through a wrapper call in a POST request. diff --git a/java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery4.java b/java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery4.java index 29e94d254d4..4f5399b9e10 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery4.java +++ b/java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery4.java @@ -13,11 +13,11 @@ public class SensitiveGetQuery4 extends HttpServlet { String tokenType = getRequestParameter(request, "tokenType"); String accessToken = getRequestParameter(request, "accessToken"); System.out.println("Username="+username+"; token="+token+"; tokenType="+tokenType); - System.out.println("AccessToken="+accessToken); + System.out.println("AccessToken="+accessToken); // $ Alert } String getRequestParameter(HttpServletRequest request, String paramName) { - return request.getParameter(paramName); + return request.getParameter(paramName); // $ Source } // GOOD - Tests retrieving non-sensitive tokens and sensitive tokens in a POST request. diff --git a/java/ql/test/experimental/query-tests/security/CWE-600/UncaughtServletException.java b/java/ql/test/experimental/query-tests/security/CWE-600/UncaughtServletException.java index 1e38c917b0f..63f19ef87a3 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-600/UncaughtServletException.java +++ b/java/ql/test/experimental/query-tests/security/CWE-600/UncaughtServletException.java @@ -10,11 +10,11 @@ import javax.servlet.ServletException; class UncaughtServletException extends HttpServlet { // BAD - Tests `doGet` without catching exceptions. public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - String ip = request.getParameter("srcIP"); - InetAddress addr = InetAddress.getByName(ip); // getByName(String) throws UnknownHostException + String ip = request.getParameter("srcIP"); // $ Source + InetAddress addr = InetAddress.getByName(ip); // $ Alert // getByName(String) throws UnknownHostException - String userId = request.getRemoteUser(); - Integer.parseInt(userId); // Integer.parse(String) throws RuntimeException + String userId = request.getRemoteUser(); // $ Source + Integer.parseInt(userId); // $ Alert // Integer.parse(String) throws RuntimeException } // GOOD - Tests `doPost` with catching exceptions. @@ -51,8 +51,8 @@ class UncaughtServletException extends HttpServlet { // BAD - Tests rethrowing caught exceptions with stack trace. public void doOptions(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { try { - String ip = request.getParameter("srcIP"); - InetAddress addr = InetAddress.getByName(ip); + String ip = request.getParameter("srcIP"); // $ Source + InetAddress addr = InetAddress.getByName(ip); // $ Alert } catch (UnknownHostException uhex) { uhex.printStackTrace(); throw uhex; @@ -72,8 +72,8 @@ class UncaughtServletException extends HttpServlet { try { addr = InetAddress.getByName(ip); - String userId = request.getRemoteUser(); - Integer.parseInt(userId); // Integer.parse(String) throws RuntimeException + String userId = request.getRemoteUser(); // $ Source + Integer.parseInt(userId); // $ Alert // Integer.parse(String) throws RuntimeException } catch (UnknownHostException uhex) { throw new UnknownHostException("Got exception "+uhex.getMessage()); } diff --git a/java/ql/test/experimental/query-tests/security/CWE-600/UncaughtServletException.qlref b/java/ql/test/experimental/query-tests/security/CWE-600/UncaughtServletException.qlref index 14466d983a7..11977e14ba2 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-600/UncaughtServletException.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-600/UncaughtServletException.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-600/UncaughtServletException.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-601/SpringUrlRedirect.java b/java/ql/test/experimental/query-tests/security/CWE-601/SpringUrlRedirect.java index e5909b3478e..a73f9c14249 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-601/SpringUrlRedirect.java +++ b/java/ql/test/experimental/query-tests/security/CWE-601/SpringUrlRedirect.java @@ -14,53 +14,53 @@ public class SpringUrlRedirect { private final static String VALID_REDIRECT = "http://127.0.0.1"; @GetMapping("url1") - public RedirectView bad1(String redirectUrl, HttpServletResponse response) throws Exception { + public RedirectView bad1(String redirectUrl, HttpServletResponse response) throws Exception { // $ Source RedirectView rv = new RedirectView(); - rv.setUrl(redirectUrl); + rv.setUrl(redirectUrl); // $ Alert return rv; } @GetMapping("url2") - public String bad2(String redirectUrl) { - String url = "redirect:" + redirectUrl; + public String bad2(String redirectUrl) { // $ Source + String url = "redirect:" + redirectUrl; // $ Alert return url; } @GetMapping("url3") - public RedirectView bad3(String redirectUrl) { - RedirectView rv = new RedirectView(redirectUrl); + public RedirectView bad3(String redirectUrl) { // $ Source + RedirectView rv = new RedirectView(redirectUrl); // $ Alert return rv; } @GetMapping("url4") - public ModelAndView bad4(String redirectUrl) { - return new ModelAndView("redirect:" + redirectUrl); + public ModelAndView bad4(String redirectUrl) { // $ Source + return new ModelAndView("redirect:" + redirectUrl); // $ Alert } @GetMapping("url5") - public String bad5(String redirectUrl) { + public String bad5(String redirectUrl) { // $ Source StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append("redirect:"); - stringBuffer.append(redirectUrl); + stringBuffer.append(redirectUrl); // $ Alert return stringBuffer.toString(); } @GetMapping("url6") - public String bad6(String redirectUrl) { + public String bad6(String redirectUrl) { // $ Source StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("redirect:"); - stringBuilder.append(redirectUrl); + stringBuilder.append(redirectUrl); // $ Alert return stringBuilder.toString(); } @GetMapping("url7") - public String bad7(String redirectUrl) { - return "redirect:" + String.format("%s/?aaa", redirectUrl); + public String bad7(String redirectUrl) { // $ Source + return "redirect:" + String.format("%s/?aaa", redirectUrl); // $ Alert } @GetMapping("url8") - public String bad8(String redirectUrl, String token) { - return "redirect:" + String.format(redirectUrl + "?token=%s", token); + public String bad8(String redirectUrl, String token) { // $ Source + return "redirect:" + String.format(redirectUrl + "?token=%s", token); // $ Alert } @GetMapping("url9") @@ -86,49 +86,49 @@ public class SpringUrlRedirect { } @GetMapping("url12") - public ResponseEntity bad9(String redirectUrl) { + public ResponseEntity bad9(String redirectUrl) { // $ Source return ResponseEntity.status(HttpStatus.FOUND) - .location(URI.create(redirectUrl)) + .location(URI.create(redirectUrl)) // $ Alert .build(); } @GetMapping("url13") - public ResponseEntity bad10(String redirectUrl) { + public ResponseEntity bad10(String redirectUrl) { // $ Source HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.setLocation(URI.create(redirectUrl)); - return new ResponseEntity<>(httpHeaders, HttpStatus.SEE_OTHER); + return new ResponseEntity<>(httpHeaders, HttpStatus.SEE_OTHER); // $ Alert } @GetMapping("url14") - public ResponseEntity bad11(String redirectUrl) { + public ResponseEntity bad11(String redirectUrl) { // $ Source HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.add("Location", redirectUrl); - return ResponseEntity.status(HttpStatus.SEE_OTHER).headers(httpHeaders).build(); + return ResponseEntity.status(HttpStatus.SEE_OTHER).headers(httpHeaders).build(); // $ Alert } @GetMapping("url15") - public ResponseEntity bad12(String redirectUrl) { + public ResponseEntity bad12(String redirectUrl) { // $ Source HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.add("Location", redirectUrl); - return new ResponseEntity<>(httpHeaders, HttpStatus.SEE_OTHER); + return new ResponseEntity<>(httpHeaders, HttpStatus.SEE_OTHER); // $ Alert } @GetMapping("url16") - public ResponseEntity bad13(String redirectUrl) { + public ResponseEntity bad13(String redirectUrl) { // $ Source HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.add("Location", redirectUrl); - return new ResponseEntity<>("TestBody", httpHeaders, HttpStatus.SEE_OTHER); + return new ResponseEntity<>("TestBody", httpHeaders, HttpStatus.SEE_OTHER); // $ Alert } @GetMapping("url17") - public ResponseEntity bad14(String redirectUrl) { + public ResponseEntity bad14(String redirectUrl) { // $ Source HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.setLocation(URI.create(redirectUrl)); - return new ResponseEntity<>("TestBody", httpHeaders, HttpStatus.SEE_OTHER); + return new ResponseEntity<>("TestBody", httpHeaders, HttpStatus.SEE_OTHER); // $ Alert } } diff --git a/java/ql/test/experimental/query-tests/security/CWE-601/SpringUrlRedirect.qlref b/java/ql/test/experimental/query-tests/security/CWE-601/SpringUrlRedirect.qlref index 3c1c8a42a95..62384d5e430 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-601/SpringUrlRedirect.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-601/SpringUrlRedirect.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-601/SpringUrlRedirect.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-625/DotRegexFilter.java b/java/ql/test/experimental/query-tests/security/CWE-625/DotRegexFilter.java index 6ce97453d8f..28583c0ecb3 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-625/DotRegexFilter.java +++ b/java/ql/test/experimental/query-tests/security/CWE-625/DotRegexFilter.java @@ -26,10 +26,10 @@ public class DotRegexFilter implements Filter { public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; - String source = httpRequest.getPathInfo(); + String source = httpRequest.getPathInfo(); // $ Source Pattern p = Pattern.compile(PROTECTED_PATTERN); - Matcher m = p.matcher(source); + Matcher m = p.matcher(source); // $ Alert if (m.matches()) { // Protected page - check access token and redirect to login page @@ -67,4 +67,4 @@ public class DotRegexFilter implements Filter { public void destroy() { // Close resources } -} \ No newline at end of file +} diff --git a/java/ql/test/experimental/query-tests/security/CWE-625/DotRegexServlet.java b/java/ql/test/experimental/query-tests/security/CWE-625/DotRegexServlet.java index 47d3175afcf..c2d50a50d71 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-625/DotRegexServlet.java +++ b/java/ql/test/experimental/query-tests/security/CWE-625/DotRegexServlet.java @@ -16,10 +16,10 @@ public class DotRegexServlet extends HttpServlet { // BAD: A string with line return e.g. `/protected/%0dxyz` can bypass the path check protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - String source = request.getPathInfo(); + String source = request.getPathInfo(); // $ Source Pattern p = Pattern.compile(PROTECTED_PATTERN); - Matcher m = p.matcher(source); + Matcher m = p.matcher(source); // $ Alert if (m.matches()) { // Protected page - check access token and redirect to login page @@ -54,9 +54,9 @@ public class DotRegexServlet extends HttpServlet { // BAD: A string with line return e.g. `/protected/%0axyz` can bypass the path check protected void doGet3(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - String source = request.getRequestURI(); + String source = request.getRequestURI(); // $ Source - boolean matches = source.matches(PROTECTED_PATTERN); + boolean matches = source.matches(PROTECTED_PATTERN); // $ Alert if (matches) { // Protected page - check access token and redirect to login page @@ -72,9 +72,9 @@ public class DotRegexServlet extends HttpServlet { // BAD: A string with line return e.g. `/protected/%0axyz` can bypass the path check protected void doGet4(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - String source = request.getPathInfo(); + String source = request.getPathInfo(); // $ Source - boolean matches = Pattern.matches(PROTECTED_PATTERN, source); + boolean matches = Pattern.matches(PROTECTED_PATTERN, source); // $ Alert if (matches) { // Protected page - check access token and redirect to login page @@ -109,10 +109,10 @@ public class DotRegexServlet extends HttpServlet { // BAD: A string with line return e.g. `/protected/%0dxyz` can bypass the path check protected void doGet6(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - String source = request.getPathInfo(); + String source = request.getPathInfo(); // $ Source Pattern p = Pattern.compile(PROTECTED_PATTERN); - Matcher m = p.matcher(source); + Matcher m = p.matcher(source); // $ Alert if (m.matches()) { // Protected page - check access token and redirect to login page diff --git a/java/ql/test/experimental/query-tests/security/CWE-625/DotRegexSpring.java b/java/ql/test/experimental/query-tests/security/CWE-625/DotRegexSpring.java index 4651508fe19..196a305b086 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-625/DotRegexSpring.java +++ b/java/ql/test/experimental/query-tests/security/CWE-625/DotRegexSpring.java @@ -17,10 +17,10 @@ public class DotRegexSpring { @GetMapping("param") // BAD: A string with line return e.g. `/protected/%0dxyz` can bypass the path check - public String withParam(@RequestParam String path, Model model) throws UnsupportedEncodingException { + public String withParam(@RequestParam String path, Model model) throws UnsupportedEncodingException { // $ Source Pattern p = Pattern.compile(PROTECTED_PATTERN); path = decodePath(path); - Matcher m = p.matcher(path); + Matcher m = p.matcher(path); // $ Alert if (m.matches()) { // Protected page - check access token and redirect to login page @@ -34,10 +34,10 @@ public class DotRegexSpring { @GetMapping("{path}") // BAD: A string with line return e.g. `%252Fprotected%252F%250dxyz` can bypass the path check - public RedirectView withPathVariable1(@PathVariable String path, Model model) throws UnsupportedEncodingException { + public RedirectView withPathVariable1(@PathVariable String path, Model model) throws UnsupportedEncodingException { // $ Source Pattern p = Pattern.compile(PROTECTED_PATTERN); path = decodePath(path); - Matcher m = p.matcher(path); + Matcher m = p.matcher(path); // $ Alert if (m.matches()) { // Protected page - check access token and redirect to login page diff --git a/java/ql/test/experimental/query-tests/security/CWE-625/PermissiveDotRegex.qlref b/java/ql/test/experimental/query-tests/security/CWE-625/PermissiveDotRegex.qlref index 67382a5e297..b4a93ae73f2 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-625/PermissiveDotRegex.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-625/PermissiveDotRegex.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-625/PermissiveDotRegex.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-652/XQueryInjection.java b/java/ql/test/experimental/query-tests/security/CWE-652/XQueryInjection.java index d8df8057cc6..5dccb7dbe22 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-652/XQueryInjection.java +++ b/java/ql/test/experimental/query-tests/security/CWE-652/XQueryInjection.java @@ -42,13 +42,13 @@ public class XQueryInjection { @RequestMapping public void testRequestbad(HttpServletRequest request) throws Exception { - String name = request.getParameter("name"); + String name = request.getParameter("name"); // $ Source XQDataSource ds = new SaxonXQDataSource(); XQConnection conn = ds.getConnection(); String query = "for $user in doc(\"users.xml\")/Users/User[name='" + name + "'] return $user/password"; XQPreparedExpression xqpe = conn.prepareExpression(query); - XQResultSequence result = xqpe.executeQuery(); + XQResultSequence result = xqpe.executeQuery(); // $ Alert while (result.next()) { System.out.println(result.getItemAsString(null)); } @@ -56,13 +56,13 @@ public class XQueryInjection { @RequestMapping public void testRequestbad1(HttpServletRequest request) throws Exception { - String name = request.getParameter("name"); + String name = request.getParameter("name"); // $ Source XQDataSource xqds = new SaxonXQDataSource(); String query = "for $user in doc(\"users.xml\")/Users/User[name='" + name + "'] return $user/password"; XQConnection conn = xqds.getConnection(); XQExpression expr = conn.createExpression(); - XQResultSequence result = expr.executeQuery(query); + XQResultSequence result = expr.executeQuery(query); // $ Alert while (result.next()) { System.out.println(result.getItemAsString(null)); } @@ -70,26 +70,26 @@ public class XQueryInjection { @RequestMapping - public void testStringtbad(@RequestParam String nameStr) throws XQException { + public void testStringtbad(@RequestParam String nameStr) throws XQException { // $ Source XQDataSource ds = new SaxonXQDataSource(); XQConnection conn = ds.getConnection(); String query = "for $user in doc(\"users.xml\")/Users/User[name='" + nameStr + "'] return $user/password"; XQPreparedExpression xqpe = conn.prepareExpression(query); - XQResultSequence result = xqpe.executeQuery(); + XQResultSequence result = xqpe.executeQuery(); // $ Alert while (result.next()) { System.out.println(result.getItemAsString(null)); } } @RequestMapping - public void testStringtbad1(@RequestParam String nameStr) throws XQException { + public void testStringtbad1(@RequestParam String nameStr) throws XQException { // $ Source XQDataSource xqds = new SaxonXQDataSource(); String query = "for $user in doc(\"users.xml\")/Users/User[name='" + nameStr + "'] return $user/password"; XQConnection conn = xqds.getConnection(); XQExpression expr = conn.createExpression(); - XQResultSequence result = expr.executeQuery(query); + XQResultSequence result = expr.executeQuery(query); // $ Alert while (result.next()) { System.out.println(result.getItemAsString(null)); } @@ -97,11 +97,11 @@ public class XQueryInjection { @RequestMapping public void testInputStreambad(HttpServletRequest request) throws Exception { - InputStream name = request.getInputStream(); + InputStream name = request.getInputStream(); // $ Source XQDataSource ds = new SaxonXQDataSource(); XQConnection conn = ds.getConnection(); XQPreparedExpression xqpe = conn.prepareExpression(name); - XQResultSequence result = xqpe.executeQuery(); + XQResultSequence result = xqpe.executeQuery(); // $ Alert while (result.next()) { System.out.println(result.getItemAsString(null)); } @@ -109,11 +109,11 @@ public class XQueryInjection { @RequestMapping public void testInputStreambad1(HttpServletRequest request) throws Exception { - InputStream name = request.getInputStream(); + InputStream name = request.getInputStream(); // $ Source XQDataSource xqds = new SaxonXQDataSource(); XQConnection conn = xqds.getConnection(); XQExpression expr = conn.createExpression(); - XQResultSequence result = expr.executeQuery(name); + XQResultSequence result = expr.executeQuery(name); // $ Alert while (result.next()) { System.out.println(result.getItemAsString(null)); } @@ -121,12 +121,12 @@ public class XQueryInjection { @RequestMapping public void testReaderbad(HttpServletRequest request) throws Exception { - InputStream name = request.getInputStream(); + InputStream name = request.getInputStream(); // $ Source BufferedReader br = new BufferedReader(new InputStreamReader(name)); XQDataSource ds = new SaxonXQDataSource(); XQConnection conn = ds.getConnection(); XQPreparedExpression xqpe = conn.prepareExpression(br); - XQResultSequence result = xqpe.executeQuery(); + XQResultSequence result = xqpe.executeQuery(); // $ Alert while (result.next()) { System.out.println(result.getItemAsString(null)); } @@ -134,12 +134,12 @@ public class XQueryInjection { @RequestMapping public void testReaderbad1(HttpServletRequest request) throws Exception { - InputStream name = request.getInputStream(); + InputStream name = request.getInputStream(); // $ Source BufferedReader br = new BufferedReader(new InputStreamReader(name)); XQDataSource xqds = new SaxonXQDataSource(); XQConnection conn = xqds.getConnection(); XQExpression expr = conn.createExpression(); - XQResultSequence result = expr.executeQuery(br); + XQResultSequence result = expr.executeQuery(br); // $ Alert while (result.next()) { System.out.println(result.getItemAsString(null)); } @@ -147,16 +147,16 @@ public class XQueryInjection { @RequestMapping public void testExecuteCommandbad(HttpServletRequest request) throws Exception { - String name = request.getParameter("name"); + String name = request.getParameter("name"); // $ Source XQDataSource xqds = new SaxonXQDataSource(); XQConnection conn = xqds.getConnection(); XQExpression expr = conn.createExpression(); //bad code - expr.executeCommand(name); + expr.executeCommand(name); // $ Alert //bad code - InputStream is = request.getInputStream(); + InputStream is = request.getInputStream(); // $ Source BufferedReader br = new BufferedReader(new InputStreamReader(is)); - expr.executeCommand(br); + expr.executeCommand(br); // $ Alert expr.close(); } diff --git a/java/ql/test/experimental/query-tests/security/CWE-652/XQueryInjection.qlref b/java/ql/test/experimental/query-tests/security/CWE-652/XQueryInjection.qlref index df94ae95807..a998a694ade 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-652/XQueryInjection.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-652/XQueryInjection.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-652/XQueryInjection.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-665/InsecureRmiJmxEnvironmentConfiguration.java b/java/ql/test/experimental/query-tests/security/CWE-665/InsecureRmiJmxEnvironmentConfiguration.java index f1294847fcc..b631e7c6cca 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-665/InsecureRmiJmxEnvironmentConfiguration.java +++ b/java/ql/test/experimental/query-tests/security/CWE-665/InsecureRmiJmxEnvironmentConfiguration.java @@ -9,12 +9,12 @@ public class InsecureRmiJmxEnvironmentConfiguration { public void initInsecureJmxDueToNullEnv() throws IOException { // Bad initializing env (arg1) with null - JMXConnectorServerFactory.newJMXConnectorServer(null, null, null); + JMXConnectorServerFactory.newJMXConnectorServer(null, null, null); // $ Alert } public void initInsecureRmiDueToNullEnv() throws IOException { // Bad initializing env (arg1) with null - new RMIConnectorServer(null, null, null, null); + new RMIConnectorServer(null, null, null, null); // $ Alert } public void initInsecureRmiDueToMissingEnvKeyValue() throws IOException { @@ -22,7 +22,7 @@ public class InsecureRmiJmxEnvironmentConfiguration { // "jmx.remote.rmi.server.credential.types" Map env = new HashMap<>(); env.put("jmx.remote.x.daemon", "true"); - new RMIConnectorServer(null, env, null, null); + new RMIConnectorServer(null, env, null, null); // $ Alert } public void initInsecureJmxDueToMissingEnvKeyValue() throws IOException { @@ -30,7 +30,7 @@ public class InsecureRmiJmxEnvironmentConfiguration { // "jmx.remote.rmi.server.credential.types" Map env = new HashMap<>(); env.put("jmx.remote.x.daemon", "true"); - JMXConnectorServerFactory.newJMXConnectorServer(null, env, null); + JMXConnectorServerFactory.newJMXConnectorServer(null, env, null); // $ Alert } public void secureJmxConnnectorServer() throws IOException { diff --git a/java/ql/test/experimental/query-tests/security/CWE-665/InsecureRmiJmxEnvironmentConfiguration.qlref b/java/ql/test/experimental/query-tests/security/CWE-665/InsecureRmiJmxEnvironmentConfiguration.qlref index de4b6744533..3b1127b4695 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-665/InsecureRmiJmxEnvironmentConfiguration.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-665/InsecureRmiJmxEnvironmentConfiguration.qlref @@ -1 +1,2 @@ -experimental/Security/CWE/CWE-665/InsecureRmiJmxEnvironmentConfiguration.ql \ No newline at end of file +query: experimental/Security/CWE/CWE-665/InsecureRmiJmxEnvironmentConfiguration.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-755/NFEAndroidDoS.java b/java/ql/test/experimental/query-tests/security/CWE-755/NFEAndroidDoS.java index bf527f04fe1..9ceefd5a388 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-755/NFEAndroidDoS.java +++ b/java/ql/test/experimental/query-tests/security/CWE-755/NFEAndroidDoS.java @@ -10,8 +10,8 @@ public class NFEAndroidDoS extends Activity { super.onCreate(savedInstanceState); setContentView(-1); - String minPriceStr = getIntent().getStringExtra("priceMin"); - double minPrice = Double.parseDouble(minPriceStr); + String minPriceStr = getIntent().getStringExtra("priceMin"); // $ Source + double minPrice = Double.parseDouble(minPriceStr); // $ Alert } // BAD - parse string extra to integer @@ -19,11 +19,11 @@ public class NFEAndroidDoS extends Activity { super.onCreate(savedInstanceState); setContentView(-1); - String widthStr = getIntent().getStringExtra("width"); - int width = Integer.parseInt(widthStr); + String widthStr = getIntent().getStringExtra("width"); // $ Source + int width = Integer.parseInt(widthStr); // $ Alert - String heightStr = getIntent().getStringExtra("height"); - int height = Integer.parseInt(heightStr); + String heightStr = getIntent().getStringExtra("height"); // $ Source + int height = Integer.parseInt(heightStr); // $ Alert } // GOOD - parse int extra to integer @@ -40,11 +40,11 @@ public class NFEAndroidDoS extends Activity { super.onCreate(savedInstanceState); setContentView(-1); - String minPriceStr = getIntent().getStringExtra("priceMin"); - double minPrice = new Double(minPriceStr); + String minPriceStr = getIntent().getStringExtra("priceMin"); // $ Source + double minPrice = new Double(minPriceStr); // $ Alert String maxPriceStr = getIntent().getStringExtra("priceMax"); - double maxPrice = Double.valueOf(minPriceStr); + double maxPrice = Double.valueOf(minPriceStr); // $ Alert } // GOOD - parse string extra to double with caught NFE @@ -83,4 +83,4 @@ public class NFEAndroidDoS extends Activity { double priceMin = IntentUtils.getDoubleExtra(this, "priceMin"); } -} \ No newline at end of file +} diff --git a/java/ql/test/experimental/query-tests/security/CWE-755/NFEAndroidDoS.qlref b/java/ql/test/experimental/query-tests/security/CWE-755/NFEAndroidDoS.qlref index 17bd71ea68a..9e538d9fd8a 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-755/NFEAndroidDoS.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-755/NFEAndroidDoS.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-755/NFEAndroidDoS.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/experimental/query-tests/security/CWE-759/HashWithoutSalt.java b/java/ql/test/experimental/query-tests/security/CWE-759/HashWithoutSalt.java index 48911486db1..ba482a503e7 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-759/HashWithoutSalt.java +++ b/java/ql/test/experimental/query-tests/security/CWE-759/HashWithoutSalt.java @@ -7,7 +7,7 @@ public class HashWithoutSalt { // BAD - Hash without a salt. public String getSHA256Hash(String password) throws NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance("SHA-256"); - byte[] messageDigest = md.digest(password.getBytes()); + byte[] messageDigest = md.digest(password.getBytes()); // $ Alert return Base64.getEncoder().encodeToString(messageDigest); } @@ -22,7 +22,7 @@ public class HashWithoutSalt { // BAD - Hash without a salt. public String getSHA256Hash2(String password) throws NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance("SHA-256"); - md.update(password.getBytes()); + md.update(password.getBytes()); // $ Alert byte[] messageDigest = md.digest(); return Base64.getEncoder().encodeToString(messageDigest); } @@ -90,8 +90,8 @@ public class HashWithoutSalt { // BAD - Invoking a wrapper implementation through qualifier without a salt. public String getWrapperSHA256Hash2(String password) throws NoSuchAlgorithmException, ClassNotFoundException, IllegalAccessException, InstantiationException { SHA256 sha256 = new SHA256(); - byte[] passBytes = password.getBytes(); - sha256.update(passBytes, 0, passBytes.length); + byte[] passBytes = password.getBytes(); // $ Source + sha256.update(passBytes, 0, passBytes.length); // $ Alert return Base64.getEncoder().encodeToString(sha256.digest()); } @@ -108,8 +108,8 @@ public class HashWithoutSalt { // BAD - Invoking a wrapper implementation through argument without a salt. public String getWrapperSHA256Hash4(String password) throws NoSuchAlgorithmException { SHA256 sha256 = new SHA256(); - byte[] passBytes = password.getBytes(); - update(sha256, passBytes, 0, passBytes.length); + byte[] passBytes = password.getBytes(); // $ Source + update(sha256, passBytes, 0, passBytes.length); // $ Alert return Base64.getEncoder().encodeToString(sha256.digest()); } diff --git a/java/ql/test/experimental/query-tests/security/CWE-759/HashWithoutSalt.qlref b/java/ql/test/experimental/query-tests/security/CWE-759/HashWithoutSalt.qlref index b2f767ca66a..186b2833671 100644 --- a/java/ql/test/experimental/query-tests/security/CWE-759/HashWithoutSalt.qlref +++ b/java/ql/test/experimental/query-tests/security/CWE-759/HashWithoutSalt.qlref @@ -1,2 +1,4 @@ query: experimental/Security/CWE/CWE-759/HashWithoutSalt.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/library-tests/frameworks/JaxWs/UrlRedirect.qlref b/java/ql/test/library-tests/frameworks/JaxWs/UrlRedirect.qlref index 933c3569eed..f41f720f725 100644 --- a/java/ql/test/library-tests/frameworks/JaxWs/UrlRedirect.qlref +++ b/java/ql/test/library-tests/frameworks/JaxWs/UrlRedirect.qlref @@ -1,2 +1,4 @@ query: Security/CWE/CWE-601/UrlRedirect.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/library-tests/frameworks/JaxWs/UrlRedirectJakarta.java b/java/ql/test/library-tests/frameworks/JaxWs/UrlRedirectJakarta.java index 897ee7890bd..263472d3fc5 100644 --- a/java/ql/test/library-tests/frameworks/JaxWs/UrlRedirectJakarta.java +++ b/java/ql/test/library-tests/frameworks/JaxWs/UrlRedirectJakarta.java @@ -7,9 +7,9 @@ import jakarta.ws.rs.core.Response; public class UrlRedirectJakarta extends HttpServlet { protected void doGetJax(HttpServletRequest request, Response jaxResponse) throws Exception { // BAD - jaxResponse.seeOther(new URI(request.getParameter("target"))); + jaxResponse.seeOther(new URI(request.getParameter("target"))); // $ Alert[java/unvalidated-url-redirection] // BAD - jaxResponse.temporaryRedirect(new URI(request.getParameter("target"))); + jaxResponse.temporaryRedirect(new URI(request.getParameter("target"))); // $ Alert[java/unvalidated-url-redirection] } } diff --git a/java/ql/test/library-tests/frameworks/JaxWs/UrlRedirectJax.java b/java/ql/test/library-tests/frameworks/JaxWs/UrlRedirectJax.java index 4ba3d1f1331..a757351a93c 100644 --- a/java/ql/test/library-tests/frameworks/JaxWs/UrlRedirectJax.java +++ b/java/ql/test/library-tests/frameworks/JaxWs/UrlRedirectJax.java @@ -7,9 +7,9 @@ import javax.ws.rs.core.Response; public class UrlRedirectJax extends HttpServlet { protected void doGetJax(HttpServletRequest request, Response jaxResponse) throws Exception { // BAD - jaxResponse.seeOther(new URI(request.getParameter("target"))); + jaxResponse.seeOther(new URI(request.getParameter("target"))); // $ Alert[java/unvalidated-url-redirection] // BAD - jaxResponse.temporaryRedirect(new URI(request.getParameter("target"))); + jaxResponse.temporaryRedirect(new URI(request.getParameter("target"))); // $ Alert[java/unvalidated-url-redirection] } } diff --git a/java/ql/test/query-tests/AmbiguousOuterSuper/AmbiguousOuterSuper.qlref b/java/ql/test/query-tests/AmbiguousOuterSuper/AmbiguousOuterSuper.qlref index 70c62b8c851..add5a9dc533 100644 --- a/java/ql/test/query-tests/AmbiguousOuterSuper/AmbiguousOuterSuper.qlref +++ b/java/ql/test/query-tests/AmbiguousOuterSuper/AmbiguousOuterSuper.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Naming Conventions/AmbiguousOuterSuper.ql \ No newline at end of file +query: Violations of Best Practice/Naming Conventions/AmbiguousOuterSuper.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/AmbiguousOuterSuper/GenericTest.java b/java/ql/test/query-tests/AmbiguousOuterSuper/GenericTest.java index f0d14dc4867..b35ac02925c 100644 --- a/java/ql/test/query-tests/AmbiguousOuterSuper/GenericTest.java +++ b/java/ql/test/query-tests/AmbiguousOuterSuper/GenericTest.java @@ -11,7 +11,7 @@ class Outer2 { class Inner extends GenericTest { public void test() { - f(); + f(); // $ Alert } } diff --git a/java/ql/test/query-tests/AmbiguousOuterSuper/Test.java b/java/ql/test/query-tests/AmbiguousOuterSuper/Test.java index e2a506f1438..875b4f7bbe9 100644 --- a/java/ql/test/query-tests/AmbiguousOuterSuper/Test.java +++ b/java/ql/test/query-tests/AmbiguousOuterSuper/Test.java @@ -11,7 +11,7 @@ class Outer { class Inner extends Test { public void test() { - f(); + f(); // $ Alert } } diff --git a/java/ql/test/query-tests/AutoBoxing/AutoBoxing.qlref b/java/ql/test/query-tests/AutoBoxing/AutoBoxing.qlref index f116f3bd8b4..dc47875616d 100644 --- a/java/ql/test/query-tests/AutoBoxing/AutoBoxing.qlref +++ b/java/ql/test/query-tests/AutoBoxing/AutoBoxing.qlref @@ -1 +1,2 @@ -Violations of Best Practice/legacy/AutoBoxing.ql +query: Violations of Best Practice/legacy/AutoBoxing.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/AutoBoxing/Test.java b/java/ql/test/query-tests/AutoBoxing/Test.java index 49c12f0c521..300a82a9a57 100644 --- a/java/ql/test/query-tests/AutoBoxing/Test.java +++ b/java/ql/test/query-tests/AutoBoxing/Test.java @@ -1,19 +1,19 @@ class Test { void unbox(Integer i, Boolean b) { // NOT OK - int j = i + 19; + int j = i + 19; // $ Alert // OK if (i == null); // NOT OK - if (i == 42); + if (i == 42); // $ Alert // NOT OK - j += i; + j += i; // $ Alert // NOT OK - int k = i; + int k = i; // $ Alert // NOT OK - bar(b); + bar(b); // $ Alert // NOT OK - int l = i == null ? 0 : i; + int l = i == null ? 0 : i; // $ Alert } void bar(boolean b) {} @@ -21,15 +21,15 @@ class Test { Integer box(int i) { Integer[] is = new Integer[1]; // NOT OK - is[0] = i; + is[0] = i; // $ Alert // NOT OK - Integer j = i; + Integer j = i; // $ Alert // NOT OK - return i == -1 ? null : i; + return i == -1 ? null : i; // $ Alert } void rebox(Integer i) { // NOT OK - i += 19; + i += 19; // $ Alert } -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/AvoidDeprecatedCallableAccess/AvoidDeprecatedCallableAccess.qlref b/java/ql/test/query-tests/AvoidDeprecatedCallableAccess/AvoidDeprecatedCallableAccess.qlref index 58c139046f3..1277deb8a54 100644 --- a/java/ql/test/query-tests/AvoidDeprecatedCallableAccess/AvoidDeprecatedCallableAccess.qlref +++ b/java/ql/test/query-tests/AvoidDeprecatedCallableAccess/AvoidDeprecatedCallableAccess.qlref @@ -1 +1,2 @@ -Advisory/Deprecated Code/AvoidDeprecatedCallableAccess.ql \ No newline at end of file +query: Advisory/Deprecated Code/AvoidDeprecatedCallableAccess.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/AvoidDeprecatedCallableAccess/Test.java b/java/ql/test/query-tests/AvoidDeprecatedCallableAccess/Test.java index 8f4b55c861d..b9095a1fa70 100644 --- a/java/ql/test/query-tests/AvoidDeprecatedCallableAccess/Test.java +++ b/java/ql/test/query-tests/AvoidDeprecatedCallableAccess/Test.java @@ -10,11 +10,11 @@ public class Test { { // NOT OK - m(); + m(); // $ Alert } public static void main(String[] args) { // NOT OK - new Test().n(); + new Test().n(); // $ Alert } -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/BadAbsOfRandom/BadAbsOfRandom.qlref b/java/ql/test/query-tests/BadAbsOfRandom/BadAbsOfRandom.qlref index b6bbc44bfa0..2fa4288992a 100644 --- a/java/ql/test/query-tests/BadAbsOfRandom/BadAbsOfRandom.qlref +++ b/java/ql/test/query-tests/BadAbsOfRandom/BadAbsOfRandom.qlref @@ -1 +1,2 @@ -Likely Bugs/Arithmetic/BadAbsOfRandom.ql +query: Likely Bugs/Arithmetic/BadAbsOfRandom.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/BadAbsOfRandom/Test.java b/java/ql/test/query-tests/BadAbsOfRandom/Test.java index a01f13c7a82..1be16ed7368 100644 --- a/java/ql/test/query-tests/BadAbsOfRandom/Test.java +++ b/java/ql/test/query-tests/BadAbsOfRandom/Test.java @@ -7,18 +7,18 @@ public class Test { public static void test() { Random r = new Random(); - Math.abs(r.nextInt()); - Math.abs(r.nextLong()); + Math.abs(r.nextInt()); // $ Alert + Math.abs(r.nextLong()); // $ Alert Math.abs(r.nextInt(100)); // GOOD: random value already has a restricted range - Math.abs(RandomUtils.nextInt()); - Math.abs(RandomUtils.nextLong()); + Math.abs(RandomUtils.nextInt()); // $ Alert + Math.abs(RandomUtils.nextLong()); // $ Alert Math.abs(RandomUtils.nextInt(1, 10)); // GOOD: random value already has a restricted range Math.abs(RandomUtils.nextLong(1, 10)); // GOOD: random value already has a restricted range ThreadLocalRandom tlr = ThreadLocalRandom.current(); - Math.abs(tlr.nextInt()); - Math.abs(tlr.nextLong()); + Math.abs(tlr.nextInt()); // $ Alert + Math.abs(tlr.nextLong()); // $ Alert Math.abs(tlr.nextInt(10)); // GOOD: random value already has a restricted range Math.abs(tlr.nextLong(10)); // GOOD: random value already has a restricted range Math.abs(tlr.nextInt(1, 10)); // GOOD: random value already has a restricted range diff --git a/java/ql/test/query-tests/BadCheckOdd/BadCheckOdd.java b/java/ql/test/query-tests/BadCheckOdd/BadCheckOdd.java index a1f7e950502..f76b5b535fe 100644 --- a/java/ql/test/query-tests/BadCheckOdd/BadCheckOdd.java +++ b/java/ql/test/query-tests/BadCheckOdd/BadCheckOdd.java @@ -7,23 +7,23 @@ class BadCheckOdd { } public boolean badLiteral() { - return -10 % 2 > 0; + return -10 % 2 > 0; // $ Alert } public boolean badBrackets1() { - return -10 % 2 > (0); + return -10 % 2 > (0); // $ Alert } public boolean badBrackets2() { - return -10 % (2) > 0;// + return -10 % (2) > 0;// $ Alert // } public boolean badBrackets3() { - return (-10) % 2 > 0; + return (-10) % 2 > 0; // $ Alert } public boolean badBrackets4() { - return (-10 % 2) > 0; + return (-10 % 2) > 0; // $ Alert } // TODO: support for these cases @@ -47,11 +47,11 @@ class BadCheckOdd { public boolean badVarLiteral() { int x = -10; - return x % 2 > 0; + return x % 2 > 0; // $ Alert } public boolean badParam(int x) { - return x % 2 > 0; + return x % 2 > 0; // $ Alert } public boolean badSometimes(boolean positive) { @@ -60,11 +60,11 @@ class BadCheckOdd { x = 10; else x = -10; - return x % 2 > 0; + return x % 2 > 0; // $ Alert } private int f; public boolean badField() { - return f % 2 >0; + return f % 2 >0; // $ Alert } -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/BadCheckOdd/BadCheckOdd.qlref b/java/ql/test/query-tests/BadCheckOdd/BadCheckOdd.qlref index 486707e04c1..544f107b3ff 100644 --- a/java/ql/test/query-tests/BadCheckOdd/BadCheckOdd.qlref +++ b/java/ql/test/query-tests/BadCheckOdd/BadCheckOdd.qlref @@ -1 +1,2 @@ -Likely Bugs/Arithmetic/BadCheckOdd.ql \ No newline at end of file +query: Likely Bugs/Arithmetic/BadCheckOdd.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/BoxedVariable/BoxedVariable.java b/java/ql/test/query-tests/BoxedVariable/BoxedVariable.java index 948f0942af7..3f0f8ff8a44 100644 --- a/java/ql/test/query-tests/BoxedVariable/BoxedVariable.java +++ b/java/ql/test/query-tests/BoxedVariable/BoxedVariable.java @@ -2,12 +2,12 @@ import java.util.*; class Test { public void f() { - Boolean done = false; // bad + Boolean done = false; // $ Alert // bad while (!done) { done = true; } - Integer sum = 0; // bad + Integer sum = 0; // $ Alert // bad for (int i = 0; i < 10; i++) sum += i; useBoxed(sum); @@ -15,7 +15,7 @@ class Test { Integer box = 42; // ok; only boxed usages useBoxed(box); - Integer badbox = 17; // bad + Integer badbox = 17; // $ Alert // bad useBoxed(badbox); usePrim(badbox); @@ -23,7 +23,7 @@ class Test { usePrim(x); x = null; - Long y = getPrim(); // bad + Long y = getPrim(); // $ Alert // bad y = 15L; y = getPrim(); boolean dummy = y > 0; @@ -39,7 +39,7 @@ class Test { for (Integer okix : l) sum += okix; // ok; has boxed assignment - for (Integer badix : a) sum += badix; // bad + for (Integer badix : a) sum += badix; // $ Alert // bad } void usePrim(int i) { } diff --git a/java/ql/test/query-tests/BoxedVariable/BoxedVariable.qlref b/java/ql/test/query-tests/BoxedVariable/BoxedVariable.qlref index 3b9bd6efc7e..d7c4d286236 100644 --- a/java/ql/test/query-tests/BoxedVariable/BoxedVariable.qlref +++ b/java/ql/test/query-tests/BoxedVariable/BoxedVariable.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Boxed Types/BoxedVariable.ql +query: Violations of Best Practice/Boxed Types/BoxedVariable.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/BusyWait/BusyWait.qlref b/java/ql/test/query-tests/BusyWait/BusyWait.qlref index c172b454c92..874645fca3e 100644 --- a/java/ql/test/query-tests/BusyWait/BusyWait.qlref +++ b/java/ql/test/query-tests/BusyWait/BusyWait.qlref @@ -1 +1,2 @@ -Likely Bugs/Concurrency/BusyWait.ql \ No newline at end of file +query: Likely Bugs/Concurrency/BusyWait.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/BusyWait/BusyWaits.java b/java/ql/test/query-tests/BusyWait/BusyWaits.java index 7b30ffe591e..4269bc905f1 100644 --- a/java/ql/test/query-tests/BusyWait/BusyWaits.java +++ b/java/ql/test/query-tests/BusyWait/BusyWaits.java @@ -1,13 +1,13 @@ class BusyWaits { public void badWait() throws InterruptedException { while(this.hashCode() != 0) - Thread.sleep(1); + Thread.sleep(1); // $ Alert } public void badWait2() throws InterruptedException, CloneNotSupportedException { while (this.hashCode() < 3) { for (int i = 0; i < this.hashCode(); this.clone()) - Thread.sleep(new String[1].length); + Thread.sleep(new String[1].length); // $ Alert } } @@ -26,4 +26,4 @@ class BusyWaits { System.out.println("foo"); } } -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/CloseResource/CloseReader/CloseReader.java b/java/ql/test/query-tests/CloseResource/CloseReader/CloseReader.java index b77afc49105..b77c3b91538 100644 --- a/java/ql/test/query-tests/CloseResource/CloseReader/CloseReader.java +++ b/java/ql/test/query-tests/CloseResource/CloseReader/CloseReader.java @@ -15,12 +15,12 @@ import java.util.zip.ZipFile; class CloseReader { void test1() throws IOException { - BufferedReader br = new BufferedReader(new FileReader("C:\\test.txt")); + BufferedReader br = new BufferedReader(new FileReader("C:\\test.txt")); // $ Alert System.out.println(br.readLine()); } void test2() throws IOException { - InputStream in = new FileInputStream("file.bin"); + InputStream in = new FileInputStream("file.bin"); // $ Alert in.read(); } @@ -30,7 +30,7 @@ class CloseReader { // InputStreamReader may throw an exception, in which case the ... reader = new InputStreamReader( // ... FileInputStream is not closed by the finally block - new FileInputStream("C:\\test.txt"), "UTF-8"); + new FileInputStream("C:\\test.txt"), "UTF-8"); // $ Alert System.out.println(reader.read()); } finally { @@ -40,7 +40,7 @@ class CloseReader { } void test4() throws IOException { - ZipFile zipFile = new ZipFile("file.zip"); + ZipFile zipFile = new ZipFile("file.zip"); // $ Alert System.out.println(zipFile.getComment()); } diff --git a/java/ql/test/query-tests/CloseResource/CloseReader/CloseReader.qlref b/java/ql/test/query-tests/CloseResource/CloseReader/CloseReader.qlref index 1c808bb9f46..9fae04fe76d 100644 --- a/java/ql/test/query-tests/CloseResource/CloseReader/CloseReader.qlref +++ b/java/ql/test/query-tests/CloseResource/CloseReader/CloseReader.qlref @@ -1 +1,2 @@ -Likely Bugs/Resource Leaks/CloseReader.ql +query: Likely Bugs/Resource Leaks/CloseReader.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/CloseResource/CloseWriter/CloseWriter.java b/java/ql/test/query-tests/CloseResource/CloseWriter/CloseWriter.java index 3733237b8de..877d18bae68 100644 --- a/java/ql/test/query-tests/CloseResource/CloseWriter/CloseWriter.java +++ b/java/ql/test/query-tests/CloseResource/CloseWriter/CloseWriter.java @@ -14,12 +14,12 @@ import java.util.zip.ZipFile; class CloseWriter { void test1() throws IOException { - BufferedWriter bw = new BufferedWriter(new FileWriter("C:\\test.txt")); + BufferedWriter bw = new BufferedWriter(new FileWriter("C:\\test.txt")); // $ Alert bw.write("test"); } void test2() throws IOException { - OutputStream out = new FileOutputStream("test.bin"); + OutputStream out = new FileOutputStream("test.bin"); // $ Alert out.write(1); } @@ -29,7 +29,7 @@ class CloseWriter { // OutputStreamWriter may throw an exception, in which case the ... writer = new OutputStreamWriter( // ... FileOutputStream is not closed by the finally block - new FileOutputStream("C:\\test.txt"), "UTF-8"); + new FileOutputStream("C:\\test.txt"), "UTF-8"); // $ Alert writer.write("test"); } finally { diff --git a/java/ql/test/query-tests/CloseResource/CloseWriter/CloseWriter.qlref b/java/ql/test/query-tests/CloseResource/CloseWriter/CloseWriter.qlref index 88008367363..d81d6020dae 100644 --- a/java/ql/test/query-tests/CloseResource/CloseWriter/CloseWriter.qlref +++ b/java/ql/test/query-tests/CloseResource/CloseWriter/CloseWriter.qlref @@ -1 +1,2 @@ -Likely Bugs/Resource Leaks/CloseWriter.ql +query: Likely Bugs/Resource Leaks/CloseWriter.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/CompareIdenticalValues/A.java b/java/ql/test/query-tests/CompareIdenticalValues/A.java index 89cadc833f5..d3f1b984132 100644 --- a/java/ql/test/query-tests/CompareIdenticalValues/A.java +++ b/java/ql/test/query-tests/CompareIdenticalValues/A.java @@ -6,13 +6,13 @@ class Super { public class A extends Super { class B extends Super { { - if (this.foo == this.foo) + if (this.foo == this.foo) // $ Alert ; - if (B.this.foo == this.foo) + if (B.this.foo == this.foo) // $ Alert ; - if (super.foo == foo) + if (super.foo == foo) // $ Alert ; - if (B.super.foo == foo) + if (B.super.foo == foo) // $ Alert ; if (A.this.foo != this.foo) ; @@ -23,23 +23,23 @@ public class A extends Super { { Double d = Double.NaN; - if (d == d); // !Double.isNan(d) - if (d <= d); // !Double.isNan(d), but unlikely to be intentional - if (d >= d); // !Double.isNan(d), but unlikely to be intentional - if (d != d); // Double.isNan(d) - if (d > d); // always false - if (d < d); // always false + if (d == d); // $ Alert // !Double.isNan(d) + if (d <= d); // $ Alert // !Double.isNan(d), but unlikely to be intentional + if (d >= d); // $ Alert // !Double.isNan(d), but unlikely to be intentional + if (d != d); // $ Alert // Double.isNan(d) + if (d > d); // $ Alert // always false + if (d < d); // $ Alert // always false float f = Float.NaN; - if (f == f); // !Float.isNan(f) - if (f <= f); // !Float.isNan(f), but unlikely to be intentional - if (f >= f); // !Float.isNan(f), but unlikely to be intentional - if (f != f); // Float.isNan(f) - if (f > f); // always false - if (f < f); // always false + if (f == f); // $ Alert // !Float.isNan(f) + if (f <= f); // $ Alert // !Float.isNan(f), but unlikely to be intentional + if (f >= f); // $ Alert // !Float.isNan(f), but unlikely to be intentional + if (f != f); // $ Alert // Float.isNan(f) + if (f > f); // $ Alert // always false + if (f < f); // $ Alert // always false int i = 0; - if (i == i); - if (i != i); + if (i == i); // $ Alert + if (i != i); // $ Alert } } diff --git a/java/ql/test/query-tests/CompareIdenticalValues/CompareIdenticalValues.qlref b/java/ql/test/query-tests/CompareIdenticalValues/CompareIdenticalValues.qlref index afff16c4f86..6022334fa24 100644 --- a/java/ql/test/query-tests/CompareIdenticalValues/CompareIdenticalValues.qlref +++ b/java/ql/test/query-tests/CompareIdenticalValues/CompareIdenticalValues.qlref @@ -1 +1,2 @@ -Likely Bugs/Comparison/CompareIdenticalValues.ql \ No newline at end of file +query: Likely Bugs/Comparison/CompareIdenticalValues.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/ComplexCondition/ComplexCondition.java b/java/ql/test/query-tests/ComplexCondition/ComplexCondition.java index 4ed26d90731..8ad6e40022c 100644 --- a/java/ql/test/query-tests/ComplexCondition/ComplexCondition.java +++ b/java/ql/test/query-tests/ComplexCondition/ComplexCondition.java @@ -1,11 +1,11 @@ class ComplexCondition { public boolean bad(boolean a, boolean b, boolean c) { - if (a && (b || !c) + if (a && (b || !c) // $ || b && (a || !c) - || c && (a || !b)) { + || c && (a || !b)) { // $ Alert return true; } else { - return (a && !b) || (b && !c) || (a && !c) || (a && b || c); + return (a && !b) || (b && !c) || (a && !c) || (a && b || c); // $ Alert } } @@ -30,4 +30,4 @@ class ComplexCondition { }.ok(a || b, b || c, c || a) ); } -}; \ No newline at end of file +}; diff --git a/java/ql/test/query-tests/ComplexCondition/ComplexCondition.qlref b/java/ql/test/query-tests/ComplexCondition/ComplexCondition.qlref index 3c32b8a04ce..cf023b3c8af 100644 --- a/java/ql/test/query-tests/ComplexCondition/ComplexCondition.qlref +++ b/java/ql/test/query-tests/ComplexCondition/ComplexCondition.qlref @@ -1 +1,2 @@ -Complexity/ComplexCondition.ql +query: Complexity/ComplexCondition.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/ConfusingOverloading/ConfusingOverloading.qlref b/java/ql/test/query-tests/ConfusingOverloading/ConfusingOverloading.qlref index 4fc71295c2c..e74bc1b00aa 100644 --- a/java/ql/test/query-tests/ConfusingOverloading/ConfusingOverloading.qlref +++ b/java/ql/test/query-tests/ConfusingOverloading/ConfusingOverloading.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Naming Conventions/ConfusingOverloading.ql \ No newline at end of file +query: Violations of Best Practice/Naming Conventions/ConfusingOverloading.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/ConfusingOverloading/TestConfusingOverloading.java b/java/ql/test/query-tests/ConfusingOverloading/TestConfusingOverloading.java index bba5cfb67b6..1d404574215 100644 --- a/java/ql/test/query-tests/ConfusingOverloading/TestConfusingOverloading.java +++ b/java/ql/test/query-tests/ConfusingOverloading/TestConfusingOverloading.java @@ -4,7 +4,7 @@ public class TestConfusingOverloading { void test(Super other) {} } class Sub extends Super { - void test(Sub other) {} + void test(Sub other) {} // $ Alert } class Sub2 extends Super { diff --git a/java/ql/test/query-tests/ConstantExpAppearsNonConstant/ConstantExpAppearsNonConstant.qlref b/java/ql/test/query-tests/ConstantExpAppearsNonConstant/ConstantExpAppearsNonConstant.qlref index 6d7e1f5cb7f..924600d5a4d 100644 --- a/java/ql/test/query-tests/ConstantExpAppearsNonConstant/ConstantExpAppearsNonConstant.qlref +++ b/java/ql/test/query-tests/ConstantExpAppearsNonConstant/ConstantExpAppearsNonConstant.qlref @@ -1 +1,2 @@ -Likely Bugs/Arithmetic/ConstantExpAppearsNonConstant.ql \ No newline at end of file +query: Likely Bugs/Arithmetic/ConstantExpAppearsNonConstant.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/ConstantExpAppearsNonConstant/Test.java b/java/ql/test/query-tests/ConstantExpAppearsNonConstant/Test.java index 57c8fe55f15..344fe39d603 100644 --- a/java/ql/test/query-tests/ConstantExpAppearsNonConstant/Test.java +++ b/java/ql/test/query-tests/ConstantExpAppearsNonConstant/Test.java @@ -15,27 +15,27 @@ class Test{ int mul_constant_left = 0 * 60 * 60 * 24; //OK int mul_constant_right = 60 * 60 * 24 * 0; //OK int mul_is_not_constant = rnd.nextInt() * 1; //OK - int mul_is_constant_int_left = (0+0) * rnd.nextInt(); //NOT OK - int mul_is_constant_int_right = rnd.nextInt() * (1-1); //NOT OK - long mul_is_constant_hex = rnd.nextLong() * (0x0F & 0xF0); //NOT OK - long mul_is_constant_binary = rnd.nextLong() * (0b010101 & 0b101010); //NOT OK + int mul_is_constant_int_left = (0+0) * rnd.nextInt(); // $ Alert //NOT OK + int mul_is_constant_int_right = rnd.nextInt() * (1-1); // $ Alert //NOT OK + long mul_is_constant_hex = rnd.nextLong() * (0x0F & 0xF0); // $ Alert //NOT OK + long mul_is_constant_binary = rnd.nextLong() * (0b010101 & 0b101010); // $ Alert //NOT OK int mul_explicit_zero = rnd.nextInt() * 0; //OK (deliberate zero multiplication) //Remainder by 1 int rem_not_constant = 42 % 6; //OK int rem_constant = 60 % 1; //OK int rem_is_not_constant = rnd.nextInt() % 2; //OK - int rem_is_constant_int = rnd.nextInt() % 1; //NOT OK + int rem_is_constant_int = rnd.nextInt() % 1; // $ Alert //NOT OK double rem_is_constant_float = rnd.nextDouble() % 1; //OK (remainder by 1 on floats is not constant) - long rem_is_constant_hex = rnd.nextLong() % 0x1; //NOT OK - long rem_is_constant_binary = rnd.nextLong() % 01; //NOT OK + long rem_is_constant_hex = rnd.nextLong() % 0x1; // $ Alert //NOT OK + long rem_is_constant_binary = rnd.nextLong() % 01; // $ Alert //NOT OK //Bitwise 'and' by 0 int band_not_constant = 42 & 6; //OK int band_appears_constant_left = 0 & 60; //OK int band_appears_constant_right = 24 & 0; //OK int band_is_not_constant = rnd.nextInt() & 5; //OK - int band_is_constant_left = 0 & rnd.nextInt(); //NOT OK - int band_is_constant_right = rnd.nextInt() & 0; //NOT OK + int band_is_constant_left = 0 & rnd.nextInt(); // $ Alert //NOT OK + int band_is_constant_right = rnd.nextInt() & 0; // $ Alert //NOT OK //Logical 'and' by false boolean and_not_constant = true && true; //OK @@ -50,7 +50,7 @@ class Test{ boolean or_appears_constant_left = true || false; //OK boolean or_appears_constant_right = false || true; //OK boolean or_is_not_constant = (rnd.nextInt() > 0) || false; //OK - boolean or_is_constant_left = true || (rnd.nextInt() > 0); //NOT OK - boolean or_is_constant_right = (rnd.nextInt() > 0) || true; //NOT OK + boolean or_is_constant_left = true || (rnd.nextInt() > 0); // $ Alert //NOT OK + boolean or_is_constant_right = (rnd.nextInt() > 0) || true; // $ Alert //NOT OK } } diff --git a/java/ql/test/query-tests/ConstantLoopCondition/A.java b/java/ql/test/query-tests/ConstantLoopCondition/A.java index 444954476da..e837b69ea1e 100644 --- a/java/ql/test/query-tests/ConstantLoopCondition/A.java +++ b/java/ql/test/query-tests/ConstantLoopCondition/A.java @@ -5,14 +5,14 @@ class A { void f(int initx) { boolean done = false; - while(!done) { // BAD: main loop condition is constant in the loop + while(!done) { // $ Alert // BAD: main loop condition is constant in the loop if (otherCond()) break; } int x = initx * 2; int i = 0; for(x++; ; i++) { - if (x > 5 && otherCond()) { // BAD: x>5 is constant in the loop and guards all exits + if (x > 5 && otherCond()) { // $ Alert // BAD: x>5 is constant in the loop and guards all exits if (i > 3) break; if (otherCond()) return; } @@ -26,14 +26,14 @@ class A { i++; } - for(int j = 0; j < 2 * initx; i++) { // BAD: j 0) { // OK: loop used as an if-statement break; } - while (cond) { // BAD: read of final field + while (cond) { // $ Alert // BAD: read of final field i++; } } diff --git a/java/ql/test/query-tests/ConstantLoopCondition/ConstantLoopCondition.qlref b/java/ql/test/query-tests/ConstantLoopCondition/ConstantLoopCondition.qlref index 37e6a9b72fe..f7081322f7d 100644 --- a/java/ql/test/query-tests/ConstantLoopCondition/ConstantLoopCondition.qlref +++ b/java/ql/test/query-tests/ConstantLoopCondition/ConstantLoopCondition.qlref @@ -1 +1,2 @@ -Likely Bugs/Termination/ConstantLoopCondition.ql +query: Likely Bugs/Termination/ConstantLoopCondition.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/ContainerSizeCmpZero/ContainerSizeCmpZero.qlref b/java/ql/test/query-tests/ContainerSizeCmpZero/ContainerSizeCmpZero.qlref index a9ea71f7f28..8d1915fd56a 100644 --- a/java/ql/test/query-tests/ContainerSizeCmpZero/ContainerSizeCmpZero.qlref +++ b/java/ql/test/query-tests/ContainerSizeCmpZero/ContainerSizeCmpZero.qlref @@ -1 +1,2 @@ -Likely Bugs/Likely Typos/ContainerSizeCmpZero.ql \ No newline at end of file +query: Likely Bugs/Likely Typos/ContainerSizeCmpZero.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/ContainerSizeCmpZero/Main.java b/java/ql/test/query-tests/ContainerSizeCmpZero/Main.java index 8176177561a..518e5074fc3 100644 --- a/java/ql/test/query-tests/ContainerSizeCmpZero/Main.java +++ b/java/ql/test/query-tests/ContainerSizeCmpZero/Main.java @@ -5,22 +5,22 @@ public class Main { public static void arrays(String[] args) { // NOT OK: always true - if (args.length >= 0) { + if (args.length >= 0) { // $ Alert System.out.println("At least zero arguments!!"); } // NOT OK: always true - if (0 <= args.length) { + if (0 <= args.length) { // $ Alert System.out.println("At least zero arguments!!"); } // NOT OK: always false - if (args.length < 0) { + if (args.length < 0) { // $ Alert System.out.println("At least zero arguments!!"); } // NOT OK: always false - if (0 > args.length) { + if (0 > args.length) { // $ Alert System.out.println("At least zero arguments!!"); } @@ -51,12 +51,12 @@ public class Main { Boolean b; // NOT OK - b = xs.size() >= 0; - b = 0 <= xs.size(); - b = 0 <= ys.size(); + b = xs.size() >= 0; // $ Alert + b = 0 <= xs.size(); // $ Alert + b = 0 <= ys.size(); // $ Alert - b = xs.size() < 0; - b = 0 > ys.size(); + b = xs.size() < 0; // $ Alert + b = 0 > ys.size(); // $ Alert // OK b = xs.size() >= -1; @@ -80,24 +80,24 @@ public class Main { Boolean b; // NOT OK - b = xs.size() >= 0; - b = xs.size() < 0; + b = xs.size() >= 0; // $ Alert + b = xs.size() < 0; // $ Alert // NOT OK - b = xs.get(0).size() >= 0; + b = xs.get(0).size() >= 0; // $ Alert // NOT OK - b = xs.get(0).get(0).length() >= 0; + b = xs.get(0).get(0).length() >= 0; // $ Alert } public static void mapTests(TreeMap xs) { Boolean b; // NOT OK: Always true - b = xs.size() >= 0; + b = xs.size() >= 0; // $ Alert // NOT OK: Always true - b = 0 <= xs.size(); + b = 0 <= xs.size(); // $ Alert // OK: can be false b = xs.size() >= -1; @@ -110,9 +110,9 @@ public class Main { Boolean b; // NOT OK - b = s.size() >= 0; - b = a.size() >= 0; - b = 0 <= m.size(); + b = s.size() >= 0; // $ Alert + b = a.size() >= 0; // $ Alert + b = 0 <= m.size(); // $ Alert } } diff --git a/java/ql/test/query-tests/ContinueInFalseLoop/A.java b/java/ql/test/query-tests/ContinueInFalseLoop/A.java index 51f381b94c8..99a749d6726 100644 --- a/java/ql/test/query-tests/ContinueInFalseLoop/A.java +++ b/java/ql/test/query-tests/ContinueInFalseLoop/A.java @@ -11,7 +11,7 @@ public class A { do { if (c.cond()) - continue; // BAD + continue; // $ Alert // BAD if (c.cond()) break; } while (false); @@ -51,7 +51,7 @@ public class A { do { do { if (c.cond()) - continue; // BAD + continue; // $ Alert // BAD if (c.cond()) break; } while (false); @@ -76,7 +76,7 @@ public class A { default: // do [2] // break out of the loop entirely, skipping [3] - continue; // BAD; labelled break is better + continue; // $ Alert // BAD; labelled break is better }; // do [3] } while (false); diff --git a/java/ql/test/query-tests/ContinueInFalseLoop/ContinueInFalseLoop.qlref b/java/ql/test/query-tests/ContinueInFalseLoop/ContinueInFalseLoop.qlref index 525b40f8409..3fa3e514229 100644 --- a/java/ql/test/query-tests/ContinueInFalseLoop/ContinueInFalseLoop.qlref +++ b/java/ql/test/query-tests/ContinueInFalseLoop/ContinueInFalseLoop.qlref @@ -1 +1,2 @@ -Likely Bugs/Statements/ContinueInFalseLoop.ql +query: Likely Bugs/Statements/ContinueInFalseLoop.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/ContradictoryTypeChecks/ContradictoryTypeChecks.qlref b/java/ql/test/query-tests/ContradictoryTypeChecks/ContradictoryTypeChecks.qlref index 0744f656bdb..ecec142d9ed 100644 --- a/java/ql/test/query-tests/ContradictoryTypeChecks/ContradictoryTypeChecks.qlref +++ b/java/ql/test/query-tests/ContradictoryTypeChecks/ContradictoryTypeChecks.qlref @@ -1 +1,2 @@ -Likely Bugs/Likely Typos/ContradictoryTypeChecks.ql \ No newline at end of file +query: Likely Bugs/Likely Typos/ContradictoryTypeChecks.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/ContradictoryTypeChecks/Test.java b/java/ql/test/query-tests/ContradictoryTypeChecks/Test.java index 258b6ce87a2..25b44158fdb 100644 --- a/java/ql/test/query-tests/ContradictoryTypeChecks/Test.java +++ b/java/ql/test/query-tests/ContradictoryTypeChecks/Test.java @@ -7,31 +7,31 @@ public class Test { void foo(Super lhs, Super rhs) { if (lhs instanceof Sub1) ; else if (rhs instanceof Sub1) - if ((lhs instanceof Sub1) || (lhs instanceof Sub2)); + if ((lhs instanceof Sub1) || (lhs instanceof Sub2)); // $ Alert } void bar(Super x) { if (x instanceof Super); - else if (x instanceof Sub1); + else if (x instanceof Sub1); // $ Alert } // modeled after results on Apache Lucene void baz(Super x, Super y) { if (x instanceof Sub1); - else if (x instanceof Sub1); + else if (x instanceof Sub1); // $ Alert } // NOT OK void w(Super x) { if (x instanceof Sub2 || x instanceof Super); - else if (x instanceof Sub1); + else if (x instanceof Sub1); // $ Alert } // modeled after result on WildFly @Override public boolean equals(Object object) { if ((object != null) && !(object instanceof Test)) { - Test value = (Test) object; + Test value = (Test) object; // $ Alert return (this.hashCode() == value.hashCode()) && super.equals(object); } return super.equals(object); @@ -40,7 +40,7 @@ public class Test { // NOT OK Sub1 m(Super o) { if (!(o instanceof Sub1)) - return (Sub1)o; + return (Sub1)o; // $ Alert return null; } diff --git a/java/ql/test/query-tests/DeadCode/DeadRefTypes/DeadRefTypes.qlref b/java/ql/test/query-tests/DeadCode/DeadRefTypes/DeadRefTypes.qlref index e4f2d879149..e8f47f2d682 100644 --- a/java/ql/test/query-tests/DeadCode/DeadRefTypes/DeadRefTypes.qlref +++ b/java/ql/test/query-tests/DeadCode/DeadRefTypes/DeadRefTypes.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Dead Code/DeadRefTypes.ql +query: Violations of Best Practice/Dead Code/DeadRefTypes.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/DeadCode/DeadRefTypes/UnusedClass.java b/java/ql/test/query-tests/DeadCode/DeadRefTypes/UnusedClass.java index 4c0d27118a3..f6696b8296a 100644 --- a/java/ql/test/query-tests/DeadCode/DeadRefTypes/UnusedClass.java +++ b/java/ql/test/query-tests/DeadCode/DeadRefTypes/UnusedClass.java @@ -1 +1 @@ -class UnusedClass {} +class UnusedClass {} // $ Alert diff --git a/java/ql/test/query-tests/DeadCode/NonAssignedFields/NonAssignedFields.qlref b/java/ql/test/query-tests/DeadCode/NonAssignedFields/NonAssignedFields.qlref index 79031c31ddb..ea15ad036eb 100644 --- a/java/ql/test/query-tests/DeadCode/NonAssignedFields/NonAssignedFields.qlref +++ b/java/ql/test/query-tests/DeadCode/NonAssignedFields/NonAssignedFields.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Dead Code/NonAssignedFields.ql \ No newline at end of file +query: Violations of Best Practice/Dead Code/NonAssignedFields.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/DeadCode/camel/DeadClass.qlref b/java/ql/test/query-tests/DeadCode/camel/DeadClass.qlref index d726e7e0849..b94832ebfca 100644 --- a/java/ql/test/query-tests/DeadCode/camel/DeadClass.qlref +++ b/java/ql/test/query-tests/DeadCode/camel/DeadClass.qlref @@ -1 +1,2 @@ -DeadCode/DeadClass.ql +query: DeadCode/DeadClass.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/DeadCode/camel/DeadMethod.qlref b/java/ql/test/query-tests/DeadCode/camel/DeadMethod.qlref index 76204a1df5a..743a5f15775 100644 --- a/java/ql/test/query-tests/DeadCode/camel/DeadMethod.qlref +++ b/java/ql/test/query-tests/DeadCode/camel/DeadMethod.qlref @@ -1 +1,2 @@ -DeadCode/DeadMethod.ql +query: DeadCode/DeadMethod.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/DeadCode/camel/com/semmle/camel/DeadTarget.java b/java/ql/test/query-tests/DeadCode/camel/com/semmle/camel/DeadTarget.java index f4fabc7d22e..d2ccfa90e36 100644 --- a/java/ql/test/query-tests/DeadCode/camel/com/semmle/camel/DeadTarget.java +++ b/java/ql/test/query-tests/DeadCode/camel/com/semmle/camel/DeadTarget.java @@ -1,10 +1,10 @@ package com.semmle.camel; /** Dead because it is not referenced in the {@code config.xml} file, or in the Java DSL. */ -public class DeadTarget { +public class DeadTarget { // $ Alert[java/dead-class] public Foo getFoo(Foo foo1) { return new Foo(); } - public static class Foo {} + public static class Foo {} // $ Alert[java/dead-class] } diff --git a/java/ql/test/query-tests/DeadCode/camel/com/semmle/camel/javadsl/CustomRouteBuilder.java b/java/ql/test/query-tests/DeadCode/camel/com/semmle/camel/javadsl/CustomRouteBuilder.java index 437a4d7b56d..01baa30e0a9 100644 --- a/java/ql/test/query-tests/DeadCode/camel/com/semmle/camel/javadsl/CustomRouteBuilder.java +++ b/java/ql/test/query-tests/DeadCode/camel/com/semmle/camel/javadsl/CustomRouteBuilder.java @@ -5,7 +5,7 @@ import org.apache.camel.impl.DefaultCamelContext; public class CustomRouteBuilder extends RouteBuilder { @Override - public void configure() throws Exception { + public void configure() throws Exception { // $ Alert[java/dead-function] from("direct:test") .to("bean:dslToTarget") .bean(DSLBeanTarget.class) diff --git a/java/ql/test/query-tests/Declarations/BreakInSwitchCase.qlref b/java/ql/test/query-tests/Declarations/BreakInSwitchCase.qlref index 463071903e8..ba1066f4fdf 100644 --- a/java/ql/test/query-tests/Declarations/BreakInSwitchCase.qlref +++ b/java/ql/test/query-tests/Declarations/BreakInSwitchCase.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Declarations/BreakInSwitchCase.ql \ No newline at end of file +query: Violations of Best Practice/Declarations/BreakInSwitchCase.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/Declarations/Test.java b/java/ql/test/query-tests/Declarations/Test.java index 473001a4de4..d47c8e72904 100644 --- a/java/ql/test/query-tests/Declarations/Test.java +++ b/java/ql/test/query-tests/Declarations/Test.java @@ -11,13 +11,13 @@ public class Test { System.out.println("No args"); break; case 1: - case 2: + case 2: // $ Alert System.out.println("1-2 args"); // missing break. case 3: System.out.println("3 or more args"); // fall-through - case 4: + case 4: // $ Alert System.out.println("4 or more args"); if (i > 1) break; diff --git a/java/ql/test/query-tests/DefineEqualsWhenAddingFields/DefineEqualsWhenAddingFields.qlref b/java/ql/test/query-tests/DefineEqualsWhenAddingFields/DefineEqualsWhenAddingFields.qlref index 59ec6309d58..908f133eccb 100644 --- a/java/ql/test/query-tests/DefineEqualsWhenAddingFields/DefineEqualsWhenAddingFields.qlref +++ b/java/ql/test/query-tests/DefineEqualsWhenAddingFields/DefineEqualsWhenAddingFields.qlref @@ -1,2 +1,2 @@ - -Likely Bugs/Comparison/DefineEqualsWhenAddingFields.ql \ No newline at end of file +query: Likely Bugs/Comparison/DefineEqualsWhenAddingFields.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/DoubleCheckedLocking/A.java b/java/ql/test/query-tests/DoubleCheckedLocking/A.java index 88c7e317244..c1b119d061a 100644 --- a/java/ql/test/query-tests/DoubleCheckedLocking/A.java +++ b/java/ql/test/query-tests/DoubleCheckedLocking/A.java @@ -9,11 +9,11 @@ public class A { private String s1; public String getString1() { if (s1 == null) { - synchronized(this) { + synchronized(this) { // $ if (s1 == null) { s1 = "string"; // BAD, immutable but read twice outside sync } - } + } // $ Alert[java/unsafe-double-checked-locking] } return s1; } @@ -37,12 +37,12 @@ public class A { public B getter1() { B x = b1; if (x == null) { - synchronized(this) { + synchronized(this) { // $ if ((x = b1) == null) { b1 = new B(); // BAD, not volatile x = b1; } - } + } // $ Alert[java/unsafe-double-checked-locking] } return x; } @@ -67,7 +67,7 @@ public class A { if (b3 == null) { synchronized(this) { if (b3 == null) { - b3 = new B(); + b3 = new B(); // $ Alert[java/unsafe-double-checked-locking-init-order] b3.x = 7; // BAD, post update init } } @@ -80,7 +80,7 @@ public class A { if (b4 == null) { synchronized(this) { if (b4 == null) { - b4 = new B(); + b4 = new B(); // $ Alert[java/unsafe-double-checked-locking-init-order] b4.setX(7); // BAD, post update init } } @@ -98,12 +98,12 @@ public class A { private FinalHelper b5; public B getter5() { if (b5 == null) { - synchronized(this) { + synchronized(this) { // $ if (b5 == null) { B b = new B(); b5 = new FinalHelper(b); // BAD, racy read on b5 outside synchronized-block } - } + } // $ Alert[java/unsafe-double-checked-locking] } return b5.x; // Potential NPE here, as the two b5 reads may be reordered } diff --git a/java/ql/test/query-tests/DoubleCheckedLocking/DoubleCheckedLocking.qlref b/java/ql/test/query-tests/DoubleCheckedLocking/DoubleCheckedLocking.qlref index dba6bdc1423..e5349f614dd 100644 --- a/java/ql/test/query-tests/DoubleCheckedLocking/DoubleCheckedLocking.qlref +++ b/java/ql/test/query-tests/DoubleCheckedLocking/DoubleCheckedLocking.qlref @@ -1 +1,2 @@ -Likely Bugs/Concurrency/DoubleCheckedLocking.ql +query: Likely Bugs/Concurrency/DoubleCheckedLocking.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/DoubleCheckedLocking/DoubleCheckedLockingWithInitRace.qlref b/java/ql/test/query-tests/DoubleCheckedLocking/DoubleCheckedLockingWithInitRace.qlref index eaa2a16d238..f38033e0831 100644 --- a/java/ql/test/query-tests/DoubleCheckedLocking/DoubleCheckedLockingWithInitRace.qlref +++ b/java/ql/test/query-tests/DoubleCheckedLocking/DoubleCheckedLockingWithInitRace.qlref @@ -1 +1,2 @@ -Likely Bugs/Concurrency/DoubleCheckedLockingWithInitRace.ql +query: Likely Bugs/Concurrency/DoubleCheckedLockingWithInitRace.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/EqualsArray/EqualsArray.qlref b/java/ql/test/query-tests/EqualsArray/EqualsArray.qlref index 0e55e19bea4..7bd191ec639 100644 --- a/java/ql/test/query-tests/EqualsArray/EqualsArray.qlref +++ b/java/ql/test/query-tests/EqualsArray/EqualsArray.qlref @@ -1 +1,2 @@ -Likely Bugs/Comparison/EqualsArray.ql \ No newline at end of file +query: Likely Bugs/Comparison/EqualsArray.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/EqualsArray/Test.java b/java/ql/test/query-tests/EqualsArray/Test.java index f6bf536c4b1..f1870b15ddf 100644 --- a/java/ql/test/query-tests/EqualsArray/Test.java +++ b/java/ql/test/query-tests/EqualsArray/Test.java @@ -3,7 +3,7 @@ public class Test { // NOT OK public boolean areTheseMyNumbers(int[] numbers) { - return this.numbers.equals(numbers); + return this.numbers.equals(numbers); // $ Alert } // OK @@ -17,6 +17,6 @@ public class Test { } { - numbers.hashCode(); + numbers.hashCode(); // $ Alert } -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/EqualsUsesInstanceOf/EqualsUsesInstanceOf.qlref b/java/ql/test/query-tests/EqualsUsesInstanceOf/EqualsUsesInstanceOf.qlref index 5fb552f91da..b9031f10aa6 100644 --- a/java/ql/test/query-tests/EqualsUsesInstanceOf/EqualsUsesInstanceOf.qlref +++ b/java/ql/test/query-tests/EqualsUsesInstanceOf/EqualsUsesInstanceOf.qlref @@ -1 +1,2 @@ -Likely Bugs/Comparison/EqualsUsesInstanceOf.ql \ No newline at end of file +query: Likely Bugs/Comparison/EqualsUsesInstanceOf.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/ExposeRepresentation/ExposeRepresentation.qlref b/java/ql/test/query-tests/ExposeRepresentation/ExposeRepresentation.qlref index 6452bb942d2..e47d860dcc2 100644 --- a/java/ql/test/query-tests/ExposeRepresentation/ExposeRepresentation.qlref +++ b/java/ql/test/query-tests/ExposeRepresentation/ExposeRepresentation.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Implementation Hiding/ExposeRepresentation.ql +query: Violations of Best Practice/Implementation Hiding/ExposeRepresentation.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/ExposeRepresentation/ExposesRep.java b/java/ql/test/query-tests/ExposeRepresentation/ExposesRep.java index 11cf4456788..3949467e249 100644 --- a/java/ql/test/query-tests/ExposeRepresentation/ExposesRep.java +++ b/java/ql/test/query-tests/ExposeRepresentation/ExposesRep.java @@ -8,17 +8,17 @@ public class ExposesRep { strings = new String[1]; } - public String[] getStrings() { return strings; } + public String[] getStrings() { return strings; } // $ Alert - public Map getStringMap() { + public Map getStringMap() { // $ Alert return stringMap; } - public void setStrings(String[] ss) { + public void setStrings(String[] ss) { // $ Alert this.strings = ss; } - public void setStringMap(Map m) { + public void setStringMap(Map m) { // $ Alert this.stringMap = m; } } @@ -26,5 +26,5 @@ public class ExposesRep { class GenericExposesRep { private T[] array; - public T[] getArray() { return array; } + public T[] getArray() { return array; } // $ Alert } diff --git a/java/ql/test/query-tests/Finally/Finally.java b/java/ql/test/query-tests/Finally/Finally.java index 536dc1df65f..7baffe907b4 100644 --- a/java/ql/test/query-tests/Finally/Finally.java +++ b/java/ql/test/query-tests/Finally/Finally.java @@ -3,7 +3,7 @@ class InFinally { void returnVoidInFinally() { try { } finally { - return; + return; // $ Alert } } @@ -14,7 +14,7 @@ class InFinally { } } finally { if (b2) { - return 5; + return 5; // $ Alert } } return 3; @@ -27,7 +27,7 @@ class InFinally { } } finally { if (b2) { - throw new RuntimeException("Foo 2"); + throw new RuntimeException("Foo 2"); // $ Alert } } throw new RuntimeException("Foo 3"); @@ -60,7 +60,7 @@ class InFinally { } } finally { if(b) { - break; + break; // $ Alert } } } @@ -74,7 +74,7 @@ class InFinally { } } finally { if(b) { - break; + break; // $ Alert } } } @@ -108,7 +108,7 @@ class InFinally { } } finally { if(b) { - continue; + continue; // $ Alert } } } @@ -122,7 +122,7 @@ class InFinally { } } finally { if(b) { - continue; + continue; // $ Alert } } } diff --git a/java/ql/test/query-tests/Finally/FinallyMayNotComplete.qlref b/java/ql/test/query-tests/Finally/FinallyMayNotComplete.qlref index d15679d0dc9..18b98edef02 100644 --- a/java/ql/test/query-tests/Finally/FinallyMayNotComplete.qlref +++ b/java/ql/test/query-tests/Finally/FinallyMayNotComplete.qlref @@ -1 +1,2 @@ -Violations of Best Practice/legacy/FinallyMayNotComplete.ql +query: Violations of Best Practice/legacy/FinallyMayNotComplete.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/HashedButNoHash/HashedButNoHash.qlref b/java/ql/test/query-tests/HashedButNoHash/HashedButNoHash.qlref index 22dcbc4be81..2dc8d0a9197 100644 --- a/java/ql/test/query-tests/HashedButNoHash/HashedButNoHash.qlref +++ b/java/ql/test/query-tests/HashedButNoHash/HashedButNoHash.qlref @@ -1 +1,2 @@ -Likely Bugs/Comparison/HashedButNoHash.ql \ No newline at end of file +query: Likely Bugs/Comparison/HashedButNoHash.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/HashedButNoHash/Test.java b/java/ql/test/query-tests/HashedButNoHash/Test.java index fa3e3851bbc..b8d63affe78 100644 --- a/java/ql/test/query-tests/HashedButNoHash/Test.java +++ b/java/ql/test/query-tests/HashedButNoHash/Test.java @@ -7,7 +7,7 @@ class Test { A a = new A(); map.put(a, "value"); HashMap map2 = new HashMap<>(); - map2.put(a, "value"); + map2.put(a, "value"); // $ Alert } } diff --git a/java/ql/test/query-tests/IgnoreExceptionalReturn/IgnoreExceptionalReturn.qlref b/java/ql/test/query-tests/IgnoreExceptionalReturn/IgnoreExceptionalReturn.qlref index a324dbc8ebf..f359a3dfd3e 100644 --- a/java/ql/test/query-tests/IgnoreExceptionalReturn/IgnoreExceptionalReturn.qlref +++ b/java/ql/test/query-tests/IgnoreExceptionalReturn/IgnoreExceptionalReturn.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Exception Handling/IgnoreExceptionalReturn.ql +query: Violations of Best Practice/Exception Handling/IgnoreExceptionalReturn.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/IgnoreExceptionalReturn/Test.java b/java/ql/test/query-tests/IgnoreExceptionalReturn/Test.java index 68f647ad474..9f16604b33a 100644 --- a/java/ql/test/query-tests/IgnoreExceptionalReturn/Test.java +++ b/java/ql/test/query-tests/IgnoreExceptionalReturn/Test.java @@ -2,13 +2,13 @@ import java.io.*; public class Test { public static void main(String[] args) throws IOException { - new File("foo").createNewFile(); + new File("foo").createNewFile(); // $ Alert new File("foo").delete(); // Don't flag: there's usually nothing to do - new File("foo").mkdir(); + new File("foo").mkdir(); // $ Alert new File("foo").mkdirs(); // Don't flag: the return value is uninformative/misleading - new File("foo").renameTo(new File("bar")); - new File("foo").setLastModified(0L); - new File("foo").setReadOnly(); - new File("foo").setWritable(true); + new File("foo").renameTo(new File("bar")); // $ Alert + new File("foo").setLastModified(0L); // $ Alert + new File("foo").setReadOnly(); // $ Alert + new File("foo").setWritable(true); // $ Alert } } diff --git a/java/ql/test/query-tests/ImpossibleCast/ImpossibleCast.qlref b/java/ql/test/query-tests/ImpossibleCast/ImpossibleCast.qlref index f39a2841d29..076c1c077fc 100644 --- a/java/ql/test/query-tests/ImpossibleCast/ImpossibleCast.qlref +++ b/java/ql/test/query-tests/ImpossibleCast/ImpossibleCast.qlref @@ -1 +1,2 @@ -Likely Bugs/Statements/ImpossibleCast.ql \ No newline at end of file +query: Likely Bugs/Statements/ImpossibleCast.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/ImpossibleCast/impossible_cast/A.java b/java/ql/test/query-tests/ImpossibleCast/impossible_cast/A.java index c7ed31926b3..05b4e5734e8 100644 --- a/java/ql/test/query-tests/ImpossibleCast/impossible_cast/A.java +++ b/java/ql/test/query-tests/ImpossibleCast/impossible_cast/A.java @@ -3,6 +3,6 @@ package impossible_cast; import java.io.Serializable; public class A { - { String[] s = (String[])new Object[] { "Hello, world!" }; } - { Serializable[] ss = (Object[][])new Serializable[] {}; } + { String[] s = (String[])new Object[] { "Hello, world!" }; } // $ Alert + { Serializable[] ss = (Object[][])new Serializable[] {}; } // $ Alert } diff --git a/java/ql/test/query-tests/InconsistentEqualsHashCode/InconsistentEqualsHashCode.qlref b/java/ql/test/query-tests/InconsistentEqualsHashCode/InconsistentEqualsHashCode.qlref index f97a899d887..bdda86a6662 100644 --- a/java/ql/test/query-tests/InconsistentEqualsHashCode/InconsistentEqualsHashCode.qlref +++ b/java/ql/test/query-tests/InconsistentEqualsHashCode/InconsistentEqualsHashCode.qlref @@ -1 +1,2 @@ -Likely Bugs/Comparison/InconsistentEqualsHashCode.ql \ No newline at end of file +query: Likely Bugs/Comparison/InconsistentEqualsHashCode.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/InconsistentEqualsHashCode/Test.java b/java/ql/test/query-tests/InconsistentEqualsHashCode/Test.java index f4bbb3bcbce..fce1665accb 100644 --- a/java/ql/test/query-tests/InconsistentEqualsHashCode/Test.java +++ b/java/ql/test/query-tests/InconsistentEqualsHashCode/Test.java @@ -16,14 +16,14 @@ class Super { } } -class NoEquals extends Super { +class NoEquals extends Super { // $ Alert // BAD public int hashCode() { return myInt+1; } } -class NoHashCode extends Super { +class NoHashCode extends Super { // $ Alert // BAD public boolean equals(Object other) { return true; @@ -37,4 +37,4 @@ class RefiningEquals extends Super { public boolean equals(Object other) { return (super.equals(other) && myLong == ((RefiningEquals)other).myLong); } -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/InconsistentOperations/InconsistentCallOnResult.qlref b/java/ql/test/query-tests/InconsistentOperations/InconsistentCallOnResult.qlref index b1457baff9a..b0ed2b68915 100644 --- a/java/ql/test/query-tests/InconsistentOperations/InconsistentCallOnResult.qlref +++ b/java/ql/test/query-tests/InconsistentOperations/InconsistentCallOnResult.qlref @@ -1 +1,2 @@ -Likely Bugs/Statements/InconsistentCallOnResult.ql \ No newline at end of file +query: Likely Bugs/Statements/InconsistentCallOnResult.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/InconsistentOperations/Operations.java b/java/ql/test/query-tests/InconsistentOperations/Operations.java index 1667ac5fccc..a91ec212a10 100644 --- a/java/ql/test/query-tests/InconsistentOperations/Operations.java +++ b/java/ql/test/query-tests/InconsistentOperations/Operations.java @@ -36,7 +36,7 @@ public class Operations implements AutoCloseable { { Operations ops = open(); if (ops.isOpen()) ops.close(); } { Operations ops = open(); if (ops.isOpen()) ops.close(); } { Operations ops = open(); if (ops.isOpen()) ops.close(); } - { Operations ops = open(); if (ops.isOpen()) ops.open(); } + { Operations ops = open(); if (ops.isOpen()) ops.open(); } // $ Alert[java/inconsistent-call-on-result] } public void missingAdd() { @@ -83,7 +83,7 @@ public class Operations implements AutoCloseable { System.out.println(this.toString()); System.out.println(this.toString()); System.out.println(this.toString()); - this.toString(); + this.toString(); // $ Alert[java/return-value-ignored] } public void designedForChaining() { diff --git a/java/ql/test/query-tests/InconsistentOperations/ReturnValueIgnored.qlref b/java/ql/test/query-tests/InconsistentOperations/ReturnValueIgnored.qlref index ef1dc964d95..ab13392ec55 100644 --- a/java/ql/test/query-tests/InconsistentOperations/ReturnValueIgnored.qlref +++ b/java/ql/test/query-tests/InconsistentOperations/ReturnValueIgnored.qlref @@ -1 +1,2 @@ -Likely Bugs/Statements/ReturnValueIgnored.ql \ No newline at end of file +query: Likely Bugs/Statements/ReturnValueIgnored.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/InconsistentOperations/Test2.java b/java/ql/test/query-tests/InconsistentOperations/Test2.java index c325179b863..6d74fd883fc 100644 --- a/java/ql/test/query-tests/InconsistentOperations/Test2.java +++ b/java/ql/test/query-tests/InconsistentOperations/Test2.java @@ -12,6 +12,6 @@ public class Test2 { { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } - { A a = foo(); /* no a.bar();*/ } // NOT OK + { A a = foo(); /* no a.bar();*/ } // $ Alert[java/inconsistent-call-on-result] // NOT OK } -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/InconsistentOperations/Test3.java b/java/ql/test/query-tests/InconsistentOperations/Test3.java index 70c28029de9..9600179fe6d 100644 --- a/java/ql/test/query-tests/InconsistentOperations/Test3.java +++ b/java/ql/test/query-tests/InconsistentOperations/Test3.java @@ -14,5 +14,5 @@ public class Test3 { { A a = foo(); a.bar(); } } - { A a = foo(); /* no a.bar();*/ } // NOT OK -} \ No newline at end of file + { A a = foo(); /* no a.bar();*/ } // $ Alert[java/inconsistent-call-on-result] // NOT OK +} diff --git a/java/ql/test/query-tests/InefficientOutputStream/InefficientOutputStream.qlref b/java/ql/test/query-tests/InefficientOutputStream/InefficientOutputStream.qlref index 1ae3a25fd23..92c44931869 100644 --- a/java/ql/test/query-tests/InefficientOutputStream/InefficientOutputStream.qlref +++ b/java/ql/test/query-tests/InefficientOutputStream/InefficientOutputStream.qlref @@ -1 +1,2 @@ -Performance/InefficientOutputStream.ql \ No newline at end of file +query: Performance/InefficientOutputStream.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/InefficientOutputStream/InefficientOutputStreamBad.java b/java/ql/test/query-tests/InefficientOutputStream/InefficientOutputStreamBad.java index f1d17f31aa9..fda83c34964 100644 --- a/java/ql/test/query-tests/InefficientOutputStream/InefficientOutputStreamBad.java +++ b/java/ql/test/query-tests/InefficientOutputStream/InefficientOutputStreamBad.java @@ -2,7 +2,7 @@ import java.io.*; import java.security.*; import java.util.*; -public class InefficientOutputStreamBad extends OutputStream { +public class InefficientOutputStreamBad extends OutputStream { // $ Alert private DigestOutputStream digest; private byte[] expectedMD5; diff --git a/java/ql/test/query-tests/InnerClassCouldBeStatic/Classes.java b/java/ql/test/query-tests/InnerClassCouldBeStatic/Classes.java index 38ef4d358db..03932830d58 100644 --- a/java/ql/test/query-tests/InnerClassCouldBeStatic/Classes.java +++ b/java/ql/test/query-tests/InnerClassCouldBeStatic/Classes.java @@ -12,19 +12,19 @@ public class Classes { } /** Could be static. */ - private class MaybeStatic { + private class MaybeStatic { // $ Alert } /** Only accesses enclosing instance in constructor. */ - private class MaybeStatic1 { + private class MaybeStatic1 { // $ Alert public MaybeStatic1() { System.out.println(foo); } } /** Only accesses enclosing instance in constructor. */ - private class MaybeStatic2 { + private class MaybeStatic2 { // $ Alert public MaybeStatic2() { System.out.println(Classes.this); } @@ -37,7 +37,7 @@ public class Classes { /** * Supertype could be static, and no enclosing instance accesses. */ - private class MaybeStatic3 extends MaybeStatic2 { + private class MaybeStatic3 extends MaybeStatic2 { // $ Alert public void foo(int i) { staticFoo = i; } } @@ -47,7 +47,7 @@ public class Classes { /** Nested and extending classes that can be static; using enclosing * state only in constructor. */ - public class MaybeStatic4 extends Static { + public class MaybeStatic4 extends Static { // $ Alert MaybeStatic4() { System.out.println(staticFoo); } @@ -57,19 +57,19 @@ public class Classes { /** * Access to bar() is through inheritance, not enclosing state. */ - private class MaybeStatic5 extends Classes { + private class MaybeStatic5 extends Classes { // $ Alert public void doit() { System.out.println(bar()); } } - private class MaybeStatic6 { + private class MaybeStatic6 { // $ Alert private final int myFoo = staticFoo; MaybeStatic6() { staticBar(); } } /** A qualified `this` access needn't refer to the enclosing instance. */ - private class MaybeStatic7 { + private class MaybeStatic7 { // $ Alert private void foo() { MaybeStatic7.this.foo(); } } @@ -82,7 +82,7 @@ public class Classes { System.out.println(interfaceFoo); } - class MaybeStatic8 { + class MaybeStatic8 { // $ Alert private void bar() { System.out.println(interfaceFoo); } @@ -91,14 +91,14 @@ public class Classes { } /** Accesses implicitly static interface field. */ - public class MaybeStatic9 extends MaybeStatic7 { + public class MaybeStatic9 extends MaybeStatic7 { // $ Alert private void bar() { System.out.println(Interface.interfaceFoo); } } /** A qualified `super` access that doesn't refer to the enclosing scope. */ - class MaybeStatic10 extends Classes { + class MaybeStatic10 extends Classes { // $ Alert private void baz() { System.out.println(MaybeStatic10.super.getClass()); } @@ -108,7 +108,7 @@ public class Classes { interface B { class ThisIsStatic { final int outer = 0; - class MaybeStaticToo { + class MaybeStaticToo { // $ Alert final int a = 0; } class MayNotBeStatic { @@ -130,7 +130,7 @@ public class Classes { enum E { A; - class NotStaticButCouldBe {} + class NotStaticButCouldBe {} // $ Alert } /** @@ -187,9 +187,9 @@ public class Classes { } /** Could be static. */ - private class SadlyNotStatic { + private class SadlyNotStatic { // $ Alert /** Could be static, provided the enclosing class is made static. */ - private class SadlyNotStaticToo { + private class SadlyNotStaticToo { // $ Alert } } @@ -203,26 +203,26 @@ public class Classes { } } - private class MaybeStatic11 { + private class MaybeStatic11 { // $ Alert { new MaybeStatic11(); } } - private class MaybeStatic12 { + private class MaybeStatic12 { // $ Alert { new Classes().new NotStatic(); } } - private class MaybeStatic13 { + private class MaybeStatic13 { // $ Alert { new Static(); } } - class CouldBeStatic { + class CouldBeStatic { // $ Alert { new Object() { class CannotBeStatic { } }; } - class CouldBeStatic2 { + class CouldBeStatic2 { // $ Alert int i; class NotStatic { { @@ -252,7 +252,7 @@ public class Classes { } /** Has an inner anonymous class with a field initializer accessing a member of this class. */ - class CouldBeStatic3 { + class CouldBeStatic3 { // $ Alert int j; { new Object() { diff --git a/java/ql/test/query-tests/InnerClassCouldBeStatic/InnerClassCouldBeStatic.qlref b/java/ql/test/query-tests/InnerClassCouldBeStatic/InnerClassCouldBeStatic.qlref index 3d3b5444609..68cb3e6761e 100644 --- a/java/ql/test/query-tests/InnerClassCouldBeStatic/InnerClassCouldBeStatic.qlref +++ b/java/ql/test/query-tests/InnerClassCouldBeStatic/InnerClassCouldBeStatic.qlref @@ -1 +1,2 @@ -Performance/InnerClassCouldBeStatic.ql \ No newline at end of file +query: Performance/InnerClassCouldBeStatic.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/InnerClassCouldBeStatic/Test.java b/java/ql/test/query-tests/InnerClassCouldBeStatic/Test.java index 41926a6e230..92d39471a13 100644 --- a/java/ql/test/query-tests/InnerClassCouldBeStatic/Test.java +++ b/java/ql/test/query-tests/InnerClassCouldBeStatic/Test.java @@ -2,7 +2,7 @@ class Test { static class Super { public void test() {} } - class Sub extends Super { + class Sub extends Super { // $ Alert public void test2() { test(); } diff --git a/java/ql/test/query-tests/Iterable/IterableIterator.qlref b/java/ql/test/query-tests/Iterable/IterableIterator.qlref index 74c3aa86efa..b21ae41e640 100644 --- a/java/ql/test/query-tests/Iterable/IterableIterator.qlref +++ b/java/ql/test/query-tests/Iterable/IterableIterator.qlref @@ -1 +1,2 @@ -Language Abuse/IterableIterator.ql +query: Language Abuse/IterableIterator.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/Iterable/Test.java b/java/ql/test/query-tests/Iterable/Test.java index e44f8dd9c28..7978342a96f 100644 --- a/java/ql/test/query-tests/Iterable/Test.java +++ b/java/ql/test/query-tests/Iterable/Test.java @@ -9,7 +9,7 @@ class Test { List someStrings; void m() { - useIterable(new Iterable() { + useIterable(new Iterable() { // $ Alert[java/iterable-wraps-iterator] final Iterator i = someStrings.iterator(); // bad @Override @@ -72,7 +72,7 @@ class Test { public void remove() { } } - protected class ValueIterableBad implements Iterable { + protected class ValueIterableBad implements Iterable { // $ Alert[java/iterable-wraps-iterator] private ValueIterator iterator = new ValueIterator(); // bad @Override public Iterator iterator() { @@ -105,7 +105,7 @@ class Test { } } - class IntIteratorBad implements Iterable, Iterator { + class IntIteratorBad implements Iterable, Iterator { // $ Alert[java/iterator-implements-iterable] private int[] ints; private int idx = 0; IntIteratorBad(int[] ints) { diff --git a/java/ql/test/query-tests/Iterable/WrappedIterator.qlref b/java/ql/test/query-tests/Iterable/WrappedIterator.qlref index c21083fd818..ce208ed2f8a 100644 --- a/java/ql/test/query-tests/Iterable/WrappedIterator.qlref +++ b/java/ql/test/query-tests/Iterable/WrappedIterator.qlref @@ -1 +1,2 @@ -Language Abuse/WrappedIterator.ql +query: Language Abuse/WrappedIterator.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/IteratorRemoveMayFail/IteratorRemoveMayFail.qlref b/java/ql/test/query-tests/IteratorRemoveMayFail/IteratorRemoveMayFail.qlref index 614554885fe..3a9b278a015 100644 --- a/java/ql/test/query-tests/IteratorRemoveMayFail/IteratorRemoveMayFail.qlref +++ b/java/ql/test/query-tests/IteratorRemoveMayFail/IteratorRemoveMayFail.qlref @@ -1 +1,2 @@ -Likely Bugs/Collections/IteratorRemoveMayFail.ql \ No newline at end of file +query: Likely Bugs/Collections/IteratorRemoveMayFail.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/IteratorRemoveMayFail/Test.java b/java/ql/test/query-tests/IteratorRemoveMayFail/Test.java index 3ed2c563327..f06f8efb22d 100644 --- a/java/ql/test/query-tests/IteratorRemoveMayFail/Test.java +++ b/java/ql/test/query-tests/IteratorRemoveMayFail/Test.java @@ -13,7 +13,7 @@ public class Test { private static void removeOdd(Iterator iter) { while (iter.hasNext()) { if (iter.next()%2 != 0) - iter.remove(); + iter.remove(); // $ Alert } } } @@ -41,7 +41,7 @@ class A { class Parent { public void removeFirst(List l) { - l.iterator().remove(); + l.iterator().remove(); // $ Alert } } @@ -52,4 +52,4 @@ class Child extends Parent { removeFirst(Arrays.asList(ss)); } -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/Javadoc/ImpossibleJavadocThrows.java b/java/ql/test/query-tests/Javadoc/ImpossibleJavadocThrows.java index 7ba8988c38b..9795251ce9a 100644 --- a/java/ql/test/query-tests/Javadoc/ImpossibleJavadocThrows.java +++ b/java/ql/test/query-tests/Javadoc/ImpossibleJavadocThrows.java @@ -6,14 +6,14 @@ class ImpossibleJavadocThrows { /** * - * @throws InterruptedException + * @throws InterruptedException // $ Alert */ public void bad1() { } /** * - * @exception Exception + * @exception Exception // $ Alert */ public void bad2() { } @@ -31,4 +31,4 @@ class ImpossibleJavadocThrows { */ public void goodUnchecked(){ } -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/Javadoc/ImpossibleJavadocThrows.qlref b/java/ql/test/query-tests/Javadoc/ImpossibleJavadocThrows.qlref index 3f604bfc9d1..dc001712b07 100644 --- a/java/ql/test/query-tests/Javadoc/ImpossibleJavadocThrows.qlref +++ b/java/ql/test/query-tests/Javadoc/ImpossibleJavadocThrows.qlref @@ -1 +1,2 @@ -Advisory/Documentation/ImpossibleJavadocThrows.ql \ No newline at end of file +query: Advisory/Documentation/ImpossibleJavadocThrows.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/LShiftLargerThanTypeWidth/A.java b/java/ql/test/query-tests/LShiftLargerThanTypeWidth/A.java index a2f1f78506c..71383afbe5f 100644 --- a/java/ql/test/query-tests/LShiftLargerThanTypeWidth/A.java +++ b/java/ql/test/query-tests/LShiftLargerThanTypeWidth/A.java @@ -1,51 +1,51 @@ public class A { void test1(byte b, char c, short s, int i, long l) { long b1 = b << 31; // OK - long b2 = b << 32; // BAD - long b3 = b << 33; // BAD - long b4 = b << 64; // BAD + long b2 = b << 32; // $ Alert // BAD + long b3 = b << 33; // $ Alert // BAD + long b4 = b << 64; // $ Alert // BAD long c1 = c << 22; // OK - long c2 = c << 42; // BAD + long c2 = c << 42; // $ Alert // BAD long s1 = s << 22; // OK - long s2 = s << 42; // BAD + long s2 = s << 42; // $ Alert // BAD long i1 = i << 22; // OK - long i2 = i << 32; // BAD - long i3 = i << 42; // BAD - long i4 = i << 64; // BAD - long i5 = i << 65; // BAD + long i2 = i << 32; // $ Alert // BAD + long i3 = i << 42; // $ Alert // BAD + long i4 = i << 64; // $ Alert // BAD + long i5 = i << 65; // $ Alert // BAD long l1 = l << 22; // OK long l2 = l << 32; // OK long l3 = l << 42; // OK - long l4 = l << 64; // BAD - long l5 = l << 65; // BAD + long l4 = l << 64; // $ Alert // BAD + long l5 = l << 65; // $ Alert // BAD } void test2(Byte b, Character c, Short s, Integer i, Long l) { long b1 = b << 31; // OK - long b2 = b << 32; // BAD - long b3 = b << 33; // BAD - long b4 = b << 64; // BAD + long b2 = b << 32; // $ Alert // BAD + long b3 = b << 33; // $ Alert // BAD + long b4 = b << 64; // $ Alert // BAD long c1 = c << 22; // OK - long c2 = c << 42; // BAD + long c2 = c << 42; // $ Alert // BAD long s1 = s << 22; // OK - long s2 = s << 42; // BAD + long s2 = s << 42; // $ Alert // BAD long i1 = i << 22; // OK - long i2 = i << 32; // BAD - long i3 = i << 42; // BAD - long i4 = i << 64; // BAD - long i5 = i << 65; // BAD + long i2 = i << 32; // $ Alert // BAD + long i3 = i << 42; // $ Alert // BAD + long i4 = i << 64; // $ Alert // BAD + long i5 = i << 65; // $ Alert // BAD long l1 = l << 22; // OK long l2 = l << 32; // OK long l3 = l << 42; // OK - long l4 = l << 64; // BAD - long l5 = l << 65; // BAD + long l4 = l << 64; // $ Alert // BAD + long l5 = l << 65; // $ Alert // BAD } } diff --git a/java/ql/test/query-tests/LShiftLargerThanTypeWidth/LShiftLargerThanTypeWidth.qlref b/java/ql/test/query-tests/LShiftLargerThanTypeWidth/LShiftLargerThanTypeWidth.qlref index 5e3fa630b7d..5f6b6243296 100644 --- a/java/ql/test/query-tests/LShiftLargerThanTypeWidth/LShiftLargerThanTypeWidth.qlref +++ b/java/ql/test/query-tests/LShiftLargerThanTypeWidth/LShiftLargerThanTypeWidth.qlref @@ -1 +1,2 @@ -Likely Bugs/Arithmetic/LShiftLargerThanTypeWidth.ql +query: Likely Bugs/Arithmetic/LShiftLargerThanTypeWidth.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/LazyInitStaticField/LazyInitStaticField.qlref b/java/ql/test/query-tests/LazyInitStaticField/LazyInitStaticField.qlref index 3d83072e701..bba785935e5 100644 --- a/java/ql/test/query-tests/LazyInitStaticField/LazyInitStaticField.qlref +++ b/java/ql/test/query-tests/LazyInitStaticField/LazyInitStaticField.qlref @@ -1 +1,2 @@ -Likely Bugs/Concurrency/LazyInitStaticField.ql \ No newline at end of file +query: Likely Bugs/Concurrency/LazyInitStaticField.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/LazyInitStaticField/LazyInits.java b/java/ql/test/query-tests/LazyInitStaticField/LazyInits.java index 08440c20ea3..1faab5c5a5f 100644 --- a/java/ql/test/query-tests/LazyInitStaticField/LazyInits.java +++ b/java/ql/test/query-tests/LazyInitStaticField/LazyInits.java @@ -95,7 +95,7 @@ public class LazyInits { private static LazyInits bad1; public static LazyInits getBad1() { if (bad1 == null) - bad1 = new LazyInits(); + bad1 = new LazyInits(); // $ Alert return bad1; } @@ -105,7 +105,7 @@ public class LazyInits { if (bad2 == null) { synchronized(bad2) { if (bad2 == null) - bad2 = new LazyInits(); + bad2 = new LazyInits(); // $ Alert } } return bad2; @@ -117,7 +117,7 @@ public class LazyInits { if (bad3 == null) { synchronized(Object.class) { if (bad3 == null) - bad3 = new LazyInits(); + bad3 = new LazyInits(); // $ Alert } } return bad3; @@ -129,7 +129,7 @@ public class LazyInits { if (bad4 == null) { synchronized(LazyInits.class) { if (bad4 == null) - bad4 = new LazyInits(); + bad4 = new LazyInits(); // $ Alert } } return bad4; @@ -141,7 +141,7 @@ public class LazyInits { if (bad5 == null) { synchronized(lock) { if (bad5 == null) - bad5 = new LazyInits(); + bad5 = new LazyInits(); // $ Alert } } return bad5; @@ -153,7 +153,7 @@ public class LazyInits { if (bad6 == null) { synchronized(badLock) { if (bad6 == null) - bad6 = new LazyInits(); + bad6 = new LazyInits(); // $ Alert } } return bad6; @@ -174,4 +174,4 @@ public class LazyInits { okLock.unlock(); } } -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/Likely Bugs/Statements/MissingEnumInSwitch/MissingEnumInSwitch.qlref b/java/ql/test/query-tests/Likely Bugs/Statements/MissingEnumInSwitch/MissingEnumInSwitch.qlref index 10f1b3e8be2..74fae365410 100644 --- a/java/ql/test/query-tests/Likely Bugs/Statements/MissingEnumInSwitch/MissingEnumInSwitch.qlref +++ b/java/ql/test/query-tests/Likely Bugs/Statements/MissingEnumInSwitch/MissingEnumInSwitch.qlref @@ -1 +1,2 @@ -Likely Bugs/Statements/MissingEnumInSwitch.ql +query: Likely Bugs/Statements/MissingEnumInSwitch.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/Likely Bugs/Statements/MissingEnumInSwitch/Test.java b/java/ql/test/query-tests/Likely Bugs/Statements/MissingEnumInSwitch/Test.java index 2f39918ead4..ff75940c857 100644 --- a/java/ql/test/query-tests/Likely Bugs/Statements/MissingEnumInSwitch/Test.java +++ b/java/ql/test/query-tests/Likely Bugs/Statements/MissingEnumInSwitch/Test.java @@ -5,32 +5,32 @@ public class Test { } public void use(MyEnum e) { - switch(e) { + switch(e) { // $ Alert case A: break; } - switch(e) { + switch(e) { // $ Alert case A: break; case B: break; } - switch(e) { + switch(e) { // $ Alert case A: break; case B: break; case C: break; } - switch(e) { + switch(e) { // $ Alert case A: break; case B: break; case C: break; case D: break; } - switch(e) { + switch(e) { // $ Alert case A: break; case B: break; case C: break; case D: break; case E: break; } - switch(e) { + switch(e) { // $ Alert case A: break; case B: break; case C: break; @@ -53,7 +53,7 @@ public class Test { case T: break; case U: break; } - switch(e) { + switch(e) { // $ Alert case A: break; case B: break; case C: break; @@ -77,7 +77,7 @@ public class Test { case U: break; case V: break; } - switch(e) { + switch(e) { // $ Alert case A: break; case B: break; case C: break; @@ -102,7 +102,7 @@ public class Test { case V: break; case W: break; } - switch(e) { + switch(e) { // $ Alert case A: break; case B: break; case C: break; @@ -128,7 +128,7 @@ public class Test { case W: break; case X: break; } - switch(e) { + switch(e) { // $ Alert case A: break; case B: break; case C: break; diff --git a/java/ql/test/query-tests/MissedTernaryOpportunity/MissedTernaryOpportunity.qlref b/java/ql/test/query-tests/MissedTernaryOpportunity/MissedTernaryOpportunity.qlref index 8ad93d27f52..4d45b7edd2f 100644 --- a/java/ql/test/query-tests/MissedTernaryOpportunity/MissedTernaryOpportunity.qlref +++ b/java/ql/test/query-tests/MissedTernaryOpportunity/MissedTernaryOpportunity.qlref @@ -1 +1,2 @@ -Language Abuse/MissedTernaryOpportunity.ql \ No newline at end of file +query: Language Abuse/MissedTernaryOpportunity.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/MissedTernaryOpportunity/MissedTernaryOpportunityTest.java b/java/ql/test/query-tests/MissedTernaryOpportunity/MissedTernaryOpportunityTest.java index 34dab78f14f..b463c7ad545 100644 --- a/java/ql/test/query-tests/MissedTernaryOpportunity/MissedTernaryOpportunityTest.java +++ b/java/ql/test/query-tests/MissedTernaryOpportunity/MissedTernaryOpportunityTest.java @@ -3,7 +3,7 @@ import java.util.*; public class MissedTernaryOpportunityTest { public static boolean missedOpportunity1(int a){ - if(a == 42) + if(a == 42) // $ Alert return true; else return false; @@ -29,7 +29,7 @@ public class MissedTernaryOpportunityTest { public static boolean missedOpportunity2(int a){ boolean ret; - if(a == 42) + if(a == 42) // $ Alert ret = true; else ret = false; @@ -71,7 +71,7 @@ public class MissedTernaryOpportunityTest { } public static boolean missedOpportunity3(int a){ - if(a == 42) + if(a == 42) // $ Alert return true; else return someOtherFn(a); @@ -130,7 +130,7 @@ public class MissedTernaryOpportunityTest { // same variables, different qualification public void missedOpportunity4(int a){ - if(a > 42) + if(a > 42) // $ Alert memberVar1 = "hey"; else MissedTernaryOpportunityTest.this.memberVar1 = "ho"; @@ -142,7 +142,7 @@ public class MissedTernaryOpportunityTest { System.out.println("something"); return false; }else{ - if(a == 42) + if(a == 42) // $ Alert return true; else return false; @@ -152,7 +152,7 @@ public class MissedTernaryOpportunityTest { // nested if public boolean missedOpportunity6(int a){ if(a > 42){ - if(a == 42) + if(a == 42) // $ Alert return true; else return false; diff --git a/java/ql/test/query-tests/MissingCallToSuperClone/MissingCallToSuperClone.qlref b/java/ql/test/query-tests/MissingCallToSuperClone/MissingCallToSuperClone.qlref index 5e9ed3758ee..3939e6de8f0 100644 --- a/java/ql/test/query-tests/MissingCallToSuperClone/MissingCallToSuperClone.qlref +++ b/java/ql/test/query-tests/MissingCallToSuperClone/MissingCallToSuperClone.qlref @@ -1 +1,2 @@ -Likely Bugs/Cloning/MissingCallToSuperClone.ql +query: Likely Bugs/Cloning/MissingCallToSuperClone.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/MissingCallToSuperClone/Test.java b/java/ql/test/query-tests/MissingCallToSuperClone/Test.java index a236543a695..e0286c37930 100644 --- a/java/ql/test/query-tests/MissingCallToSuperClone/Test.java +++ b/java/ql/test/query-tests/MissingCallToSuperClone/Test.java @@ -7,7 +7,7 @@ class IAmAGoodCloneable implements Cloneable { class Sub1 extends IAmAGoodCloneable { public Object clone() throws CloneNotSupportedException { return super.clone(); } } class IAmABadCloneable implements Cloneable { - public Object clone() { + public Object clone() { // $ Alert return null; } } diff --git a/java/ql/test/query-tests/MissingInstanceofInEquals/Bad.java b/java/ql/test/query-tests/MissingInstanceofInEquals/Bad.java index 63cdf14fddd..0f22d47cab2 100644 --- a/java/ql/test/query-tests/MissingInstanceofInEquals/Bad.java +++ b/java/ql/test/query-tests/MissingInstanceofInEquals/Bad.java @@ -10,10 +10,10 @@ class Bad { } @Override - public boolean equals(Object obj) { + public boolean equals(Object obj) { // $ Alert Bad other = (Bad) obj; if (data != other.data) return false; return true; } -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/MissingInstanceofInEquals/MissingInstanceofInEquals.qlref b/java/ql/test/query-tests/MissingInstanceofInEquals/MissingInstanceofInEquals.qlref index 40038cf027a..d1a5c7d8130 100644 --- a/java/ql/test/query-tests/MissingInstanceofInEquals/MissingInstanceofInEquals.qlref +++ b/java/ql/test/query-tests/MissingInstanceofInEquals/MissingInstanceofInEquals.qlref @@ -1 +1,2 @@ -Likely Bugs/Comparison/MissingInstanceofInEquals.ql \ No newline at end of file +query: Likely Bugs/Comparison/MissingInstanceofInEquals.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/MissingOverrideAnnotation/MissingOverrideAnnotation.qlref b/java/ql/test/query-tests/MissingOverrideAnnotation/MissingOverrideAnnotation.qlref index c74780e7d24..885c1312f9e 100644 --- a/java/ql/test/query-tests/MissingOverrideAnnotation/MissingOverrideAnnotation.qlref +++ b/java/ql/test/query-tests/MissingOverrideAnnotation/MissingOverrideAnnotation.qlref @@ -1 +1,2 @@ -Advisory/Declarations/MissingOverrideAnnotation.ql \ No newline at end of file +query: Advisory/Declarations/MissingOverrideAnnotation.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/MissingOverrideAnnotation/Test.java b/java/ql/test/query-tests/MissingOverrideAnnotation/Test.java index e74026cf6ef..cdadb8b7818 100644 --- a/java/ql/test/query-tests/MissingOverrideAnnotation/Test.java +++ b/java/ql/test/query-tests/MissingOverrideAnnotation/Test.java @@ -15,7 +15,7 @@ class Super { public class Test extends Super { // NOT OK - int m() { + int m() { // $ Alert return 42; } @@ -32,4 +32,4 @@ public class Test extends Super { // OK Arrays.asList(1,2).stream().map(x -> x+1).collect(Collectors.toList()); } -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/MissingSpaceTypo/A.java b/java/ql/test/query-tests/MissingSpaceTypo/A.java index bf40bbaa27a..a095d8568d8 100644 --- a/java/ql/test/query-tests/MissingSpaceTypo/A.java +++ b/java/ql/test/query-tests/MissingSpaceTypo/A.java @@ -1,20 +1,20 @@ public class A { public void missing() { String s; - s = "this text" + - "is missing a space"; - s = "the class java.util.ArrayList" + - "without a space"; - s = "This isn't" + - "right."; - s = "There's 1" + - "thing wrong"; - s = "There's A/B" + - "and no space"; - s = "Wait for it...." + - "No space!"; - s = "Is there a space?" + - "No!"; + s = "this text" + // $ + "is missing a space"; // $ Alert + s = "the class java.util.ArrayList" + // $ + "without a space"; // $ Alert + s = "This isn't" + // $ + "right."; // $ Alert + s = "There's 1" + // $ + "thing wrong"; // $ Alert + s = "There's A/B" + // $ + "and no space"; // $ Alert + s = "Wait for it...." + // $ + "No space!"; // $ Alert + s = "Is there a space?" + // $ + "No!"; // $ Alert } public void ok() { diff --git a/java/ql/test/query-tests/MissingSpaceTypo/MissingSpaceTypo.qlref b/java/ql/test/query-tests/MissingSpaceTypo/MissingSpaceTypo.qlref index b0ad55262d2..6eb5700aa4e 100644 --- a/java/ql/test/query-tests/MissingSpaceTypo/MissingSpaceTypo.qlref +++ b/java/ql/test/query-tests/MissingSpaceTypo/MissingSpaceTypo.qlref @@ -1 +1,2 @@ -Likely Bugs/Likely Typos/MissingSpaceTypo.ql +query: Likely Bugs/Likely Typos/MissingSpaceTypo.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/MissingVoidConstructorsOnSerializable/MissingVoidConstructorsOnSerializable.qlref b/java/ql/test/query-tests/MissingVoidConstructorsOnSerializable/MissingVoidConstructorsOnSerializable.qlref index 26bbcf24bbb..220dcc04752 100644 --- a/java/ql/test/query-tests/MissingVoidConstructorsOnSerializable/MissingVoidConstructorsOnSerializable.qlref +++ b/java/ql/test/query-tests/MissingVoidConstructorsOnSerializable/MissingVoidConstructorsOnSerializable.qlref @@ -1 +1,2 @@ -Likely Bugs/Serialization/MissingVoidConstructorsOnSerializable.ql +query: Likely Bugs/Serialization/MissingVoidConstructorsOnSerializable.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/MissingVoidConstructorsOnSerializable/Test.java b/java/ql/test/query-tests/MissingVoidConstructorsOnSerializable/Test.java index f20f5ac8f49..579aa276070 100644 --- a/java/ql/test/query-tests/MissingVoidConstructorsOnSerializable/Test.java +++ b/java/ql/test/query-tests/MissingVoidConstructorsOnSerializable/Test.java @@ -9,7 +9,7 @@ class NonSerializable { } // BAD: Serializable but its parent cannot be instantiated -class A extends NonSerializable implements Serializable { +class A extends NonSerializable implements Serializable { // $ Alert public A() { super(1); } } diff --git a/java/ql/test/query-tests/MutualDependency/MutualDependency.qlref b/java/ql/test/query-tests/MutualDependency/MutualDependency.qlref index ab1dbe353ef..273ed4d757a 100644 --- a/java/ql/test/query-tests/MutualDependency/MutualDependency.qlref +++ b/java/ql/test/query-tests/MutualDependency/MutualDependency.qlref @@ -1 +1,2 @@ -Architecture/Dependencies/MutualDependency.ql \ No newline at end of file +query: Architecture/Dependencies/MutualDependency.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/MutualDependency/onepackage/MutualDependency.java b/java/ql/test/query-tests/MutualDependency/onepackage/MutualDependency.java index 31188ad5a52..13225f83869 100644 --- a/java/ql/test/query-tests/MutualDependency/onepackage/MutualDependency.java +++ b/java/ql/test/query-tests/MutualDependency/onepackage/MutualDependency.java @@ -7,7 +7,7 @@ public class MutualDependency { static int a = m; } // disallow inter-package dependencies - public static class B { + public static class B { // $ Alert public static int b = otherpackage.OtherClass.c; } } diff --git a/java/ql/test/query-tests/Naming/ConfusingOverloading.qlref b/java/ql/test/query-tests/Naming/ConfusingOverloading.qlref index 4fc71295c2c..e74bc1b00aa 100644 --- a/java/ql/test/query-tests/Naming/ConfusingOverloading.qlref +++ b/java/ql/test/query-tests/Naming/ConfusingOverloading.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Naming Conventions/ConfusingOverloading.ql \ No newline at end of file +query: Violations of Best Practice/Naming Conventions/ConfusingOverloading.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/Naming/NamingTest.java b/java/ql/test/query-tests/Naming/NamingTest.java index e6365ead8ef..75ee73b4eb7 100644 --- a/java/ql/test/query-tests/Naming/NamingTest.java +++ b/java/ql/test/query-tests/Naming/NamingTest.java @@ -4,7 +4,7 @@ import java.util.stream.*; public class NamingTest { public boolean equals(Object other) { return false; } - public boolean equals(NamingTest other) { return true; } + public boolean equals(NamingTest other) { return true; } // $ Alert public void visit(Object node) {} public void visit(NamingTest t) {} diff --git a/java/ql/test/query-tests/NonPrivateField/NonPrivateField.qlref b/java/ql/test/query-tests/NonPrivateField/NonPrivateField.qlref index 569bf88d8e5..e52cd3fa668 100644 --- a/java/ql/test/query-tests/NonPrivateField/NonPrivateField.qlref +++ b/java/ql/test/query-tests/NonPrivateField/NonPrivateField.qlref @@ -1 +1,2 @@ -Advisory/Declarations/NonPrivateField.ql +query: Advisory/Declarations/NonPrivateField.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/NonPrivateField/NonPrivateFieldTest.java b/java/ql/test/query-tests/NonPrivateField/NonPrivateFieldTest.java index c64af38ee50..a67c6ac7da6 100644 --- a/java/ql/test/query-tests/NonPrivateField/NonPrivateFieldTest.java +++ b/java/ql/test/query-tests/NonPrivateField/NonPrivateFieldTest.java @@ -5,15 +5,15 @@ public class NonPrivateFieldTest { public @interface Rule {} // JUnit-like annotation public static class Fields{ - public static String problematic1 = "value"; - public final int problematic2 = 0; - public final int problematic3; + public static String problematic1 = "value"; // $ Alert + public final int problematic2 = 0; // $ Alert + public final int problematic3; // $ Alert - final int problematic4 = 9; // omitted access descriptor - static int problematic5 = 0; - public int problematic6 = 0; - protected Double problematic7 = 0.0; // protected but not used in derived classes - static int[] problematic8; + final int problematic4 = 9; // $ Alert // omitted access descriptor + static int problematic5 = 0; // $ Alert + public int problematic6 = 0; // $ Alert + protected Double problematic7 = 0.0; // $ Alert // protected but not used in derived classes + static int[] problematic8; // $ Alert public static final int ok1 = 0; // public static finals are usually fine, even if not accessed by anything from outside public static int ok2 = 0; // foreign write access diff --git a/java/ql/test/query-tests/NonSerializableField/NonSerializableField.qlref b/java/ql/test/query-tests/NonSerializableField/NonSerializableField.qlref index 401d63757af..1b3b59559be 100644 --- a/java/ql/test/query-tests/NonSerializableField/NonSerializableField.qlref +++ b/java/ql/test/query-tests/NonSerializableField/NonSerializableField.qlref @@ -1 +1,2 @@ -Likely Bugs/Serialization/NonSerializableField.ql +query: Likely Bugs/Serialization/NonSerializableField.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/NonSerializableField/NonSerializableFieldTest.java b/java/ql/test/query-tests/NonSerializableField/NonSerializableFieldTest.java index 48022434c91..71b48e62d78 100644 --- a/java/ql/test/query-tests/NonSerializableField/NonSerializableFieldTest.java +++ b/java/ql/test/query-tests/NonSerializableField/NonSerializableFieldTest.java @@ -22,20 +22,20 @@ public class NonSerializableFieldTest { public static class MyColl extends HashMap{} public static class NotSerializable1 extends SerializableBase{ - NS problematic1; - List problematic2; - Map problematic3; - Map problematic4; - Map> problematic5; - Map problematic6; - List problematic7; - List problematic8; - T problematic9; - List problematic10; - List problematic11; - Map problematic12; - Map> problematic13; - Map problematic14; + NS problematic1; // $ Alert + List problematic2; // $ Alert + Map problematic3; // $ Alert + Map problematic4; // $ Alert + Map> problematic5; // $ Alert + Map problematic6; // $ Alert + List problematic7; // $ Alert + List problematic8; // $ Alert + T problematic9; // $ Alert + List problematic10; // $ Alert + List problematic11; // $ Alert + Map problematic12; // $ Alert + Map> problematic13; // $ Alert + Map problematic14; // $ Alert transient NS ok1; List ok2; @@ -76,7 +76,7 @@ public class NonSerializableFieldTest { public static void main(String[] args){ Anonymous a1 = new Anonymous(){ - NS problematic; + NS problematic; // $ Alert }; @SuppressWarnings("serial") @@ -106,7 +106,7 @@ public class NonSerializableFieldTest { @Stateful class StatefulSessionEjb extends SessionBean { - NonSerializableClass nonSerializableField; + NonSerializableClass nonSerializableField; // $ Alert } enum Enum { diff --git a/java/ql/test/query-tests/NonSerializableInnerClass/NonSerializableInnerClass.qlref b/java/ql/test/query-tests/NonSerializableInnerClass/NonSerializableInnerClass.qlref index 4cbb0995764..0ce5b0819e9 100644 --- a/java/ql/test/query-tests/NonSerializableInnerClass/NonSerializableInnerClass.qlref +++ b/java/ql/test/query-tests/NonSerializableInnerClass/NonSerializableInnerClass.qlref @@ -1 +1,2 @@ -Likely Bugs/Serialization/NonSerializableInnerClass.ql +query: Likely Bugs/Serialization/NonSerializableInnerClass.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/NonSerializableInnerClass/NonSerializableInnerClassTest.java b/java/ql/test/query-tests/NonSerializableInnerClass/NonSerializableInnerClassTest.java index 5fe5a6cafa3..55e15cdd0b9 100644 --- a/java/ql/test/query-tests/NonSerializableInnerClass/NonSerializableInnerClassTest.java +++ b/java/ql/test/query-tests/NonSerializableInnerClass/NonSerializableInnerClassTest.java @@ -11,9 +11,9 @@ public class NonSerializableInnerClassTest { public static class Outer1{ - public class Problematic1 implements Serializable{ } + public class Problematic1 implements Serializable{ } // $ Alert - public class Problematic2 extends S{ } + public class Problematic2 extends S{ } // $ Alert @SuppressWarnings("serial") @@ -48,8 +48,8 @@ public class NonSerializableInnerClassTest { public class Ok9 implements Serializable{ } } - public class Problematic3 extends S { - public class Problematic4 implements Serializable{ } // because NonSerializableInnerClassTest is not serializable + public class Problematic3 extends S { // $ Alert + public class Problematic4 implements Serializable{ } // $ Alert // because NonSerializableInnerClassTest is not serializable } // we currently ignore anonymous classes @@ -66,7 +66,7 @@ public class NonSerializableInnerClassTest { } // the class is not used anywhere, but the serialVersionUID field is an indicator for later serialization - private class Problematic7 implements Serializable{ + private class Problematic7 implements Serializable{ // $ Alert public static final long serialVersionUID = 123; } diff --git a/java/ql/test/query-tests/NonSynchronizedOverride/NonSynchronizedOverride.qlref b/java/ql/test/query-tests/NonSynchronizedOverride/NonSynchronizedOverride.qlref index f8c54049dce..324b7a4355c 100644 --- a/java/ql/test/query-tests/NonSynchronizedOverride/NonSynchronizedOverride.qlref +++ b/java/ql/test/query-tests/NonSynchronizedOverride/NonSynchronizedOverride.qlref @@ -1 +1,2 @@ -Likely Bugs/Concurrency/NonSynchronizedOverride.ql \ No newline at end of file +query: Likely Bugs/Concurrency/NonSynchronizedOverride.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/NonSynchronizedOverride/Test.java b/java/ql/test/query-tests/NonSynchronizedOverride/Test.java index dd537d12b3b..82ffa4b2650 100644 --- a/java/ql/test/query-tests/NonSynchronizedOverride/Test.java +++ b/java/ql/test/query-tests/NonSynchronizedOverride/Test.java @@ -13,7 +13,7 @@ class Super { class Sub extends Super { // NOT OK - void quack() { + void quack() { // $ Alert super.quack(); super.quack(); } @@ -24,7 +24,7 @@ class Sub extends Super { } // NOT OK - void foo() { + void foo() { // $ Alert super.bar(); } } @@ -35,10 +35,10 @@ class A { class B extends A { // NOT OK - void foo() {} + void foo() {} // $ Alert } class C extends A { // NOT OK - void foo() {} -} \ No newline at end of file + void foo() {} // $ Alert +} diff --git a/java/ql/test/query-tests/NotifyWithoutSynch/NotifyWithoutSynch.qlref b/java/ql/test/query-tests/NotifyWithoutSynch/NotifyWithoutSynch.qlref index fb6f44cc3e0..b05b6eb0c06 100644 --- a/java/ql/test/query-tests/NotifyWithoutSynch/NotifyWithoutSynch.qlref +++ b/java/ql/test/query-tests/NotifyWithoutSynch/NotifyWithoutSynch.qlref @@ -1 +1,2 @@ -Likely Bugs/Concurrency/NotifyWithoutSynch.ql +query: Likely Bugs/Concurrency/NotifyWithoutSynch.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/NotifyWithoutSynch/Test.java b/java/ql/test/query-tests/NotifyWithoutSynch/Test.java index 73982fc6586..7bd22fbbab3 100644 --- a/java/ql/test/query-tests/NotifyWithoutSynch/Test.java +++ b/java/ql/test/query-tests/NotifyWithoutSynch/Test.java @@ -7,7 +7,7 @@ class NotifyWithoutSynch { } public void fail_unqualified_wait() throws InterruptedException { - wait(); + wait(); // $ Alert } public synchronized void pass_unqualified_notify() throws InterruptedException { @@ -15,7 +15,7 @@ class NotifyWithoutSynch { } public void fail_unqualified_notify() throws InterruptedException { - notify(); + notify(); // $ Alert } public synchronized void pass_unqualified_notifyAll() throws InterruptedException { @@ -23,7 +23,7 @@ class NotifyWithoutSynch { } public void fail_unqualified_notifyAll() throws InterruptedException { - notifyAll(); + notifyAll(); // $ Alert } public void pass_unqualified_wait2() throws InterruptedException { @@ -49,32 +49,32 @@ class NotifyWithoutSynch { } public void fail_qualified_wait01() throws InterruptedException { - this.wait(); + this.wait(); // $ Alert } public void fail_qualified_wait02() throws InterruptedException { - this.wait(); + this.wait(); // $ Alert } public void fail_qualified_wait03() throws InterruptedException { synchronized(obj1) { - this.wait(); + this.wait(); // $ Alert } } public void fail_qualified_wait04() throws InterruptedException { synchronized(this) { - obj1.wait(); + obj1.wait(); // $ Alert } } public synchronized void fail_qualified_wait05() throws InterruptedException { - obj1.wait(); + obj1.wait(); // $ Alert } public synchronized void fail_qualified_wait06() throws InterruptedException { synchronized(obj1) { - obj2.wait(); + obj2.wait(); // $ Alert } } @@ -111,7 +111,7 @@ class NotifyWithoutSynch { } private void fail_indirect_callee14() throws InterruptedException { - wait(); + wait(); // $ Alert } public void fail_indirect_caller15() throws InterruptedException { diff --git a/java/ql/test/query-tests/Nullness/A.java b/java/ql/test/query-tests/Nullness/A.java index 065fffdbd3f..c40f6e898d5 100644 --- a/java/ql/test/query-tests/Nullness/A.java +++ b/java/ql/test/query-tests/Nullness/A.java @@ -12,7 +12,7 @@ public class A { } Object not = null; if (!(not != null)) { - not.hashCode(); + not.hashCode(); // $ Alert[java/dereferenced-value-is-always-null] } } @@ -45,7 +45,7 @@ public class A { Object assertNotNull_ok3 = maybe() ? null : new Object(); assertNonNull(assertNotNull_ok3, ""); - assertNotNull_ok3.toString(); + assertNotNull_ok3.toString(); // $ Alert[java/dereferenced-value-may-be-null] } public void assertTrueTest() { @@ -94,7 +94,7 @@ public class A { public void synchronised() { Object synchronized_always = null; - synchronized(synchronized_always) { + synchronized(synchronized_always) { // $ Alert[java/dereferenced-value-is-always-null] synchronized_always.hashCode(); } } @@ -158,18 +158,18 @@ public class A { String do_always = null; do { - System.out.println(do_always.length()); + System.out.println(do_always.length()); // $ Alert[java/dereferenced-value-is-always-null] do_always = null; } while(do_always != null); String do_maybe1 = null; do { - System.out.println(do_maybe1.length()); + System.out.println(do_maybe1.length()); // $ Alert[java/dereferenced-value-is-always-null] } while(do_maybe1 != null); String do_maybe = ""; do { - System.out.println(do_maybe.length()); + System.out.println(do_maybe.length()); // $ Alert[java/dereferenced-value-may-be-null] do_maybe = null; } while(true); } @@ -184,13 +184,13 @@ public class A { boolean TRUE = true; String while_always = null; while(TRUE) { - System.out.println(while_always.length()); + System.out.println(while_always.length()); // $ Alert[java/dereferenced-value-is-always-null] while_always = null; } String while_maybe = ""; while(true) { - System.out.println(while_maybe.length()); + System.out.println(while_maybe.length()); // $ Alert[java/dereferenced-value-may-be-null] while_maybe = null; } } @@ -204,7 +204,7 @@ public class A { String if_always = null; if (if_always == null) { - System.out.println(if_always.length()); + System.out.println(if_always.length()); // $ Alert[java/dereferenced-value-is-always-null] if_always = null; } @@ -212,7 +212,7 @@ public class A { if (if_maybe != null && if_maybe.length() % 2 == 0) { if_maybe = null; } - System.out.println(if_maybe.length()); + System.out.println(if_maybe.length()); // $ Alert[java/dereferenced-value-may-be-null] } public void for_() { @@ -220,20 +220,20 @@ public class A { for (for_ok = ""; for_ok != null; for_ok = null) { System.out.println(for_ok.length()); } - System.out.println(for_ok.length()); + System.out.println(for_ok.length()); // $ Alert[java/dereferenced-value-is-always-null] for (String for_always = null; ((for_always == null)); for_always = null) { - System.out.println(for_always.length()); + System.out.println(for_always.length()); // $ Alert[java/dereferenced-value-is-always-null] } for (String for_maybe = ""; ; for_maybe = null) { - System.out.println(for_maybe.length()); + System.out.println(for_maybe.length()); // $ Alert[java/dereferenced-value-may-be-null] } } public void array_assign_test() { int[] array_null = null; - array_null[0] = 10; + array_null[0] = 10; // $ Alert[java/dereferenced-value-is-always-null] int[] array_ok; array_ok = new int[10]; @@ -245,9 +245,9 @@ public class A { String[] fieldaccess = null; Object methodaccess = null; - System.out.println(arrayaccess[1]); - System.out.println(fieldaccess.length); - System.out.println(methodaccess.toString()); + System.out.println(arrayaccess[1]); // $ Alert[java/dereferenced-value-is-always-null] + System.out.println(fieldaccess.length); // $ Alert[java/dereferenced-value-is-always-null] + System.out.println(methodaccess.toString()); // $ Alert[java/dereferenced-value-is-always-null] System.out.println(arrayaccess[1]); System.out.println(fieldaccess.length); @@ -261,16 +261,16 @@ public class A { System.out.println(for_ok.size()); List for_always = null; - for (String s : for_always) + for (String s : for_always) // $ Alert[java/dereferenced-value-is-always-null] System.out.println(s); - System.out.println(for_always.size()); + System.out.println(for_always.size()); // $ Alert[java/dereferenced-value-is-always-null] List for_maybe = java.util.Collections.emptyList(); for (String s : for_maybe) { System.out.println(s); for_maybe = null; } - System.out.println(for_maybe.size()); + System.out.println(for_maybe.size()); // $ Alert[java/dereferenced-value-may-be-null] } public void assertFalseInstanceofTest() { @@ -290,7 +290,7 @@ public class A { public void assertFalseNotNullNestedTest() { Object s = String.valueOf(1); assertFalse(s != null || !"1".equals("1")); // assertTrue(s==null) - s.toString().isEmpty(); + s.toString().isEmpty(); // $ Alert[java/dereferenced-value-is-always-null] } public void testForLoopCondition(Iterable iter) { diff --git a/java/ql/test/query-tests/Nullness/B.java b/java/ql/test/query-tests/Nullness/B.java index 5759df2d236..14ff2b35935 100644 --- a/java/ql/test/query-tests/Nullness/B.java +++ b/java/ql/test/query-tests/Nullness/B.java @@ -13,14 +13,14 @@ public class B { } public void callee1(Object param) { - param.toString(); // NPE + param.toString(); // $ Alert[java/dereferenced-value-may-be-null] // NPE } public void callee2(Object param) { if (param != null) { param.toString(); // OK } - param.toString(); // NPE + param.toString(); // $ Alert[java/dereferenced-value-may-be-null] // NPE } private static boolean customIsNull(Object x) { @@ -54,7 +54,7 @@ public class B { if (ok) o7.hashCode(); // OK else - o7.hashCode(); // NPE + o7.hashCode(); // $ Alert[java/dereferenced-value-may-be-null] // NPE Object o8 = maybe ? null : ""; int track = o8 == null ? 42 : 1+1; @@ -66,16 +66,16 @@ public class B { public void deref() { int[] xs = maybe ? null : new int[2]; - if (2 > 1) xs[0] = 5; // NPE - if (2 > 1) maybe = xs[1] > 5; // NPE + if (2 > 1) xs[0] = 5; // $ Alert[java/dereferenced-value-may-be-null] // NPE + if (2 > 1) maybe = xs[1] > 5; // $ Alert[java/dereferenced-value-may-be-null] // NPE if (2 > 1) { - int l = xs.length; // NPE + int l = xs.length; // $ Alert[java/dereferenced-value-may-be-null] // NPE } if (2 > 1) { - for (int i : xs) { } // NPE + for (int i : xs) { } // $ Alert[java/dereferenced-value-may-be-null] // NPE } if (2 > 1) { - synchronized(xs) { // NPE + synchronized(xs) { // $ Alert[java/dereferenced-value-may-be-null] // NPE xs.hashCode(); // Not reported - same basic block } } @@ -115,7 +115,7 @@ public class B { } public void missedGuard(Object obj) { - obj.hashCode(); // NPE + obj.hashCode(); // $ Alert[java/dereferenced-value-may-be-null] // NPE int x = obj != null ? 1 : 0; } @@ -130,7 +130,7 @@ public class B { obj = mkMaybe(); } catch(Exception e) { } - obj.hashCode(); // NPE + obj.hashCode(); // $ Alert[java/dereferenced-value-may-be-null] // NPE Object obj2 = null; try { @@ -187,7 +187,7 @@ public class B { Object other = maybe ? null : ""; if (other == null) o = ""; if (other != null) - o.hashCode(); // NPE + o.hashCode(); // $ Alert[java/dereferenced-value-may-be-null] // NPE else o.hashCode(); // OK @@ -301,7 +301,7 @@ public class B { if (ioe != null) { ioe = e; } else { - ioe.getMessage(); // NPE; always + ioe.getMessage(); // $ Alert[java/dereferenced-value-is-always-null] // NPE; always } } @@ -331,7 +331,7 @@ public class B { x = new Object(); } if(y instanceof String) { - x.hashCode(); // Spurious NPE - false positive + x.hashCode(); // $ Alert[java/dereferenced-value-may-be-null] // Spurious NPE - false positive } } @@ -341,7 +341,7 @@ public class B { x = new Object(); } if(!(y instanceof String)) { - x.hashCode(); // Spurious NPE - false positive + x.hashCode(); // $ Alert[java/dereferenced-value-may-be-null] // Spurious NPE - false positive } } @@ -351,7 +351,7 @@ public class B { x = new Object(); } if(y == z) { - x.hashCode(); // Spurious NPE - false positive + x.hashCode(); // $ Alert[java/dereferenced-value-may-be-null] // Spurious NPE - false positive } Object x2 = null; @@ -359,7 +359,7 @@ public class B { x2 = new Object(); } if(y != z) { - x2.hashCode(); // Spurious NPE - false positive + x2.hashCode(); // $ Alert[java/dereferenced-value-may-be-null] // Spurious NPE - false positive } Object x3 = null; @@ -367,7 +367,7 @@ public class B { x3 = new Object(); } if(!(y == z)) { - x3.hashCode(); // Spurious NPE - false positive + x3.hashCode(); // $ Alert[java/dereferenced-value-may-be-null] // Spurious NPE - false positive } } @@ -405,7 +405,7 @@ public class B { g5 |= b; if (g5) { - x.hashCode(); // NPE + x.hashCode(); // $ Alert[java/dereferenced-value-may-be-null] // NPE } } @@ -417,7 +417,7 @@ public class B { x = null; } if (!b) { - x.hashCode(); // NPE + x.hashCode(); // $ Alert[java/dereferenced-value-may-be-null] // NPE } // flow can loop around from one iteration to the next } @@ -462,7 +462,7 @@ public class B { cur = a[i]; if (!prev) { // correctly guarded by !cur from the _previous_ iteration - x.hashCode(); // Spurious NPE - false positive + x.hashCode(); // $ Alert[java/dereferenced-value-may-be-null] // Spurious NPE - false positive } else { x = new Object(); } @@ -484,7 +484,7 @@ public class B { t = new Object(); } // correctly guarded by t: null -> String -> Object - x.hashCode(); // Spurious NPE - false positive + x.hashCode(); // $ Alert[java/dereferenced-value-may-be-null] // Spurious NPE - false positive } } } @@ -513,7 +513,7 @@ public class B { int c = -1; if (maybe) { } if (c == 100) { return; } - o.hashCode(); // NPE + o.hashCode(); // $ Alert[java/dereferenced-value-may-be-null] // NPE } public void testFinally(int[] xs, int[] ys) { @@ -532,9 +532,9 @@ public class B { } finally { } s1.hashCode(); // OK - s2.hashCode(); // NPE + s2.hashCode(); // $ Alert[java/dereferenced-value-may-be-null] // NPE } - s1.hashCode(); // NPE + s1.hashCode(); // $ Alert[java/dereferenced-value-may-be-null] // NPE } public void lenCheck(int[] xs, int n, int t) { @@ -573,7 +573,7 @@ public class B { } finally { } } - s.hashCode(); // Spurious NPE - false positive + s.hashCode(); // $ Alert[java/dereferenced-value-may-be-null] // Spurious NPE - false positive // CFG reachability does not distinguish abrupt successors } } diff --git a/java/ql/test/query-tests/Nullness/C.java b/java/ql/test/query-tests/Nullness/C.java index edd64cfa79b..0ecc0c23f88 100644 --- a/java/ql/test/query-tests/Nullness/C.java +++ b/java/ql/test/query-tests/Nullness/C.java @@ -6,8 +6,8 @@ public class C { long[][] a2 = null; boolean haveA2 = ix < len && (a2 = a1[ix]) != null; long[] a3 = null; - final boolean haveA3 = haveA2 && (a3 = a2[ix]) != null; // NPE - false positive - if (haveA3) a3[0] = 0; // NPE - false positive + final boolean haveA3 = haveA2 && (a3 = a2[ix]) != null; // $ Alert[java/dereferenced-value-may-be-null] // NPE - false positive + if (haveA3) a3[0] = 0; // $ Alert[java/dereferenced-value-may-be-null] // NPE - false positive } public void ex2(boolean x, boolean y) { @@ -18,7 +18,7 @@ public class C { s2 = (s1 == null) ? null : ""; } if (s2 != null) - s1.hashCode(); // NPE - false positive + s1.hashCode(); // $ Alert[java/dereferenced-value-may-be-null] // NPE - false positive } public void ex3(List ss) { @@ -48,7 +48,7 @@ public class C { slice = new ArrayList<>(); result.add(slice); } - slice.add(str); // NPE - false positive + slice.add(str); // $ Alert[java/dereferenced-value-may-be-null] // NPE - false positive ++index; iter.remove(); } @@ -141,7 +141,7 @@ public class C { public void ex10(int[] a) { int n = a == null ? 0 : a.length; for (int i = 0; i < n; i++) { - int x = a[i]; // NPE - false positive + int x = a[i]; // $ Alert[java/dereferenced-value-may-be-null] // NPE - false positive if (x > 7) a = new int[n]; } @@ -216,7 +216,7 @@ public class C { if (o1 == o2) { return; } - if (o1.equals(o2)) { // NPE - false positive + if (o1.equals(o2)) { // $ Alert[java/dereferenced-value-may-be-null] // NPE - false positive return; } } @@ -230,7 +230,7 @@ public class C { public static void ex16(C c) { int[] xs = c.getFoo16() != null ? new int[5] : null; if (c.getFoo16() != null) { - xs[0]++; // NPE - false positive + xs[0]++; // $ Alert[java/dereferenced-value-may-be-null] // NPE - false positive } } diff --git a/java/ql/test/query-tests/Nullness/ExprDeref.java b/java/ql/test/query-tests/Nullness/ExprDeref.java index 61aa9c4d8da..4a4c503d959 100644 --- a/java/ql/test/query-tests/Nullness/ExprDeref.java +++ b/java/ql/test/query-tests/Nullness/ExprDeref.java @@ -4,6 +4,6 @@ public class ExprDeref { } int unboxBad(boolean b) { - return (b ? null : getBoxed()); // NPE + return (b ? null : getBoxed()); // $ Alert[java/dereferenced-expr-may-be-null] // NPE } } diff --git a/java/ql/test/query-tests/Nullness/F.java b/java/ql/test/query-tests/Nullness/F.java index 6589c3d78fa..d1fd4348429 100644 --- a/java/ql/test/query-tests/Nullness/F.java +++ b/java/ql/test/query-tests/Nullness/F.java @@ -8,13 +8,13 @@ public class F { public void m2(Object obj) { if (obj == null) doStuff(); - obj.hashCode(); // NPE + obj.hashCode(); // $ Alert[java/dereferenced-value-may-be-null] // NPE } public void m3(Object obj) { if (obj == null) doStuffOrThrow(0); - obj.hashCode(); // NPE + obj.hashCode(); // $ Alert[java/dereferenced-value-may-be-null] // NPE } public static class MyException extends RuntimeException { diff --git a/java/ql/test/query-tests/Nullness/G.java b/java/ql/test/query-tests/Nullness/G.java index 9a525e8d14b..c8c69873299 100644 --- a/java/ql/test/query-tests/Nullness/G.java +++ b/java/ql/test/query-tests/Nullness/G.java @@ -17,7 +17,7 @@ public class G { case null, default -> "bar"; }; - switch(s) { // BAD; lack of a null case means this may throw. + switch(s) { // $ Alert[java/dereferenced-value-may-be-null] // BAD; lack of a null case means this may throw. case "foo" -> System.out.println("Foo"); case String s2 -> System.out.println("Other string of length " + s2.length()); } diff --git a/java/ql/test/query-tests/Nullness/NullAlways.qlref b/java/ql/test/query-tests/Nullness/NullAlways.qlref index a03818b411f..76df7c2751e 100644 --- a/java/ql/test/query-tests/Nullness/NullAlways.qlref +++ b/java/ql/test/query-tests/Nullness/NullAlways.qlref @@ -1 +1,2 @@ -Likely Bugs/Nullness/NullAlways.ql +query: Likely Bugs/Nullness/NullAlways.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/Nullness/NullExprDeref.qlref b/java/ql/test/query-tests/Nullness/NullExprDeref.qlref index 46dda091593..4ca963ecbcc 100644 --- a/java/ql/test/query-tests/Nullness/NullExprDeref.qlref +++ b/java/ql/test/query-tests/Nullness/NullExprDeref.qlref @@ -1 +1,2 @@ -Likely Bugs/Nullness/NullExprDeref.ql +query: Likely Bugs/Nullness/NullExprDeref.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/Nullness/NullMaybe.qlref b/java/ql/test/query-tests/Nullness/NullMaybe.qlref index ab01473d8e5..19125c7bc59 100644 --- a/java/ql/test/query-tests/Nullness/NullMaybe.qlref +++ b/java/ql/test/query-tests/Nullness/NullMaybe.qlref @@ -1 +1,2 @@ -Likely Bugs/Nullness/NullMaybe.ql +query: Likely Bugs/Nullness/NullMaybe.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/NumberFormatException/NumberFormatException.qlref b/java/ql/test/query-tests/NumberFormatException/NumberFormatException.qlref index 8d221a0854f..4f183d197af 100644 --- a/java/ql/test/query-tests/NumberFormatException/NumberFormatException.qlref +++ b/java/ql/test/query-tests/NumberFormatException/NumberFormatException.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Exception Handling/NumberFormatException.ql +query: Violations of Best Practice/Exception Handling/NumberFormatException.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/NumberFormatException/Test.java b/java/ql/test/query-tests/NumberFormatException/Test.java index b886116eb74..6f58bac8ba2 100644 --- a/java/ql/test/query-tests/NumberFormatException/Test.java +++ b/java/ql/test/query-tests/NumberFormatException/Test.java @@ -8,46 +8,46 @@ public class Test { } static void test1() { - Byte.parseByte("123"); - Byte.decode("123"); - Byte.valueOf("123"); - Byte.valueOf("123", 10); - Byte.valueOf("7f", 16); - new Byte("123"); + Byte.parseByte("123"); // $ Alert + Byte.decode("123"); // $ Alert + Byte.valueOf("123"); // $ Alert + Byte.valueOf("123", 10); // $ Alert + Byte.valueOf("7f", 16); // $ Alert + new Byte("123"); // $ Alert new Byte((byte) 123); // don't flag: wrong constructor - Short.parseShort("123"); - Short.decode("123"); - Short.valueOf("123"); - Short.valueOf("123", 10); - Short.valueOf("7abc", 16); - new Short("123"); + Short.parseShort("123"); // $ Alert + Short.decode("123"); // $ Alert + Short.valueOf("123"); // $ Alert + Short.valueOf("123", 10); // $ Alert + Short.valueOf("7abc", 16); // $ Alert + new Short("123"); // $ Alert new Short((short) 123); // don't flag: wrong constructor - Integer.parseInt("123"); - Integer.decode("123"); - Integer.valueOf("123"); - Integer.valueOf("123", 10); - Integer.valueOf("1234beef", 16); - new Integer("123"); + Integer.parseInt("123"); // $ Alert + Integer.decode("123"); // $ Alert + Integer.valueOf("123"); // $ Alert + Integer.valueOf("123", 10); // $ Alert + Integer.valueOf("1234beef", 16); // $ Alert + new Integer("123"); // $ Alert new Integer(123); // don't flag: wrong constructor - Long.parseLong("123"); - Long.decode("123"); - Long.valueOf("123"); - Long.valueOf("123", 10); - Long.valueOf("deadbeef", 16); - new Long("123"); + Long.parseLong("123"); // $ Alert + Long.decode("123"); // $ Alert + Long.valueOf("123"); // $ Alert + Long.valueOf("123", 10); // $ Alert + Long.valueOf("deadbeef", 16); // $ Alert + new Long("123"); // $ Alert new Long(123l); // don't flag: wrong constructor - Float.parseFloat("2.7818281828"); - Float.valueOf("2.7818281828"); - new Float("2.7818281828"); + Float.parseFloat("2.7818281828"); // $ Alert + Float.valueOf("2.7818281828"); // $ Alert + new Float("2.7818281828"); // $ Alert new Float(2.7818281828f); // don't flag: wrong constructor - Double.parseDouble("2.7818281828"); - Double.valueOf("2.7818281828"); - new Double("2.7818281828"); + Double.parseDouble("2.7818281828"); // $ Alert + Double.valueOf("2.7818281828"); // $ Alert + new Double("2.7818281828"); // $ Alert new Double(2.7818281828); // don't flag: wrong constructor } diff --git a/java/ql/test/query-tests/PartiallyMaskedCatch/PartiallyMaskedCatch.qlref b/java/ql/test/query-tests/PartiallyMaskedCatch/PartiallyMaskedCatch.qlref index c2db43d8953..a129d30287b 100644 --- a/java/ql/test/query-tests/PartiallyMaskedCatch/PartiallyMaskedCatch.qlref +++ b/java/ql/test/query-tests/PartiallyMaskedCatch/PartiallyMaskedCatch.qlref @@ -1 +1,2 @@ -Likely Bugs/Statements/PartiallyMaskedCatch.ql \ No newline at end of file +query: Likely Bugs/Statements/PartiallyMaskedCatch.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/PartiallyMaskedCatch/PartiallyMaskedCatchTest.java b/java/ql/test/query-tests/PartiallyMaskedCatch/PartiallyMaskedCatchTest.java index 4debe220f25..b5423a3c731 100644 --- a/java/ql/test/query-tests/PartiallyMaskedCatch/PartiallyMaskedCatchTest.java +++ b/java/ql/test/query-tests/PartiallyMaskedCatch/PartiallyMaskedCatchTest.java @@ -13,7 +13,7 @@ public class PartiallyMaskedCatchTest { // reachable: ExceptionB is thrown by invocation of CloseableThing.doThing() } catch (ExceptionA e) { // reachable: ExceptionA is thrown by implicit invocation of CloseableThing.close() - } catch (IOException e) { + } catch (IOException e) { // $ Alert // unreachable: only more specific exceptions are thrown and caught by previous catch blocks } @@ -23,7 +23,7 @@ public class PartiallyMaskedCatchTest { // reachable: ExceptionB is thrown by invocation of CloseableThing.doThing() } catch (ExceptionA | RuntimeException e) { // reachable: ExceptionA is thrown by implicit invocation of CloseableThing.close() - } catch (IOException e) { + } catch (IOException e) { // $ Alert // unreachable: only more specific exceptions are thrown and caught by previous catch blocks } @@ -33,7 +33,7 @@ public class PartiallyMaskedCatchTest { // reachable: ExceptionB is thrown by invocation of CloseableThing.doThing() } catch (ExceptionA | IllegalArgumentException e) { // reachable: ExceptionA is thrown by implicit invocation of CloseableThing.close() - } catch (IOException | RuntimeException e) { + } catch (IOException | RuntimeException e) { // $ Alert // unreachable for type IOException: only more specific exceptions are thrown and caught by previous catch blocks } diff --git a/java/ql/test/query-tests/PointlessForwardingMethod/PointlessForwardingMethod.qlref b/java/ql/test/query-tests/PointlessForwardingMethod/PointlessForwardingMethod.qlref index 310c4a6ae3e..ad8cb0f399d 100644 --- a/java/ql/test/query-tests/PointlessForwardingMethod/PointlessForwardingMethod.qlref +++ b/java/ql/test/query-tests/PointlessForwardingMethod/PointlessForwardingMethod.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Dead Code/PointlessForwardingMethod.ql +query: Violations of Best Practice/Dead Code/PointlessForwardingMethod.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/PointlessForwardingMethod/pointlessforwardingmethod/Test.java b/java/ql/test/query-tests/PointlessForwardingMethod/pointlessforwardingmethod/Test.java index 4810a4cefcf..a71b7c7382d 100644 --- a/java/ql/test/query-tests/PointlessForwardingMethod/pointlessforwardingmethod/Test.java +++ b/java/ql/test/query-tests/PointlessForwardingMethod/pointlessforwardingmethod/Test.java @@ -6,7 +6,7 @@ public class Test { return x + one; } - int addOne(byte x) { + int addOne(byte x) { // $ Alert return addOne(x, 1); } diff --git a/java/ql/test/query-tests/PrintLnArray/PrintLn.qlref b/java/ql/test/query-tests/PrintLnArray/PrintLn.qlref index 476f3f42e6e..ccb0525d55e 100644 --- a/java/ql/test/query-tests/PrintLnArray/PrintLn.qlref +++ b/java/ql/test/query-tests/PrintLnArray/PrintLn.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Undesirable Calls/PrintLnArray.ql \ No newline at end of file +query: Violations of Best Practice/Undesirable Calls/PrintLnArray.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/PrintLnArray/Test.java b/java/ql/test/query-tests/PrintLnArray/Test.java index 4890b892ce8..917091c21de 100644 --- a/java/ql/test/query-tests/PrintLnArray/Test.java +++ b/java/ql/test/query-tests/PrintLnArray/Test.java @@ -3,6 +3,6 @@ class Test { // OK: calls PrintStream.println(char[]) System.out.println(new char[] { 'H', 'i' }); // NOT OK: calls PrintStream.println(Object) - System.out.println(new byte[0]); + System.out.println(new byte[0]); // $ Alert } -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/RandomUsedOnce/RandomUsedOnce.qlref b/java/ql/test/query-tests/RandomUsedOnce/RandomUsedOnce.qlref index fa212fc3548..9dd0dd1812b 100644 --- a/java/ql/test/query-tests/RandomUsedOnce/RandomUsedOnce.qlref +++ b/java/ql/test/query-tests/RandomUsedOnce/RandomUsedOnce.qlref @@ -1 +1,2 @@ -Likely Bugs/Arithmetic/RandomUsedOnce.ql +query: Likely Bugs/Arithmetic/RandomUsedOnce.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/RandomUsedOnce/Test.java b/java/ql/test/query-tests/RandomUsedOnce/Test.java index 81ee1f0dd5a..d27779f6757 100644 --- a/java/ql/test/query-tests/RandomUsedOnce/Test.java +++ b/java/ql/test/query-tests/RandomUsedOnce/Test.java @@ -4,7 +4,7 @@ public class Test { public static void test() { - (new Random()).nextInt(); + (new Random()).nextInt(); // $ Alert } diff --git a/java/ql/test/query-tests/RangeAnalysis/A.java b/java/ql/test/query-tests/RangeAnalysis/A.java index b68de9beaa7..acd05fae9b8 100644 --- a/java/ql/test/query-tests/RangeAnalysis/A.java +++ b/java/ql/test/query-tests/RangeAnalysis/A.java @@ -16,14 +16,14 @@ public class A { void m1(int[] a) { int sum = 0; for (int i = 0; i <= a.length; i++) { - sum += a[i]; // Out of bounds + sum += a[i]; // $ Alert // Out of bounds } } void m2(int[] a) { int sum = 0; for (int i = 0; i < a.length; i += 2) { - sum += a[i] + a[i + 1]; // Out of bounds (unless len%2==0) + sum += a[i] + a[i + 1]; // $ Alert // Out of bounds (unless len%2==0) } } @@ -42,11 +42,11 @@ public class A { } for (int i = 0; i < arr2.length; ) { sum += arr2[i++]; // OK - sum += arr2[i++]; // OK - FP + sum += arr2[i++]; // $ Alert // OK - FP } for (int i = 0; i < arr3.length; ) { sum += arr3[i++]; // OK - sum += arr3[i++]; // OK - FP + sum += arr3[i++]; // $ Alert // OK - FP } int[] b; if (sum > 3) @@ -55,7 +55,7 @@ public class A { b = arr1; for (int i = 0; i < b.length; i++) { sum += b[i]; // OK - sum += b[++i]; // OK - FP + sum += b[++i]; // $ Alert // OK - FP } } @@ -86,7 +86,7 @@ public class A { int m6(int[] a, int ix) { if (ix < 0 || ix > a.length) return 0; - return a[ix]; // Out of bounds + return a[ix]; // $ Alert // Out of bounds } void m7() { @@ -97,7 +97,7 @@ public class A { sum += xs[i]; // OK sum += xs[j]; // OK if (i < j) - sum += xs[i + 11 - j]; // OK - FP + sum += xs[i + 11 - j]; // $ Alert // OK - FP else sum += xs[i - j]; // OK } @@ -110,8 +110,8 @@ public class A { int sum = 0; for (int i = 4; i < a.length; i += 3) { sum += a[i]; // OK - sum += a[i + 1]; // OK - FP - sum += a[i + 2]; // OK - FP + sum += a[i + 1]; // $ Alert // OK - FP + sum += a[i + 2]; // $ Alert // OK - FP } } @@ -122,7 +122,7 @@ public class A { if (i < 5) sum += a[i]; // OK else - sum += a[9 - i]; // OK - FP + sum += a[9 - i]; // $ Alert // OK - FP } } @@ -134,7 +134,7 @@ public class A { sum += a[i]; // OK for (int j = i + 1; j < len; j++) { sum += a[j]; // OK - sum += a[i + 1]; // OK - FP + sum += a[i + 1]; // $ Alert // OK - FP } } } @@ -182,7 +182,7 @@ public class A { void m14(int[] xs) { for (int i = 0; i < xs.length + 1; i++) { if (i == 0 && xs.length > 0) { - xs[i]++; // OK - FP + xs[i]++; // $ Alert // OK - FP } } } @@ -192,23 +192,23 @@ public class A { int x = ++i; int y = ++i; if (y < xs.length) { - xs[x]++; // OK - FP + xs[x]++; // $ Alert // OK - FP xs[y]++; // OK } } } static int m16() { - return A.arr1[(new Random()).nextInt(arr1.length + 1)] + // BAD: random int may be out of range + return A.arr1[(new Random()).nextInt(arr1.length + 1)] + // $ Alert // BAD: random int may be out of range A.arr1[(new Random()).nextInt(arr1.length)] + // GOOD: random int must be in range - A.arr1[RandomUtils.nextInt(0, arr1.length + 1)] + // BAD: random int may be out of range + A.arr1[RandomUtils.nextInt(0, arr1.length + 1)] + // $ Alert // BAD: random int may be out of range A.arr1[RandomUtils.nextInt(0, arr1.length)]; // GOOD: random int must be in range } int m17() { - return this.arr2[(new Random()).nextInt(arr2.length + 1)] + // BAD: random int may be out of range + return this.arr2[(new Random()).nextInt(arr2.length + 1)] + // $ Alert // BAD: random int may be out of range this.arr2[(new Random()).nextInt(arr2.length)] + // GOOD: random int must be in range - this.arr2[RandomUtils.nextInt(0, arr2.length + 1)] + // BAD: random int may be out of range + this.arr2[RandomUtils.nextInt(0, arr2.length + 1)] + // $ Alert // BAD: random int may be out of range this.arr2[RandomUtils.nextInt(0, arr2.length)]; // GOOD: random int must be in range } } diff --git a/java/ql/test/query-tests/RangeAnalysis/ArrayIndexOutOfBounds.qlref b/java/ql/test/query-tests/RangeAnalysis/ArrayIndexOutOfBounds.qlref index 439f2fd18de..a374970716f 100644 --- a/java/ql/test/query-tests/RangeAnalysis/ArrayIndexOutOfBounds.qlref +++ b/java/ql/test/query-tests/RangeAnalysis/ArrayIndexOutOfBounds.qlref @@ -1 +1,2 @@ -Likely Bugs/Collections/ArrayIndexOutOfBounds.ql +query: Likely Bugs/Collections/ArrayIndexOutOfBounds.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/ReadOnlyContainer/ReadOnlyContainer.qlref b/java/ql/test/query-tests/ReadOnlyContainer/ReadOnlyContainer.qlref index 2f4f5248a6b..623d63c7505 100644 --- a/java/ql/test/query-tests/ReadOnlyContainer/ReadOnlyContainer.qlref +++ b/java/ql/test/query-tests/ReadOnlyContainer/ReadOnlyContainer.qlref @@ -1 +1,2 @@ -Likely Bugs/Collections/ReadOnlyContainer.ql \ No newline at end of file +query: Likely Bugs/Collections/ReadOnlyContainer.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/ReadOnlyContainer/Test.java b/java/ql/test/query-tests/ReadOnlyContainer/Test.java index f4e75501bc8..7eb11a5784c 100644 --- a/java/ql/test/query-tests/ReadOnlyContainer/Test.java +++ b/java/ql/test/query-tests/ReadOnlyContainer/Test.java @@ -2,7 +2,7 @@ import java.util.*; public class Test { boolean containsDuplicates(Object[] array) { - Set seen = new HashSet(); + Set seen = new HashSet(); // $ Alert for (Object o : array) { // should be flagged if (seen.contains(o)) @@ -65,7 +65,7 @@ public class Test { } List g() { - List bl = new ArrayList(); + List bl = new ArrayList(); // $ Alert // should be flagged bl.contains(false); return bl; @@ -81,4 +81,4 @@ public class Test { return sneakySet.contains(x); } -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/ReturnValueIgnored/ReturnValueIgnored.qlref b/java/ql/test/query-tests/ReturnValueIgnored/ReturnValueIgnored.qlref index ef1dc964d95..ab13392ec55 100644 --- a/java/ql/test/query-tests/ReturnValueIgnored/ReturnValueIgnored.qlref +++ b/java/ql/test/query-tests/ReturnValueIgnored/ReturnValueIgnored.qlref @@ -1 +1,2 @@ -Likely Bugs/Statements/ReturnValueIgnored.ql \ No newline at end of file +query: Likely Bugs/Statements/ReturnValueIgnored.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/ReturnValueIgnored/return_value_ignored/Test.java b/java/ql/test/query-tests/ReturnValueIgnored/return_value_ignored/Test.java index 49ec7daf694..f736a12b764 100644 --- a/java/ql/test/query-tests/ReturnValueIgnored/return_value_ignored/Test.java +++ b/java/ql/test/query-tests/ReturnValueIgnored/return_value_ignored/Test.java @@ -38,7 +38,7 @@ public class Test implements I { foo = test3.getI(); foo = test1.getI(); foo = test2.getI(); - test3.getI(); + test3.getI(); // $ Alert // test setter; shouldn't flag last call Test test; @@ -86,6 +86,6 @@ public class Test implements I { t = s.trim(); t = s.trim(); t = s.trim(); - s.trim(); + s.trim(); // $ Alert } } diff --git a/java/ql/test/query-tests/SelfAssignment/SelfAssignment.qlref b/java/ql/test/query-tests/SelfAssignment/SelfAssignment.qlref index de3fdee7091..b56a4a66749 100644 --- a/java/ql/test/query-tests/SelfAssignment/SelfAssignment.qlref +++ b/java/ql/test/query-tests/SelfAssignment/SelfAssignment.qlref @@ -1 +1,2 @@ -Likely Bugs/Likely Typos/SelfAssignment.ql +query: Likely Bugs/Likely Typos/SelfAssignment.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/SelfAssignment/Test.java b/java/ql/test/query-tests/SelfAssignment/Test.java index 7b55fd4c1d0..2c89a4a49bf 100644 --- a/java/ql/test/query-tests/SelfAssignment/Test.java +++ b/java/ql/test/query-tests/SelfAssignment/Test.java @@ -3,7 +3,7 @@ class Outer { Outer(int x) { // NOT OK - x = x; + x = x; // $ Alert // OK this.x = x; } @@ -20,4 +20,4 @@ class Outer { // OK { x = Outer.this.x; } } -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/SimplifyBoolExpr/SimplifyBoolExpr.java b/java/ql/test/query-tests/SimplifyBoolExpr/SimplifyBoolExpr.java index 7d425e96d80..612acaa5c7a 100644 --- a/java/ql/test/query-tests/SimplifyBoolExpr/SimplifyBoolExpr.java +++ b/java/ql/test/query-tests/SimplifyBoolExpr/SimplifyBoolExpr.java @@ -1,16 +1,16 @@ class Test { void f(boolean x, boolean y, Boolean a, Boolean b) { boolean w; - w = a == false; - w = x != true; - w = a ? false : b; - w = a ? true : false; - w = x ? y : true; + w = a == false; // $ Alert + w = x != true; // $ Alert + w = a ? false : b; // $ Alert + w = a ? true : false; // $ Alert + w = x ? y : true; // $ Alert } void g(int x, int y) { boolean w; - w = !(x > y); - w = !(x != y); + w = !(x > y); // $ Alert + w = !(x != y); // $ Alert } public Boolean getBool(int i) { if (i > 2) @@ -19,7 +19,7 @@ class Test { } public Boolean getBoolNPE(int i) { if (i > 2) - return i == 3 ? true : ((Boolean)null); // should be reported; both this and the simplified version have equal NPE behavior - return i == 1 ? false : ((Boolean)null); // should be reported; both this and the simplified version have equal NPE behavior + return i == 3 ? true : ((Boolean)null); // $ Alert // should be reported; both this and the simplified version have equal NPE behavior + return i == 1 ? false : ((Boolean)null); // $ Alert // should be reported; both this and the simplified version have equal NPE behavior } } diff --git a/java/ql/test/query-tests/SimplifyBoolExpr/SimplifyBoolExpr.qlref b/java/ql/test/query-tests/SimplifyBoolExpr/SimplifyBoolExpr.qlref index d071e989ebb..45d0db5559c 100644 --- a/java/ql/test/query-tests/SimplifyBoolExpr/SimplifyBoolExpr.qlref +++ b/java/ql/test/query-tests/SimplifyBoolExpr/SimplifyBoolExpr.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Boolean Logic/SimplifyBoolExpr.ql +query: Violations of Best Practice/Boolean Logic/SimplifyBoolExpr.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/SpuriousJavadocParam/Test.java b/java/ql/test/query-tests/SpuriousJavadocParam/Test.java index d8891afb756..ca724cf468c 100644 --- a/java/ql/test/query-tests/SpuriousJavadocParam/Test.java +++ b/java/ql/test/query-tests/SpuriousJavadocParam/Test.java @@ -54,83 +54,83 @@ public class Test { protected void ok9(int...param){ } /** - * @param prameter typo + * @param prameter typo // $ Alert */ public void problem1(int parameter){ } /** - * @param Parameter capitalization + * @param Parameter capitalization // $ Alert */ public void problem2(int parameter){ } /** - * @param parameter unmatched + * @param parameter unmatched // $ Alert */ public void problem3(){ } /** * @param someOtherParameter matched - * @param parameter unmatched + * @param parameter unmatched // $ Alert */ public void problem4(int someOtherParameter){ } /** - * @param unmatched type parameter + * @param unmatched type parameter // $ Alert */ private T problem5(){ return null; } /** * @param matched type parameter - * @param

unmatched type parameter - * @param n unmatched normal parameter + * @param

unmatched type parameter // $ Alert + * @param n unmatched normal parameter // $ Alert */ private T problem6(V p){ return null; } /** * param with immediate newline - * @param + * @param // $ Alert */ protected void problem7(){ } /** * param without a value (followed by blanks) - * @param + * @param // $ Alert */ protected void problem8(){ } class SomeClass { /** * @param i exists - * @param k does not + * @param k does not // $ Alert */ SomeClass(int i, int j) {} } /** * @param exists - * @param T wrong syntax - * @param does not exist + * @param T wrong syntax // $ Alert + * @param does not exist // $ Alert */ class GenericClass {} /** * @param exists - * @param T wrong syntax - * @param does not exist + * @param T wrong syntax // $ Alert + * @param does not exist // $ Alert */ interface GenericInterface {} /** * @param i exists - * @param k does not + * @param k does not // $ Alert */ static record SomeRecord(int i, int j) {} /** * @param exists - * @param does not + * @param does not // $ Alert * @param i exists - * @param k does not + * @param k does not // $ Alert */ static record GenericRecord(int i, int j) {} } diff --git a/java/ql/test/query-tests/SpuriousJavadocParam/test.qlref b/java/ql/test/query-tests/SpuriousJavadocParam/test.qlref index 05f7231fe6b..85c1971658c 100644 --- a/java/ql/test/query-tests/SpuriousJavadocParam/test.qlref +++ b/java/ql/test/query-tests/SpuriousJavadocParam/test.qlref @@ -1 +1,2 @@ -Advisory/Documentation/SpuriousJavadocParam.ql +query: Advisory/Documentation/SpuriousJavadocParam.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/StartInConstructor/StartInConstructor.qlref b/java/ql/test/query-tests/StartInConstructor/StartInConstructor.qlref index 2f16c25c1ee..e27b98e9e72 100644 --- a/java/ql/test/query-tests/StartInConstructor/StartInConstructor.qlref +++ b/java/ql/test/query-tests/StartInConstructor/StartInConstructor.qlref @@ -1 +1,2 @@ -Likely Bugs/Concurrency/StartInConstructor.ql +query: Likely Bugs/Concurrency/StartInConstructor.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/StartInConstructor/Test.java b/java/ql/test/query-tests/StartInConstructor/Test.java index ae8148af787..58883af4ede 100644 --- a/java/ql/test/query-tests/StartInConstructor/Test.java +++ b/java/ql/test/query-tests/StartInConstructor/Test.java @@ -6,7 +6,7 @@ public class Test { public Test() { myThread = new Thread("myThread"); // BAD - myThread.start(); + myThread.start(); // $ Alert } public static final class Final { diff --git a/java/ql/test/query-tests/StaticArray/StaticArray.java b/java/ql/test/query-tests/StaticArray/StaticArray.java index 362d6fefcef..b24fa5526b1 100644 --- a/java/ql/test/query-tests/StaticArray/StaticArray.java +++ b/java/ql/test/query-tests/StaticArray/StaticArray.java @@ -1,6 +1,6 @@ class StaticArray { - public static final int[] bad = new int[42]; //NOT OK + public static final int[] bad = new int[42]; // $ Alert //NOT OK protected static final int[] good_protected = new int[42]; //OK (protected arrays are ok) /* default */ static final int[] good_default = new int[42]; //OK (default access arrays are ok) @@ -11,10 +11,10 @@ class StaticArray public /* final */ static int[] good_nonfinal = new int[42]; //OK (non-final arrays are ok) public static final Object good_not_array = new int[42]; //OK (non-arrays are ok) - public static final int[][][] bad_multidimensional = new int[42][42][42]; //NOT OK - public static final int[][][] bad_multidimensional_partial_init = new int[42][][]; //NOT OK + public static final int[][][] bad_multidimensional = new int[42][42][42]; // $ Alert //NOT OK + public static final int[][][] bad_multidimensional_partial_init = new int[42][][]; // $ Alert //NOT OK - public static final int[] bad_separate_init; //NOT OK + public static final int[] bad_separate_init; // $ Alert //NOT OK static { bad_separate_init = new int[42]; @@ -23,6 +23,6 @@ class StaticArray public static final int[] good_empty = new int[0]; //OK (empty array creation) public static final int[] good_empty2 = {}; //OK (empty array literal) public static final int[][] good_empty_multidimensional = new int[0][42]; //OK (empty array) - public static final int[][] bad_nonempty = { {} }; //NOT OK (first dimension is 1, so not empty) + public static final int[][] bad_nonempty = { {} }; // $ Alert //NOT OK (first dimension is 1, so not empty) } diff --git a/java/ql/test/query-tests/StaticArray/StaticArray.qlref b/java/ql/test/query-tests/StaticArray/StaticArray.qlref index 1c28ac13a16..f0cae39a882 100644 --- a/java/ql/test/query-tests/StaticArray/StaticArray.qlref +++ b/java/ql/test/query-tests/StaticArray/StaticArray.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Implementation Hiding/StaticArray.ql \ No newline at end of file +query: Violations of Best Practice/Implementation Hiding/StaticArray.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/StringComparison/StringComparison.java b/java/ql/test/query-tests/StringComparison/StringComparison.java index e777b75a3f1..f1156a3e706 100644 --- a/java/ql/test/query-tests/StringComparison/StringComparison.java +++ b/java/ql/test/query-tests/StringComparison/StringComparison.java @@ -20,13 +20,13 @@ class StringComparison { if("".equals(variable)) return; // NOT OK - if("" == variable) + if("" == variable) // $ Alert return; // NOT OK - if("" == param) + if("" == param) // $ Alert return; // NOT OK - if("" == variable2) + if("" == variable2) // $ Alert return; } } diff --git a/java/ql/test/query-tests/StringComparison/StringComparison.qlref b/java/ql/test/query-tests/StringComparison/StringComparison.qlref index a50debd9378..ecf6c270f7e 100644 --- a/java/ql/test/query-tests/StringComparison/StringComparison.qlref +++ b/java/ql/test/query-tests/StringComparison/StringComparison.qlref @@ -1 +1,2 @@ -Likely Bugs/Comparison/StringComparison.ql \ No newline at end of file +query: Likely Bugs/Comparison/StringComparison.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/StringFormat/A.java b/java/ql/test/query-tests/StringFormat/A.java index ff87290bcc9..88d651c8725 100644 --- a/java/ql/test/query-tests/StringFormat/A.java +++ b/java/ql/test/query-tests/StringFormat/A.java @@ -6,28 +6,28 @@ import java.io.File; public class A { void f_string() { - String.format("%s%s", ""); // missing + String.format("%s%s", ""); // $ Alert[java/missing-format-argument] // missing } void f_formatter(Formatter x) { - x.format("%s%s", ""); // missing + x.format("%s%s", ""); // $ Alert[java/missing-format-argument] // missing } void f_printstream(PrintStream x) { - x.format("%s%s", ""); // missing - x.printf("%s%s", ""); // missing + x.format("%s%s", ""); // $ Alert[java/missing-format-argument] // missing + x.printf("%s%s", ""); // $ Alert[java/missing-format-argument] // missing } void f_printwriter(PrintWriter x) { - x.format("%s%s", ""); // missing - x.printf("%s%s", ""); // missing + x.format("%s%s", ""); // $ Alert[java/missing-format-argument] // missing + x.printf("%s%s", ""); // $ Alert[java/missing-format-argument] // missing } void f_console(Console x) { - x.format("%s%s", ""); // missing - x.printf("%s%s", ""); // missing - x.readLine("%s%s", ""); // missing - x.readPassword("%s%s", ""); // missing + x.format("%s%s", ""); // $ Alert[java/missing-format-argument] // missing + x.printf("%s%s", ""); // $ Alert[java/missing-format-argument] // missing + x.readLine("%s%s", ""); // $ Alert[java/missing-format-argument] // missing + x.readPassword("%s%s", ""); // $ Alert[java/missing-format-argument] // missing } void custom_format(Object o, String fmt, Object... args) { @@ -35,20 +35,20 @@ public class A { } void f_wrapper() { - custom_format(new Object(), "%s%s", ""); // missing + custom_format(new Object(), "%s%s", ""); // $ Alert[java/missing-format-argument] // missing } void f() { - String.format("%s", "", ""); // unused - String.format("s", ""); // unused - String.format("%2$s %2$s", "", ""); // unused + String.format("%s", "", ""); // $ Alert[java/unused-format-argument] // unused + String.format("s", ""); // $ Alert[java/unused-format-argument] // unused + String.format("%2$s %2$s", "", ""); // $ Alert[java/unused-format-argument] // unused String.format("%2$s %1$s", "", ""); // ok - String.format("%2$s %s", ""); // missing - String.format("%s% { T t; void test(String s) { - t.equals(s); + t.equals(s); // $ Alert[java/equals-on-unrelated-types] t.equals(this); } } diff --git a/java/ql/test/query-tests/TypeMismatch/incomparable_equals/F.java b/java/ql/test/query-tests/TypeMismatch/incomparable_equals/F.java index 52c41537437..a87667dd9d4 100644 --- a/java/ql/test/query-tests/TypeMismatch/incomparable_equals/F.java +++ b/java/ql/test/query-tests/TypeMismatch/incomparable_equals/F.java @@ -2,6 +2,6 @@ package incomparable_equals; public class F { void m(int[] l, int[][] r) { - l.equals(r); + l.equals(r); // $ Alert[java/equals-on-unrelated-types] } -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/TypeMismatch/remove_type_mismatch/A.java b/java/ql/test/query-tests/TypeMismatch/remove_type_mismatch/A.java index 92b369da370..1dd72e43240 100644 --- a/java/ql/test/query-tests/TypeMismatch/remove_type_mismatch/A.java +++ b/java/ql/test/query-tests/TypeMismatch/remove_type_mismatch/A.java @@ -4,12 +4,12 @@ import java.util.Collection; public class A { void test1(Collection c, String s, StringBuffer b) { - c.remove(s); + c.remove(s); // $ Alert[java/type-mismatch-modification] c.remove(b); } void test2(Collection c, A a, String b) { - c.remove(a); + c.remove(a); // $ Alert[java/type-mismatch-modification] c.remove(b); } } @@ -20,7 +20,7 @@ class TestB { Collection coll2 = null; Collection coll3; { - coll3.remove(""); + coll3.remove(""); // $ Alert[java/type-mismatch-modification] } } @@ -30,7 +30,7 @@ class MyIntList extends java.util.LinkedList { class TestC { MyIntList mil; { - mil.remove(""); + mil.remove(""); // $ Alert[java/type-mismatch-modification] } } @@ -40,6 +40,6 @@ class MyOtherIntList extends java.util.LinkedList { class TestD { MyOtherIntList moil; { - moil.remove(""); + moil.remove(""); // $ Alert[java/type-mismatch-modification] } -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/UnreadLocal/A.java b/java/ql/test/query-tests/UnreadLocal/A.java index 5591df08634..928de6cd48c 100644 --- a/java/ql/test/query-tests/UnreadLocal/A.java +++ b/java/ql/test/query-tests/UnreadLocal/A.java @@ -26,18 +26,18 @@ public class A { public void ex2() { for (int i = 0; i < 5; i++) { int x = 42; - x = x + 3; // DEAD + x = x + 3; // $ Alert[java/useless-assignment-to-local] // DEAD } } public int ex3(int param) { - param += 3; // DEAD + param += 3; // $ Alert[java/overwritten-assignment-to-local] // DEAD param = 4; int x = 7; - ++x; // DEAD + ++x; // $ Alert[java/overwritten-assignment-to-local] // DEAD x = 10; int y = 5; - y = (++y) + 5; // DEAD (++y) + y = (++y) + 5; // $ Alert[java/overwritten-assignment-to-local] // DEAD (++y) return x + y + param; } @@ -52,7 +52,7 @@ public class A { } int x; try { - x = 5; // DEAD + x = 5; // $ Alert[java/overwritten-assignment-to-local] // DEAD ex3(0); x = 7; ex3(x); @@ -61,7 +61,7 @@ public class A { boolean valid; try { if (ex3(4) > 4) { - valid = false; // DEAD + valid = false; // $ Alert[java/overwritten-assignment-to-local] // DEAD } ex3(0); valid = true; diff --git a/java/ql/test/query-tests/UnreadLocal/DeadStoreOfLocal.qlref b/java/ql/test/query-tests/UnreadLocal/DeadStoreOfLocal.qlref index ece72e5295b..86820a14122 100644 --- a/java/ql/test/query-tests/UnreadLocal/DeadStoreOfLocal.qlref +++ b/java/ql/test/query-tests/UnreadLocal/DeadStoreOfLocal.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Dead Code/DeadStoreOfLocal.ql +query: Violations of Best Practice/Dead Code/DeadStoreOfLocal.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/UnreadLocal/DeadStoreOfLocalUnread.qlref b/java/ql/test/query-tests/UnreadLocal/DeadStoreOfLocalUnread.qlref index c3fbaae6b81..81c434f6606 100644 --- a/java/ql/test/query-tests/UnreadLocal/DeadStoreOfLocalUnread.qlref +++ b/java/ql/test/query-tests/UnreadLocal/DeadStoreOfLocalUnread.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Dead Code/DeadStoreOfLocalUnread.ql +query: Violations of Best Practice/Dead Code/DeadStoreOfLocalUnread.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/UnreadLocal/UnreadLocal.qlref b/java/ql/test/query-tests/UnreadLocal/UnreadLocal.qlref index 5a77117711e..dc6fb57ca6a 100644 --- a/java/ql/test/query-tests/UnreadLocal/UnreadLocal.qlref +++ b/java/ql/test/query-tests/UnreadLocal/UnreadLocal.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Dead Code/UnreadLocal.ql +query: Violations of Best Practice/Dead Code/UnreadLocal.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/UnreadLocal/UnreadLocal/ImplicitReads.java b/java/ql/test/query-tests/UnreadLocal/UnreadLocal/ImplicitReads.java index bd87047a086..236b97562f7 100644 --- a/java/ql/test/query-tests/UnreadLocal/UnreadLocal/ImplicitReads.java +++ b/java/ql/test/query-tests/UnreadLocal/UnreadLocal/ImplicitReads.java @@ -35,7 +35,7 @@ public class ImplicitReads System.out.println("test"); } // Assignment is useless - c = b; + c = b; // $ Alert[java/useless-assignment-to-local] // Not flagged due to implicit read in implicit finally block try(B d = b) {} } diff --git a/java/ql/test/query-tests/UnreadLocal/UnreadLocal/UnreadLocals.java b/java/ql/test/query-tests/UnreadLocal/UnreadLocal/UnreadLocals.java index 305b3947de6..5b2168b79d3 100644 --- a/java/ql/test/query-tests/UnreadLocal/UnreadLocal/UnreadLocals.java +++ b/java/ql/test/query-tests/UnreadLocal/UnreadLocal/UnreadLocals.java @@ -14,13 +14,13 @@ public class UnreadLocals public UnreadLocals () { - int alpha = 2; + int alpha = 2; // $ Alert[java/local-variable-is-never-read] int _beta = 4; this.alpha = 3; beta = _beta; Something something1 = new Something(); - Something something2 = new Something(); + Something something2 = new Something(); // $ Alert[java/local-variable-is-never-read] something = something1; diff --git a/java/ql/test/query-tests/UnreleasedLock/UnreleasedLock.java b/java/ql/test/query-tests/UnreleasedLock/UnreleasedLock.java index 2aadb5044be..4b97a239be4 100644 --- a/java/ql/test/query-tests/UnreleasedLock/UnreleasedLock.java +++ b/java/ql/test/query-tests/UnreleasedLock/UnreleasedLock.java @@ -12,7 +12,7 @@ class Test { MyLock mylock = new MyLock(); void bad1() { - mylock.lock(); + mylock.lock(); // $ Alert f(); mylock.unlock(); } @@ -27,7 +27,7 @@ class Test { } void bad3() { - mylock.lock(); + mylock.lock(); // $ Alert f(); try { g(); @@ -37,7 +37,7 @@ class Test { } void bad4() { - mylock.lock(); + mylock.lock(); // $ Alert try { f(); } finally { @@ -47,7 +47,7 @@ class Test { } void bad5(boolean lockmore) { - mylock.lock(); + mylock.lock(); // $ Alert try { f(); if (lockmore) { @@ -69,7 +69,7 @@ class Test { } void bad7() { - if (!mylock.tryLock()) { return; } + if (!mylock.tryLock()) { return; } // $ Alert f(); mylock.unlock(); } @@ -111,7 +111,7 @@ class Test { void bad10() { boolean locked = false; try { - locked = mylock.tryLock(); + locked = mylock.tryLock(); // $ Alert if (!locked) { return; } } finally { if (locked) { diff --git a/java/ql/test/query-tests/UnreleasedLock/UnreleasedLock.qlref b/java/ql/test/query-tests/UnreleasedLock/UnreleasedLock.qlref index 34ea40ac566..37dfff0e946 100644 --- a/java/ql/test/query-tests/UnreleasedLock/UnreleasedLock.qlref +++ b/java/ql/test/query-tests/UnreleasedLock/UnreleasedLock.qlref @@ -1 +1,2 @@ -Likely Bugs/Concurrency/UnreleasedLock.ql +query: Likely Bugs/Concurrency/UnreleasedLock.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/UseBraces/UseBraces.java b/java/ql/test/query-tests/UseBraces/UseBraces.java index 756050b2c44..0177d68571e 100644 --- a/java/ql/test/query-tests/UseBraces/UseBraces.java +++ b/java/ql/test/query-tests/UseBraces/UseBraces.java @@ -25,11 +25,11 @@ class UseBraces g(); // No alert if(1==1) - f(); + f(); // $ Alert g(); // Alert if(1==1) - f(); g(); // Alert + f(); g(); // $ Alert // Alert // If-then-else statement @@ -55,7 +55,7 @@ class UseBraces f(); } else - f(); + f(); // $ Alert g(); // Alert if(true) @@ -63,7 +63,7 @@ class UseBraces f(); } else - f(); g(); // Alert + f(); g(); // $ Alert // Alert // While statement @@ -79,12 +79,12 @@ class UseBraces g(); while(bb ) - f(); + f(); // $ Alert g(); // Alert g(); // No alert while(bb ) - f(); g(); // Alert + f(); g(); // $ Alert // Alert while(bb) @@ -109,11 +109,11 @@ class UseBraces g(); for(int i=0; i<10; ++i) - f(); + f(); // $ Alert g(); // Alert for(int i=0; i<10; ++i) - f(); g(); // Alert + f(); g(); // $ Alert // Alert // Foreach statement @@ -129,11 +129,11 @@ class UseBraces f(); for( int b : branches) - f(); + f(); // $ Alert g(); // Alert for( int b : branches) - f(); g(); // Alert + f(); g(); // $ Alert // Alert // Nested ifs if( true ) @@ -142,7 +142,7 @@ class UseBraces g(); // No alert if( true ) - if(false) + if(false) // $ Alert f(); g(); // Alert @@ -163,7 +163,7 @@ class UseBraces if( true ) ; else if (false) - f(); + f(); // $ Alert g(); // Alert // Nested combinations @@ -173,7 +173,7 @@ class UseBraces g(); // No alert if (true) - while (x<10) + while (x<10) // $ Alert f(); g(); // Alert @@ -183,7 +183,7 @@ class UseBraces g(); // No alert while (x<10) - if (true) + if (true) // $ Alert f(); g(); // Alert diff --git a/java/ql/test/query-tests/UseBraces/UseBraces.qlref b/java/ql/test/query-tests/UseBraces/UseBraces.qlref index 5d1d4a06388..e89389461d7 100644 --- a/java/ql/test/query-tests/UseBraces/UseBraces.qlref +++ b/java/ql/test/query-tests/UseBraces/UseBraces.qlref @@ -1 +1,2 @@ -Likely Bugs/Statements/UseBraces.ql +query: Likely Bugs/Statements/UseBraces.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/UselessComparisonTest/A.java b/java/ql/test/query-tests/UselessComparisonTest/A.java index abc525ff20d..a7689b49c52 100644 --- a/java/ql/test/query-tests/UselessComparisonTest/A.java +++ b/java/ql/test/query-tests/UselessComparisonTest/A.java @@ -12,35 +12,35 @@ public class A { x++; if (x - 1 == 2) return; x--; - if (x >= 2) unreachable(); // useless test + if (x >= 2) unreachable(); // $ Alert // useless test } if (y > 0) { int z = (x >= 0) ? x : y; - if (z < 0) unreachable(); // useless test + if (z < 0) unreachable(); // $ Alert // useless test } int k; while ((k = getInt()) >= 0) { - if (k < 0) unreachable(); // useless test + if (k < 0) unreachable(); // $ Alert // useless test } if (x > 0) { int z = x & y; - if (!(z <= x)) unreachable(); // useless test + if (!(z <= x)) unreachable(); // $ Alert // useless test } if (x % 2 == 0) { for (int i = 0; i < x; i+=2) { - if (i + 1 >= x) unreachable(); // useless test + if (i + 1 >= x) unreachable(); // $ Alert // useless test } } int r = new Random().nextInt(x); - if (r >= x) unreachable(); // useless test + if (r >= x) unreachable(); // $ Alert // useless test - if (x > Math.max(x, y)) unreachable(); // useless test - if (x < Math.min(x, y)) unreachable(); // useless test + if (x > Math.max(x, y)) unreachable(); // $ Alert // useless test + if (x < Math.min(x, y)) unreachable(); // $ Alert // useless test int w; if (x > 7) { @@ -52,17 +52,17 @@ public class A { } w--; w -= 2; - if (w <= 5) unreachable(); // useless test + if (w <= 5) unreachable(); // $ Alert // useless test while ((w--) > 0) { - if (w < 0) unreachable(); // useless test + if (w < 0) unreachable(); // $ Alert // useless test } - if (w != -1) unreachable(); // useless test + if (w != -1) unreachable(); // $ Alert // useless test if (x > 20) { int i; for (i = x; i > 0; i--) { } - if (i != 0) unreachable(); // useless test + if (i != 0) unreachable(); // $ Alert // useless test } if (getInt() > 0) { @@ -73,7 +73,7 @@ public class A { } else { if (z >= 4) return; } - if (z >= 4) unreachable(); // useless test + if (z >= 4) unreachable(); // $ Alert // useless test } int length = getInt(); @@ -81,11 +81,11 @@ public class A { int cnt = getInt(); length -= cnt; } - for (int i = 0; i < length; ++i) { } // useless test + for (int i = 0; i < length; ++i) { } // $ Alert // useless test int b = getInt(); if (b > 4) b = 8; - if (b > 8) unreachable(); // useless test + if (b > 8) unreachable(); // $ Alert // useless test int sz = getInt(); if (0 < x && x < sz) { diff --git a/java/ql/test/query-tests/UselessComparisonTest/CharLiterals.java b/java/ql/test/query-tests/UselessComparisonTest/CharLiterals.java index ac90e911ca6..90d8ee0b883 100644 --- a/java/ql/test/query-tests/UselessComparisonTest/CharLiterals.java +++ b/java/ql/test/query-tests/UselessComparisonTest/CharLiterals.java @@ -1,7 +1,7 @@ public class CharLiterals { public static boolean redundantSurrogateRange(char c) { if(c >= '\uda00') { - if(c >= '\ud900') { + if(c >= '\ud900') { // $ Alert return true; } } @@ -19,7 +19,7 @@ public class CharLiterals { public static boolean redundantNonSurrogateRange(char c) { if(c >= 'b') { - if(c >= 'a') { + if(c >= 'a') { // $ Alert return true; } } @@ -39,7 +39,7 @@ public class CharLiterals { if(c == '\uda00') { return true; } - else if(c == '\uda00') { + else if(c == '\uda00') { // $ Alert return true; } return false; @@ -59,7 +59,7 @@ public class CharLiterals { if(c == 'a') { return true; } - else if(c == 'a') { + else if(c == 'a') { // $ Alert return true; } return false; diff --git a/java/ql/test/query-tests/UselessComparisonTest/Test.java b/java/ql/test/query-tests/UselessComparisonTest/Test.java index eafac84dea5..a4c8e31706f 100644 --- a/java/ql/test/query-tests/UselessComparisonTest/Test.java +++ b/java/ql/test/query-tests/UselessComparisonTest/Test.java @@ -6,28 +6,28 @@ class Test { throw new Error(); } int y = 0; - if (x >= 0) y++; // useless test due to test in line 5 being false - if (z >= 0) y++; // useless test due to test in line 5 being false + if (x >= 0) y++; // $ Alert // useless test due to test in line 5 being false + if (z >= 0) y++; // $ Alert // useless test due to test in line 5 being false while(x >= 0) { if (y < 10) { z++; - if (y == 15) z++; // useless test due to test in line 12 being true + if (y == 15) z++; // $ Alert // useless test due to test in line 12 being true y++; z--; - } else if (y > 7) { // useless test due to test in line 12 being false + } else if (y > 7) { // $ Alert // useless test due to test in line 12 being false y--; } - if (!(y != 5) && z >= 0) { // z >= 0 is always true due to line 5 (and z being increasing) - int w = y < 3 ? 0 : 1; // useless test due to test in line 20 being true + if (!(y != 5) && z >= 0) { // $ Alert // z >= 0 is always true due to line 5 (and z being increasing) + int w = y < 3 ? 0 : 1; // $ Alert // useless test due to test in line 20 being true } x--; } } void test2(int x) { if (x != 0) { - int w = x == 0 ? 1 : 2; // useless test due to test in line 27 being true + int w = x == 0 ? 1 : 2; // $ Alert // useless test due to test in line 27 being true x--; - } else if (x == 0) { // useless test due to test in line 27 being false + } else if (x == 0) { // $ Alert // useless test due to test in line 27 being false x++; } } diff --git a/java/ql/test/query-tests/UselessComparisonTest/UselessComparisonTest.qlref b/java/ql/test/query-tests/UselessComparisonTest/UselessComparisonTest.qlref index d567af5db1b..fc8aaa7ab6f 100644 --- a/java/ql/test/query-tests/UselessComparisonTest/UselessComparisonTest.qlref +++ b/java/ql/test/query-tests/UselessComparisonTest/UselessComparisonTest.qlref @@ -1 +1,2 @@ -Likely Bugs/Comparison/UselessComparisonTest.ql +query: Likely Bugs/Comparison/UselessComparisonTest.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/UselessNullCheck/A.java b/java/ql/test/query-tests/UselessNullCheck/A.java index 009f5efadd3..232534c0e7f 100644 --- a/java/ql/test/query-tests/UselessNullCheck/A.java +++ b/java/ql/test/query-tests/UselessNullCheck/A.java @@ -1,12 +1,12 @@ public class A { void f() { Object o = new Object(); - if (o == null) { } // Useless check - if (o != null) { } // Useless check + if (o == null) { } // $ Alert // Useless check + if (o != null) { } // $ Alert // Useless check try { new Object(); } catch(Exception e) { - if (e == null) { // Useless check + if (e == null) { // $ Alert // Useless check throw new Error(); } } @@ -15,7 +15,7 @@ public class A { void g(Object o) { if (o instanceof A) { A a = (A)o; - if (a != null) { // Useless check + if (a != null) { // $ Alert // Useless check throw new Error(); } } @@ -28,7 +28,7 @@ public class A { I h() { final A x = this; return () -> { - if (x != null) { // Useless check + if (x != null) { // $ Alert // Useless check return x; } return new A(); @@ -37,9 +37,9 @@ public class A { Object f2(Object x) { if (x == null) { - return this != null ? this : null; // Useless check + return this != null ? this : null; // $ Alert // Useless check } - if (x != null) { // Useless check + if (x != null) { // $ Alert // Useless check return x; } return null; @@ -49,7 +49,7 @@ public class A { public void ex12() { finalObj.hashCode(); - if (finalObj != null) { // Useless check + if (finalObj != null) { // $ Alert // Useless check finalObj.hashCode(); } } diff --git a/java/ql/test/query-tests/UselessNullCheck/UselessNullCheck.qlref b/java/ql/test/query-tests/UselessNullCheck/UselessNullCheck.qlref index 8b5a095d396..68c4adcf428 100644 --- a/java/ql/test/query-tests/UselessNullCheck/UselessNullCheck.qlref +++ b/java/ql/test/query-tests/UselessNullCheck/UselessNullCheck.qlref @@ -1 +1,2 @@ -Language Abuse/UselessNullCheck.ql +query: Language Abuse/UselessNullCheck.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/UselessUpcast/Test.java b/java/ql/test/query-tests/UselessUpcast/Test.java index 497957da5f7..68debb06029 100644 --- a/java/ql/test/query-tests/UselessUpcast/Test.java +++ b/java/ql/test/query-tests/UselessUpcast/Test.java @@ -18,11 +18,11 @@ class Test extends TestSuper { // OK new Test((Super)s); // NOT OK - Super o = (Super)s; + Super o = (Super)s; // $ Alert // OK foo((Super)s); // NOT OK - bar((Super)s); + bar((Super)s); // $ Alert // OK baz((Super)s); // OK @@ -37,4 +37,4 @@ class Test extends TestSuper { void bar(Super o) {} void baz(Super o) {} -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/UselessUpcast/Test2.java b/java/ql/test/query-tests/UselessUpcast/Test2.java index 0ae86ec7923..c1c884b5b00 100644 --- a/java/ql/test/query-tests/UselessUpcast/Test2.java +++ b/java/ql/test/query-tests/UselessUpcast/Test2.java @@ -5,7 +5,7 @@ public class Test2 { public static void main(Sub[] args) { Map m = new HashMap<>(); Sub k = null, v = null; - m.put(k, (Super) v); + m.put(k, (Super) v); // $ Alert m.put(k, v); } -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/UselessUpcast/UselessUpcast.qlref b/java/ql/test/query-tests/UselessUpcast/UselessUpcast.qlref index f0a49b78b14..d48a3f98942 100644 --- a/java/ql/test/query-tests/UselessUpcast/UselessUpcast.qlref +++ b/java/ql/test/query-tests/UselessUpcast/UselessUpcast.qlref @@ -1 +1,2 @@ -Language Abuse/UselessUpcast.ql \ No newline at end of file +query: Language Abuse/UselessUpcast.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.java b/java/ql/test/query-tests/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.java index db76f4f7355..227f04137d5 100644 --- a/java/ql/test/query-tests/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.java +++ b/java/ql/test/query-tests/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.java @@ -1,6 +1,6 @@ public class WhitespaceContradictsPrecedence { int bad(int x) { - return x + x>>1; + return x + x>>1; // $ Alert } int ok1(int x) { @@ -26,4 +26,4 @@ public class WhitespaceContradictsPrecedence { int ok6(int x) { return x + x>> 1; } -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.qlref b/java/ql/test/query-tests/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.qlref index e8331b4132f..470fdcfe273 100644 --- a/java/ql/test/query-tests/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.qlref +++ b/java/ql/test/query-tests/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.qlref @@ -1 +1,2 @@ -Likely Bugs/Arithmetic/WhitespaceContradictsPrecedence.ql \ No newline at end of file +query: Likely Bugs/Arithmetic/WhitespaceContradictsPrecedence.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/WriteOnlyContainer/CollectionTest.java b/java/ql/test/query-tests/WriteOnlyContainer/CollectionTest.java index f6dced779fa..2f57771ceae 100644 --- a/java/ql/test/query-tests/WriteOnlyContainer/CollectionTest.java +++ b/java/ql/test/query-tests/WriteOnlyContainer/CollectionTest.java @@ -35,7 +35,7 @@ public class CollectionTest { } // should be flagged - private List useless = new ArrayList(); + private List useless = new ArrayList(); // $ Alert { useless.add(23); useless.remove(0); @@ -49,4 +49,4 @@ public class CollectionTest { @interface MyReflectionAnnotation {} @MyReflectionAnnotation private List l8 = new ArrayList(); -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/WriteOnlyContainer/MapTest.java b/java/ql/test/query-tests/WriteOnlyContainer/MapTest.java index 201b7134af5..ee7071513c0 100644 --- a/java/ql/test/query-tests/WriteOnlyContainer/MapTest.java +++ b/java/ql/test/query-tests/WriteOnlyContainer/MapTest.java @@ -35,7 +35,7 @@ public class MapTest { } // should be flagged - private Map useless = new HashMap(); + private Map useless = new HashMap(); // $ Alert { useless.put("hello", 23); useless.remove("hello"); @@ -49,4 +49,4 @@ public class MapTest { @interface MyReflectionAnnotation {} @MyReflectionAnnotation private Map l8 = new HashMap(); -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/WriteOnlyContainer/WriteOnlyContainer.qlref b/java/ql/test/query-tests/WriteOnlyContainer/WriteOnlyContainer.qlref index fc4d4c2a39b..9d2057a3d37 100644 --- a/java/ql/test/query-tests/WriteOnlyContainer/WriteOnlyContainer.qlref +++ b/java/ql/test/query-tests/WriteOnlyContainer/WriteOnlyContainer.qlref @@ -1 +1,2 @@ -Likely Bugs/Collections/WriteOnlyContainer.ql \ No newline at end of file +query: Likely Bugs/Collections/WriteOnlyContainer.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/WrongNanComparison/Test.java b/java/ql/test/query-tests/WrongNanComparison/Test.java index 23091818412..3bf6a12fd40 100644 --- a/java/ql/test/query-tests/WrongNanComparison/Test.java +++ b/java/ql/test/query-tests/WrongNanComparison/Test.java @@ -1,6 +1,6 @@ class Test { void f(double x, float y) { - if (x == Double.NaN) return; - if (y == Float.NaN) return; + if (x == Double.NaN) return; // $ Alert + if (y == Float.NaN) return; // $ Alert } } diff --git a/java/ql/test/query-tests/WrongNanComparison/WrongNanComparison.qlref b/java/ql/test/query-tests/WrongNanComparison/WrongNanComparison.qlref index 09e54ee1c1e..f22a5654255 100644 --- a/java/ql/test/query-tests/WrongNanComparison/WrongNanComparison.qlref +++ b/java/ql/test/query-tests/WrongNanComparison/WrongNanComparison.qlref @@ -1 +1,2 @@ -Likely Bugs/Comparison/WrongNanComparison.ql +query: Likely Bugs/Comparison/WrongNanComparison.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/dead-code/DeadCallable/DeadCallable.qlref b/java/ql/test/query-tests/dead-code/DeadCallable/DeadCallable.qlref index 76204a1df5a..743a5f15775 100644 --- a/java/ql/test/query-tests/dead-code/DeadCallable/DeadCallable.qlref +++ b/java/ql/test/query-tests/dead-code/DeadCallable/DeadCallable.qlref @@ -1 +1,2 @@ -DeadCode/DeadMethod.ql +query: DeadCode/DeadMethod.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/dead-code/DeadCallable/Main.java b/java/ql/test/query-tests/dead-code/DeadCallable/Main.java index 46153987d9a..55de2248270 100644 --- a/java/ql/test/query-tests/dead-code/DeadCallable/Main.java +++ b/java/ql/test/query-tests/dead-code/DeadCallable/Main.java @@ -1,17 +1,17 @@ -public class Main { +public class Main { // $ Alert private static String ss = "a"; private static String ss2 = "b"; private final String is = "a"; private final String is2 = "b"; - private void unused() { + private void unused() { // $ Alert indirectlyUnused(); } - private void indirectlyUnused() {} + private void indirectlyUnused() {} // $ Alert - private void foo() { bar(); } - private void bar() { foo(); } + private void foo() { bar(); } // $ Alert + private void bar() { foo(); } // $ Alert public static void main(String[] args) {} } diff --git a/java/ql/test/query-tests/dead-code/DeadClass/DeadClass.qlref b/java/ql/test/query-tests/dead-code/DeadClass/DeadClass.qlref index d726e7e0849..b94832ebfca 100644 --- a/java/ql/test/query-tests/dead-code/DeadClass/DeadClass.qlref +++ b/java/ql/test/query-tests/dead-code/DeadClass/DeadClass.qlref @@ -1 +1,2 @@ -DeadCode/DeadClass.ql +query: DeadCode/DeadClass.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/dead-code/DeadClass/DeadEnumTest.java b/java/ql/test/query-tests/dead-code/DeadClass/DeadEnumTest.java index 7e760a16e42..3163bb14dff 100644 --- a/java/ql/test/query-tests/dead-code/DeadClass/DeadEnumTest.java +++ b/java/ql/test/query-tests/dead-code/DeadClass/DeadEnumTest.java @@ -1,5 +1,5 @@ public class DeadEnumTest { - public enum DeadEnum { + public enum DeadEnum { // $ Alert A } diff --git a/java/ql/test/query-tests/dead-code/DeadClass/ExternalDeadCodeCycle.java b/java/ql/test/query-tests/dead-code/DeadClass/ExternalDeadCodeCycle.java index ab6fab276ff..40f661e602b 100644 --- a/java/ql/test/query-tests/dead-code/DeadClass/ExternalDeadCodeCycle.java +++ b/java/ql/test/query-tests/dead-code/DeadClass/ExternalDeadCodeCycle.java @@ -5,7 +5,7 @@ public class ExternalDeadCodeCycle { * This class should be marked as being only used from a dead code cycle, because the dead-code * cycle is external to the class. */ - public static class DeadClass { + public static class DeadClass { // $ Alert public static void deadMethod() { } } diff --git a/java/ql/test/query-tests/dead-code/DeadClass/ExternalDeadRoot.java b/java/ql/test/query-tests/dead-code/DeadClass/ExternalDeadRoot.java index e239e2bbec8..dbdec26093d 100644 --- a/java/ql/test/query-tests/dead-code/DeadClass/ExternalDeadRoot.java +++ b/java/ql/test/query-tests/dead-code/DeadClass/ExternalDeadRoot.java @@ -5,7 +5,7 @@ public class ExternalDeadRoot { * This class should be marked as only being used by the "outerDeadRoot()". The * "innerDeadRoot()" should not be reported as a dead root, as it is internal to the class. */ - public static class DeadClass { + public static class DeadClass { // $ Alert public static void innerDeadRoot() { } diff --git a/java/ql/test/query-tests/dead-code/DeadClass/InternalDeadCodeCycle.java b/java/ql/test/query-tests/dead-code/DeadClass/InternalDeadCodeCycle.java index 94079d6198c..cd0028d3a16 100644 --- a/java/ql/test/query-tests/dead-code/DeadClass/InternalDeadCodeCycle.java +++ b/java/ql/test/query-tests/dead-code/DeadClass/InternalDeadCodeCycle.java @@ -1,7 +1,7 @@ /** * This class should be marked as entirely unused. */ -public class InternalDeadCodeCycle { +public class InternalDeadCodeCycle { // $ Alert public void foo() { bar(); diff --git a/java/ql/test/query-tests/dead-code/DeadClass/NamespaceTest.java b/java/ql/test/query-tests/dead-code/DeadClass/NamespaceTest.java index f0ae44f2bf7..12b7f547aee 100644 --- a/java/ql/test/query-tests/dead-code/DeadClass/NamespaceTest.java +++ b/java/ql/test/query-tests/dead-code/DeadClass/NamespaceTest.java @@ -32,7 +32,7 @@ public class NamespaceTest { * This class is not a namespace class, because it has an instance method. The nested live class * should not make the NonNamespaceClass live. */ - public static class NonNamespaceClass { + public static class NonNamespaceClass { // $ Alert public static class LiveInnerClass2 { } diff --git a/java/ql/test/query-tests/dead-code/DeadEnumConstant/DeadEnumConstant.qlref b/java/ql/test/query-tests/dead-code/DeadEnumConstant/DeadEnumConstant.qlref index 45725063f34..7e720934da4 100644 --- a/java/ql/test/query-tests/dead-code/DeadEnumConstant/DeadEnumConstant.qlref +++ b/java/ql/test/query-tests/dead-code/DeadEnumConstant/DeadEnumConstant.qlref @@ -1 +1,2 @@ -DeadCode/DeadEnumConstant.ql +query: DeadCode/DeadEnumConstant.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/dead-code/DeadEnumConstant/DeadEnumConstantTest.java b/java/ql/test/query-tests/dead-code/DeadEnumConstant/DeadEnumConstantTest.java index ef6b2686b75..3e16c5305e4 100644 --- a/java/ql/test/query-tests/dead-code/DeadEnumConstant/DeadEnumConstantTest.java +++ b/java/ql/test/query-tests/dead-code/DeadEnumConstant/DeadEnumConstantTest.java @@ -5,8 +5,8 @@ public class DeadEnumConstantTest { public @interface MyAnnotation{}; public static enum E1{ - unused1, - unused2, + unused1, // $ Alert + unused2, // $ Alert @MyAnnotation ok1, // constants with reflective annotations should be ignored diff --git a/java/ql/test/query-tests/dead-code/DeadField/AnnotationValueTest.java b/java/ql/test/query-tests/dead-code/DeadField/AnnotationValueTest.java index 007915b161b..0dbfb578aa7 100644 --- a/java/ql/test/query-tests/dead-code/DeadField/AnnotationValueTest.java +++ b/java/ql/test/query-tests/dead-code/DeadField/AnnotationValueTest.java @@ -8,7 +8,7 @@ public class AnnotationValueTest { public static String liveField = ""; @TestAnnotation(value = AnnotationValueUtil.DEAD_STRING_CONSTANT_FIELD) - public static String deadField = ""; + public static String deadField = ""; // $ Alert @TestAnnotation(value = { AnnotationValueUtil.LIVE_STRING_CONSTANT_METHOD }) public static void liveMethod() { diff --git a/java/ql/test/query-tests/dead-code/DeadField/AnnotationValueUtil.java b/java/ql/test/query-tests/dead-code/DeadField/AnnotationValueUtil.java index 95a7129286f..0511eecb14a 100644 --- a/java/ql/test/query-tests/dead-code/DeadField/AnnotationValueUtil.java +++ b/java/ql/test/query-tests/dead-code/DeadField/AnnotationValueUtil.java @@ -19,9 +19,9 @@ public class AnnotationValueUtil { /** * These three should be dead because they are used as annotation values on dead fields/methods/classes. */ - public static final String DEAD_STRING_CONSTANT_FIELD = "A string constant."; - public static final String DEAD_STRING_CONSTANT_METHOD = "A string constant."; - public static final String DEAD_STRING_CONSTANT_CLASS = "A string constant."; + public static final String DEAD_STRING_CONSTANT_FIELD = "A string constant."; // $ Alert + public static final String DEAD_STRING_CONSTANT_METHOD = "A string constant."; // $ Alert + public static final String DEAD_STRING_CONSTANT_CLASS = "A string constant."; // $ Alert public static void main(String[] args) { // Ensure outer class is live. diff --git a/java/ql/test/query-tests/dead-code/DeadField/BasicTest.java b/java/ql/test/query-tests/dead-code/DeadField/BasicTest.java index 453469d177a..4a65ad28e40 100644 --- a/java/ql/test/query-tests/dead-code/DeadField/BasicTest.java +++ b/java/ql/test/query-tests/dead-code/DeadField/BasicTest.java @@ -1,8 +1,8 @@ public class BasicTest { - private static String deadStaticField = "Dead"; + private static String deadStaticField = "Dead"; // $ Alert private static String liveStaticField = "Live"; - private String deadField; - private String deadCycleField; + private String deadField; // $ Alert + private String deadCycleField; // $ Alert private String liveField; public BasicTest(String deadField, String liveField) { diff --git a/java/ql/test/query-tests/dead-code/DeadField/DeadField.qlref b/java/ql/test/query-tests/dead-code/DeadField/DeadField.qlref index 42d37e49f2f..fdae92e4d92 100644 --- a/java/ql/test/query-tests/dead-code/DeadField/DeadField.qlref +++ b/java/ql/test/query-tests/dead-code/DeadField/DeadField.qlref @@ -1 +1,2 @@ -DeadCode/DeadField.ql +query: DeadCode/DeadField.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/dead-code/DeadField/ReflectionTest.java b/java/ql/test/query-tests/dead-code/DeadField/ReflectionTest.java index 72ca3ae46f6..ca64e642fd4 100644 --- a/java/ql/test/query-tests/dead-code/DeadField/ReflectionTest.java +++ b/java/ql/test/query-tests/dead-code/DeadField/ReflectionTest.java @@ -2,11 +2,11 @@ public class ReflectionTest { public static class ParentClass { // Not live - private int notInheritedField; + private int notInheritedField; // $ Alert // Live because it is accessed through ChildClass public int inheritedField; // Not live because it is shadowed by the child - public int shadowedField; + public int shadowedField; // $ Alert } public static class ChildClass extends ParentClass { diff --git a/java/ql/test/query-tests/dead-code/DeadMethod/DeadMethod.qlref b/java/ql/test/query-tests/dead-code/DeadMethod/DeadMethod.qlref index 76204a1df5a..743a5f15775 100644 --- a/java/ql/test/query-tests/dead-code/DeadMethod/DeadMethod.qlref +++ b/java/ql/test/query-tests/dead-code/DeadMethod/DeadMethod.qlref @@ -1 +1,2 @@ -DeadCode/DeadMethod.ql +query: DeadCode/DeadMethod.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/dead-code/DeadMethod/InternalDeadCodeCycle.java b/java/ql/test/query-tests/dead-code/DeadMethod/InternalDeadCodeCycle.java index f52b3289528..18da349c79d 100644 --- a/java/ql/test/query-tests/dead-code/DeadMethod/InternalDeadCodeCycle.java +++ b/java/ql/test/query-tests/dead-code/DeadMethod/InternalDeadCodeCycle.java @@ -1,10 +1,10 @@ public class InternalDeadCodeCycle { - public void foo() { + public void foo() { // $ Alert bar(); } - public void bar() { + public void bar() { // $ Alert foo(); } diff --git a/java/ql/test/query-tests/dead-code/DeadMethod/JMXTest.java b/java/ql/test/query-tests/dead-code/DeadMethod/JMXTest.java index 0bd2c517f0d..32f8ec8d3e3 100644 --- a/java/ql/test/query-tests/dead-code/DeadMethod/JMXTest.java +++ b/java/ql/test/query-tests/dead-code/DeadMethod/JMXTest.java @@ -11,7 +11,7 @@ public class JMXTest { public static class FooIntermediate implements FooMBean { // This method is dead, because it is overridden in FooImpl, which is the registered MBean. - public String sometimesLiveMethod(String arg) { return "foo"; } + public String sometimesLiveMethod(String arg) { return "foo"; } // $ Alert // This method is live, because it is the most specific method for FooImpl public String liveMethod2(String arg) { return "foo"; } } diff --git a/java/ql/test/query-tests/dead-code/DeadMethod/SuppressedConstructorTest.java b/java/ql/test/query-tests/dead-code/DeadMethod/SuppressedConstructorTest.java index 8ab2f5a91c7..9eef167c6e9 100644 --- a/java/ql/test/query-tests/dead-code/DeadMethod/SuppressedConstructorTest.java +++ b/java/ql/test/query-tests/dead-code/DeadMethod/SuppressedConstructorTest.java @@ -6,13 +6,13 @@ public class SuppressedConstructorTest { public static void liveMethod() { } } - public void deadMethod() { + public void deadMethod() { // $ Alert new NestedPrivateConstructor(); } private static class NestedPrivateConstructor { // This should be dead, because it is called from a dead method. - private NestedPrivateConstructor() { } + private NestedPrivateConstructor() { } // $ Alert public static void liveMethod() { } } @@ -23,7 +23,7 @@ public class SuppressedConstructorTest { * constructor will be added by the compiler. Therefore, we do not need to declare this private * in order to suppress it. */ - private OtherConstructor() { } + private OtherConstructor() { } // $ Alert // Live constructor private OtherConstructor(Object foo) { } diff --git a/java/ql/test/query-tests/dead-code/UselessParameter/Test.java b/java/ql/test/query-tests/dead-code/UselessParameter/Test.java index 57554544e4c..7f8fc16ffe6 100644 --- a/java/ql/test/query-tests/dead-code/UselessParameter/Test.java +++ b/java/ql/test/query-tests/dead-code/UselessParameter/Test.java @@ -3,7 +3,7 @@ interface I { // NOT OK: no overriding method uses x - void foo(int x); + void foo(int x); // $ Alert // OK: no concrete implementation void bar(String y); diff --git a/java/ql/test/query-tests/dead-code/UselessParameter/UselessParameter.qlref b/java/ql/test/query-tests/dead-code/UselessParameter/UselessParameter.qlref index b1ceb2751a6..7de29d4e3f4 100644 --- a/java/ql/test/query-tests/dead-code/UselessParameter/UselessParameter.qlref +++ b/java/ql/test/query-tests/dead-code/UselessParameter/UselessParameter.qlref @@ -1 +1,2 @@ -DeadCode/UselessParameter.ql \ No newline at end of file +query: DeadCode/UselessParameter.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/maven-dependencies/UnusedMavenDependencyBinary.qlref b/java/ql/test/query-tests/maven-dependencies/UnusedMavenDependencyBinary.qlref index 9d5c4d42fe4..ff6e15f32d9 100644 --- a/java/ql/test/query-tests/maven-dependencies/UnusedMavenDependencyBinary.qlref +++ b/java/ql/test/query-tests/maven-dependencies/UnusedMavenDependencyBinary.qlref @@ -1 +1,2 @@ -Architecture/Dependencies/UnusedMavenDependencyBinary.ql \ No newline at end of file +query: Architecture/Dependencies/UnusedMavenDependencyBinary.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/maven-dependencies/UnusedMavenDependencySource.qlref b/java/ql/test/query-tests/maven-dependencies/UnusedMavenDependencySource.qlref index 78daed5aa14..e9ac8f72425 100644 --- a/java/ql/test/query-tests/maven-dependencies/UnusedMavenDependencySource.qlref +++ b/java/ql/test/query-tests/maven-dependencies/UnusedMavenDependencySource.qlref @@ -1 +1,2 @@ -Architecture/Dependencies/UnusedMavenDependencySource.ql \ No newline at end of file +query: Architecture/Dependencies/UnusedMavenDependencySource.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/maven-dependencies/my-project/pom.xml b/java/ql/test/query-tests/maven-dependencies/my-project/pom.xml index c082f704bed..644cc968f98 100644 --- a/java/ql/test/query-tests/maven-dependencies/my-project/pom.xml +++ b/java/ql/test/query-tests/maven-dependencies/my-project/pom.xml @@ -18,16 +18,16 @@ com.semmle another-project ${project.version} - + commons-lang commons-lang - + semmle-test semmle-test 1.0 - + - \ No newline at end of file + diff --git a/java/ql/test/query-tests/security/CWE-020/OverlyLargeRangeQuery.qlref b/java/ql/test/query-tests/security/CWE-020/OverlyLargeRangeQuery.qlref index ba518e54442..99525343c37 100644 --- a/java/ql/test/query-tests/security/CWE-020/OverlyLargeRangeQuery.qlref +++ b/java/ql/test/query-tests/security/CWE-020/OverlyLargeRangeQuery.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-020/OverlyLargeRange.ql +query: Security/CWE/CWE-020/OverlyLargeRange.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-020/SuspiciousRegexpRange.java b/java/ql/test/query-tests/security/CWE-020/SuspiciousRegexpRange.java index e346d74d4c2..b2f2e0c9c88 100644 --- a/java/ql/test/query-tests/security/CWE-020/SuspiciousRegexpRange.java +++ b/java/ql/test/query-tests/security/CWE-020/SuspiciousRegexpRange.java @@ -2,11 +2,11 @@ import java.util.regex.Pattern; class SuspiciousRegexpRange { void test() { - Pattern overlap1 = Pattern.compile("^[0-93-5]*$"); // NOT OK + Pattern overlap1 = Pattern.compile("^[0-93-5]*$"); // $ Alert[java/overly-large-range] // NOT OK - Pattern overlap2 = Pattern.compile("[A-ZA-z]*"); // NOT OK + Pattern overlap2 = Pattern.compile("[A-ZA-z]*"); // $ Alert[java/overly-large-range] // NOT OK - Pattern isEmpty = Pattern.compile("^[z-a]*$"); // NOT OK + Pattern isEmpty = Pattern.compile("^[z-a]*$"); // $ Alert[java/overly-large-range] // NOT OK Pattern isAscii = Pattern.compile("^[\\x00-\\x7F]*$"); // OK @@ -16,19 +16,19 @@ class SuspiciousRegexpRange { Pattern NON_ALPHANUMERIC_REGEXP = Pattern.compile("([^\\#-~| |!])*"); // OK - Pattern smallOverlap = Pattern.compile("[0-9a-fA-f]*"); // NOT OK + Pattern smallOverlap = Pattern.compile("[0-9a-fA-f]*"); // $ Alert[java/overly-large-range] // NOT OK - Pattern weirdRange = Pattern.compile("[$-`]*"); // NOT OK + Pattern weirdRange = Pattern.compile("[$-`]*"); // $ Alert[java/overly-large-range] // NOT OK - Pattern keywordOperator = Pattern.compile("[!\\~\\*\\/%+-<>\\^|=&]*"); // NOT OK + Pattern keywordOperator = Pattern.compile("[!\\~\\*\\/%+-<>\\^|=&]*"); // $ Alert[java/overly-large-range] // NOT OK - Pattern notYoutube = Pattern.compile("youtu.be/[a-z1-9.-_]+"); // NOT OK + Pattern notYoutube = Pattern.compile("youtu.be/[a-z1-9.-_]+"); // $ Alert[java/overly-large-range] // NOT OK - Pattern numberToLetter = Pattern.compile("[7-F]*"); // NOT OK + Pattern numberToLetter = Pattern.compile("[7-F]*"); // $ Alert[java/overly-large-range] // NOT OK - Pattern overlapsWithClass1 = Pattern.compile("[0-9\\d]*"); // NOT OK + Pattern overlapsWithClass1 = Pattern.compile("[0-9\\d]*"); // $ Alert[java/overly-large-range] // NOT OK - Pattern overlapsWithClass2 = Pattern.compile("[\\w,.-?:*+]*"); // NOT OK + Pattern overlapsWithClass2 = Pattern.compile("[\\w,.-?:*+]*"); // $ Alert[java/overly-large-range] // NOT OK Pattern nested = Pattern.compile("[[A-Za-z_][A-Za-z0-9._-]]*"); // OK, the dash it at the end diff --git a/java/ql/test/query-tests/security/CWE-022/semmle/tests/ZipSlip.qlref b/java/ql/test/query-tests/security/CWE-022/semmle/tests/ZipSlip.qlref index eee3728e935..71a41a4c0ac 100644 --- a/java/ql/test/query-tests/security/CWE-022/semmle/tests/ZipSlip.qlref +++ b/java/ql/test/query-tests/security/CWE-022/semmle/tests/ZipSlip.qlref @@ -1,2 +1,4 @@ query: Security/CWE/CWE-022/ZipSlip.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-022/semmle/tests/ZipTest.java b/java/ql/test/query-tests/security/CWE-022/semmle/tests/ZipTest.java index 2c5e1cd9d53..b4d8ba8eea9 100644 --- a/java/ql/test/query-tests/security/CWE-022/semmle/tests/ZipTest.java +++ b/java/ql/test/query-tests/security/CWE-022/semmle/tests/ZipTest.java @@ -4,11 +4,11 @@ import java.util.zip.*; public class ZipTest { public void m1(ZipEntry entry, File dir) throws Exception { - String name = entry.getName(); + String name = entry.getName(); // $ Alert[java/zipslip] File file = new File(dir, name); - FileOutputStream os = new FileOutputStream(file); // ZipSlip - RandomAccessFile raf = new RandomAccessFile(file, "rw"); // ZipSlip - FileWriter fw = new FileWriter(file); // ZipSlip + FileOutputStream os = new FileOutputStream(file); // $ Sink[java/zipslip] // ZipSlip + RandomAccessFile raf = new RandomAccessFile(file, "rw"); // $ Sink[java/zipslip] // ZipSlip + FileWriter fw = new FileWriter(file); // $ Sink[java/zipslip] // ZipSlip } public void m2(ZipEntry entry, File dir) throws Exception { diff --git a/java/ql/test/query-tests/security/CWE-078/ExecRelative.qlref b/java/ql/test/query-tests/security/CWE-078/ExecRelative.qlref index 42aa816c177..65cb1b6dd76 100644 --- a/java/ql/test/query-tests/security/CWE-078/ExecRelative.qlref +++ b/java/ql/test/query-tests/security/CWE-078/ExecRelative.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-078/ExecRelative.ql +query: Security/CWE/CWE-078/ExecRelative.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-078/ExecTainted.qlref b/java/ql/test/query-tests/security/CWE-078/ExecTainted.qlref index 856b97bf0fe..77cdee7b283 100644 --- a/java/ql/test/query-tests/security/CWE-078/ExecTainted.qlref +++ b/java/ql/test/query-tests/security/CWE-078/ExecTainted.qlref @@ -1,2 +1,4 @@ query: Security/CWE/CWE-078/ExecTainted.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-078/ExecUnescaped.qlref b/java/ql/test/query-tests/security/CWE-078/ExecUnescaped.qlref index 1ee86c5e76a..add1dcb676b 100644 --- a/java/ql/test/query-tests/security/CWE-078/ExecUnescaped.qlref +++ b/java/ql/test/query-tests/security/CWE-078/ExecUnescaped.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-078/ExecUnescaped.ql +query: Security/CWE/CWE-078/ExecUnescaped.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-078/TaintedEnvironment.java b/java/ql/test/query-tests/security/CWE-078/TaintedEnvironment.java index cb3ecb3b050..b112597f260 100644 --- a/java/ql/test/query-tests/security/CWE-078/TaintedEnvironment.java +++ b/java/ql/test/query-tests/security/CWE-078/TaintedEnvironment.java @@ -36,6 +36,6 @@ public class TaintedEnvironment { public void exec() throws java.io.IOException { String kv = (String) source(); - Runtime.getRuntime().exec(new String[] { "ls" }, new String[] { kv }); // $ hasTaintFlow + Runtime.getRuntime().exec(new String[] { "ls" }, new String[] { kv }); // $ Alert[java/relative-path-command] hasTaintFlow } } diff --git a/java/ql/test/query-tests/security/CWE-078/Test.java b/java/ql/test/query-tests/security/CWE-078/Test.java index 1ac5dc47882..6850a3a19e3 100644 --- a/java/ql/test/query-tests/security/CWE-078/Test.java +++ b/java/ql/test/query-tests/security/CWE-078/Test.java @@ -4,10 +4,10 @@ import java.util.ArrayList; class Test { public static void shellCommand(String arg) throws java.io.IOException { - ProcessBuilder pb = new ProcessBuilder("/bin/bash -c echo " + arg); + ProcessBuilder pb = new ProcessBuilder("/bin/bash -c echo " + arg); // $ Alert[java/concatenated-command-line] Alert[java/command-line-injection] pb.start(); - pb = new ProcessBuilder(new String[]{"/bin/bash", "-c", "echo " + arg}); + pb = new ProcessBuilder(new String[]{"/bin/bash", "-c", "echo " + arg}); // $ Alert[java/command-line-injection] pb.start(); List cmd = new ArrayList(); @@ -15,18 +15,18 @@ class Test { cmd.add("-c"); cmd.add("echo " + arg); - pb = new ProcessBuilder(cmd); + pb = new ProcessBuilder(cmd); // $ Alert[java/command-line-injection] pb.start(); String[] cmd1 = new String[]{"/bin/bash", "-c", ""}; cmd1[1] = "echo " + arg; - pb = new ProcessBuilder(cmd1); + pb = new ProcessBuilder(cmd1); // $ Alert[java/command-line-injection] pb.start(); } public static void nonShellCommand(String arg) throws java.io.IOException { - ProcessBuilder pb = new ProcessBuilder("./customTool " + arg); + ProcessBuilder pb = new ProcessBuilder("./customTool " + arg); // $ Alert[java/concatenated-command-line] Alert[java/command-line-injection] pb.start(); pb = new ProcessBuilder(new String[]{"./customTool", arg}); @@ -47,14 +47,14 @@ class Test { } public static void relativeCommand() throws java.io.IOException { - ProcessBuilder pb = new ProcessBuilder("ls"); + ProcessBuilder pb = new ProcessBuilder("ls"); // $ Alert[java/relative-path-command] pb.start(); pb = new ProcessBuilder("/bin/ls"); pb.start(); } - public static void main(String[] args) throws java.io.IOException { + public static void main(String[] args) throws java.io.IOException { // $ Source[java/command-line-injection] String arg = args.length > 1 ? args[1] : "default"; shellCommand(arg); diff --git a/java/ql/test/query-tests/security/CWE-079/semmle/tests/SetJavascriptEnabled.java b/java/ql/test/query-tests/security/CWE-079/semmle/tests/SetJavascriptEnabled.java index 02a81f3e3c2..82215d11130 100644 --- a/java/ql/test/query-tests/security/CWE-079/semmle/tests/SetJavascriptEnabled.java +++ b/java/ql/test/query-tests/security/CWE-079/semmle/tests/SetJavascriptEnabled.java @@ -6,7 +6,7 @@ import android.webkit.WebSettings; public class SetJavascriptEnabled { public static void configureWebViewUnsafe(WebView view) { WebSettings settings = view.getSettings(); - settings.setJavaScriptEnabled(true); // $ javascriptEnabled + settings.setJavaScriptEnabled(true); // $ Alert[java/android/websettings-javascript-enabled] javascriptEnabled } public static void configureWebViewSafe(WebView view) { diff --git a/java/ql/test/query-tests/security/CWE-079/semmle/tests/WebViewAddJavascriptInterface.java b/java/ql/test/query-tests/security/CWE-079/semmle/tests/WebViewAddJavascriptInterface.java index 50fc3847705..acd895c474f 100644 --- a/java/ql/test/query-tests/security/CWE-079/semmle/tests/WebViewAddJavascriptInterface.java +++ b/java/ql/test/query-tests/security/CWE-079/semmle/tests/WebViewAddJavascriptInterface.java @@ -7,6 +7,6 @@ class WebViewAddJavascriptInterface { } public void addGreeter(WebView view) { - view.addJavascriptInterface(new Greeter(), "greeter"); + view.addJavascriptInterface(new Greeter(), "greeter"); // $ Alert[java/android/webview-addjavascriptinterface] } } diff --git a/java/ql/test/query-tests/security/CWE-079/semmle/tests/WebViewAddJavascriptInterface.qlref b/java/ql/test/query-tests/security/CWE-079/semmle/tests/WebViewAddJavascriptInterface.qlref index 1161c47dda6..f0385f63cbd 100644 --- a/java/ql/test/query-tests/security/CWE-079/semmle/tests/WebViewAddJavascriptInterface.qlref +++ b/java/ql/test/query-tests/security/CWE-079/semmle/tests/WebViewAddJavascriptInterface.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-079/AndroidWebViewAddJavascriptInterface.ql +query: Security/CWE/CWE-079/AndroidWebViewAddJavascriptInterface.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-079/semmle/tests/WebViewSetEnabledJavaScript.qlref b/java/ql/test/query-tests/security/CWE-079/semmle/tests/WebViewSetEnabledJavaScript.qlref index e9e8006886d..34f44ac58cd 100644 --- a/java/ql/test/query-tests/security/CWE-079/semmle/tests/WebViewSetEnabledJavaScript.qlref +++ b/java/ql/test/query-tests/security/CWE-079/semmle/tests/WebViewSetEnabledJavaScript.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-079/AndroidWebViewSettingsEnabledJavaScript.ql +query: Security/CWE/CWE-079/AndroidWebViewSettingsEnabledJavaScript.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-089/semmle/examples/AllowListSanitizerWithJavaUtilList.java b/java/ql/test/query-tests/security/CWE-089/semmle/examples/AllowListSanitizerWithJavaUtilList.java index 285f9bc49cb..50a9547e48a 100644 --- a/java/ql/test/query-tests/security/CWE-089/semmle/examples/AllowListSanitizerWithJavaUtilList.java +++ b/java/ql/test/query-tests/security/CWE-089/semmle/examples/AllowListSanitizerWithJavaUtilList.java @@ -45,7 +45,7 @@ class AllowListSanitizerWithJavaUtilList { return String.valueOf(System.currentTimeMillis()); } - public static void main(String[] args) throws IOException, SQLException { + public static void main(String[] args) throws IOException, SQLException { // $ Source[java/sql-injection] badAllowList6 = List.of("allowed1", getNonConstantString(), "allowed3"); testStaticFields(args); testLocal(args); @@ -61,61 +61,61 @@ class AllowListSanitizerWithJavaUtilList { if(goodAllowList1.contains(tainted.toLowerCase())){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/concatenated-sql-query] } // GOOD: an allowlist is used with constant strings if(goodAllowList2.contains(tainted.toUpperCase())){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/concatenated-sql-query] } // GOOD: an allowlist is used with constant strings if(goodAllowList3.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/concatenated-sql-query] } // GOOD: an allowlist is used with constant strings if(goodAllowList4.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/concatenated-sql-query] } // BAD: an allowlist is used with constant strings if(badAllowList1.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } // BAD: an allowlist is used with constant strings if(badAllowList2.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } // BAD: an allowlist is used with constant strings if(badAllowList3.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } // BAD: an allowlist is used with constant strings if(badAllowList4.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } // GOOD: an allowlist is used with constant strings if(goodAllowList5.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/concatenated-sql-query] } // BAD: the allowlist is in a non-final field if(badAllowList6.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } } @@ -125,7 +125,7 @@ class AllowListSanitizerWithJavaUtilList { if(goodAllowList7.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/concatenated-sql-query] } } @@ -137,7 +137,7 @@ class AllowListSanitizerWithJavaUtilList { if(allowlist.contains(tainted.toLowerCase())){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/concatenated-sql-query] } } // BAD: an allowlist is used but one of the entries is not a compile-time constant @@ -146,7 +146,7 @@ class AllowListSanitizerWithJavaUtilList { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } } // GOOD: an allowlist is used with constant strings @@ -156,7 +156,7 @@ class AllowListSanitizerWithJavaUtilList { if(allowlist.contains(tainted.toUpperCase())){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/concatenated-sql-query] } } // BAD: an allowlist is used but one of the entries is not a compile-time constant @@ -166,7 +166,7 @@ class AllowListSanitizerWithJavaUtilList { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } } // GOOD: an allowlist is used with constant strings @@ -175,7 +175,7 @@ class AllowListSanitizerWithJavaUtilList { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/concatenated-sql-query] } } // BAD: an allowlist is used but one of the entries is not a compile-time constant @@ -184,7 +184,7 @@ class AllowListSanitizerWithJavaUtilList { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } } // GOOD: an allowlist is used with constant strings @@ -194,7 +194,7 @@ class AllowListSanitizerWithJavaUtilList { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/concatenated-sql-query] } } // BAD: an allowlist is used but one of the entries is not a compile-time constant @@ -204,7 +204,7 @@ class AllowListSanitizerWithJavaUtilList { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } } // GOOD: an allowlist is used with constant string @@ -216,7 +216,7 @@ class AllowListSanitizerWithJavaUtilList { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/concatenated-sql-query] } } // BAD: an allowlist is used but one of the entries is not a compile-time constant @@ -228,7 +228,7 @@ class AllowListSanitizerWithJavaUtilList { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } } // BAD: an allowlist is used but it contains a non-compile-time constant element @@ -239,7 +239,7 @@ class AllowListSanitizerWithJavaUtilList { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } } } @@ -257,7 +257,7 @@ class AllowListSanitizerWithJavaUtilList { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } } { @@ -266,7 +266,7 @@ class AllowListSanitizerWithJavaUtilList { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } } { @@ -275,7 +275,7 @@ class AllowListSanitizerWithJavaUtilList { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } } } @@ -290,7 +290,7 @@ class AllowListSanitizerWithJavaUtilList { if(allowlist.contains(tainted)){ // missing result String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } } } diff --git a/java/ql/test/query-tests/security/CWE-089/semmle/examples/AllowListSanitizerWithJavaUtilSet.java b/java/ql/test/query-tests/security/CWE-089/semmle/examples/AllowListSanitizerWithJavaUtilSet.java index e1a5f889c6f..28defcbab29 100644 --- a/java/ql/test/query-tests/security/CWE-089/semmle/examples/AllowListSanitizerWithJavaUtilSet.java +++ b/java/ql/test/query-tests/security/CWE-089/semmle/examples/AllowListSanitizerWithJavaUtilSet.java @@ -44,7 +44,7 @@ class AllowListSanitizerWithJavaUtilSet { return String.valueOf(System.currentTimeMillis()); } - public static void main(String[] args) throws IOException, SQLException { + public static void main(String[] args) throws IOException, SQLException { // $ Source[java/sql-injection] badAllowList6 = Set.of("allowed1", getNonConstantString(), "allowed3"); testStaticFields(args); testLocal(args); @@ -60,61 +60,61 @@ class AllowListSanitizerWithJavaUtilSet { if(goodAllowList1.contains(tainted.toLowerCase())){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/concatenated-sql-query] } // GOOD: an allowlist is used with constant strings if(goodAllowList2.contains(tainted.toUpperCase())){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/concatenated-sql-query] } // GOOD: an allowlist is used with constant strings if(goodAllowList3.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/concatenated-sql-query] } // GOOD: an allowlist is used with constant strings if(goodAllowList4.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/concatenated-sql-query] } // BAD: an allowlist is used with constant strings if(badAllowList1.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } // BAD: an allowlist is used with constant strings if(badAllowList2.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } // BAD: an allowlist is used with constant strings if(badAllowList3.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } // BAD: an allowlist is used with constant strings if(badAllowList4.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } // GOOD: an allowlist is used with constant strings if(goodAllowList5.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/concatenated-sql-query] } // BAD: the allowlist is in a non-final field if(badAllowList6.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } } @@ -124,7 +124,7 @@ class AllowListSanitizerWithJavaUtilSet { if(goodAllowList7.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/concatenated-sql-query] } } @@ -136,7 +136,7 @@ class AllowListSanitizerWithJavaUtilSet { if(allowlist.contains(tainted.toLowerCase())){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/concatenated-sql-query] } } // BAD: an allowlist is used but one of the entries is not a compile-time constant @@ -145,7 +145,7 @@ class AllowListSanitizerWithJavaUtilSet { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } } // GOOD: an allowlist is used with constant strings @@ -155,7 +155,7 @@ class AllowListSanitizerWithJavaUtilSet { if(allowlist.contains(tainted.toUpperCase())){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/concatenated-sql-query] } } // BAD: an allowlist is used but one of the entries is not a compile-time constant @@ -165,7 +165,7 @@ class AllowListSanitizerWithJavaUtilSet { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } } // GOOD: an allowlist is used with constant strings @@ -174,7 +174,7 @@ class AllowListSanitizerWithJavaUtilSet { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/concatenated-sql-query] } } // BAD: an allowlist is used but one of the entries is not a compile-time constant @@ -183,7 +183,7 @@ class AllowListSanitizerWithJavaUtilSet { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } } // GOOD: an allowlist is used with constant strings @@ -193,7 +193,7 @@ class AllowListSanitizerWithJavaUtilSet { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/concatenated-sql-query] } } // BAD: an allowlist is used but one of the entries is not a compile-time constant @@ -203,7 +203,7 @@ class AllowListSanitizerWithJavaUtilSet { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } } // GOOD: an allowlist is used with constant string @@ -215,7 +215,7 @@ class AllowListSanitizerWithJavaUtilSet { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/concatenated-sql-query] } } // BAD: an allowlist is used but one of the entries is not a compile-time constant @@ -227,7 +227,7 @@ class AllowListSanitizerWithJavaUtilSet { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } } // BAD: an allowlist is used but it contains a non-compile-time constant element @@ -238,7 +238,7 @@ class AllowListSanitizerWithJavaUtilSet { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } } } @@ -256,7 +256,7 @@ class AllowListSanitizerWithJavaUtilSet { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } } { @@ -265,7 +265,7 @@ class AllowListSanitizerWithJavaUtilSet { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } } { @@ -274,7 +274,7 @@ class AllowListSanitizerWithJavaUtilSet { if(allowlist.contains(tainted)){ String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } } } @@ -289,7 +289,7 @@ class AllowListSanitizerWithJavaUtilSet { if(allowlist.contains(tainted)){ // missing result String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + tainted + "' ORDER BY PRICE"; - ResultSet results = connection.createStatement().executeQuery(query); + ResultSet results = connection.createStatement().executeQuery(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } } } diff --git a/java/ql/test/query-tests/security/CWE-089/semmle/examples/CouchBase.java b/java/ql/test/query-tests/security/CWE-089/semmle/examples/CouchBase.java index ee6c81cdc81..3d3b7179459 100644 --- a/java/ql/test/query-tests/security/CWE-089/semmle/examples/CouchBase.java +++ b/java/ql/test/query-tests/security/CWE-089/semmle/examples/CouchBase.java @@ -4,14 +4,14 @@ import com.couchbase.client.java.Bucket; import com.couchbase.client.java.Cluster; public class CouchBase { - public static void main(String[] args) { + public static void main(String[] args) { // $ Source[java/sql-injection] Cluster cluster = Cluster.connect("192.168.0.158", "Administrator", "Administrator"); Bucket bucket = cluster.bucket("travel-sample"); - cluster.analyticsQuery(args[1]); - cluster.analyticsQuery(args[1], null); - cluster.query(args[1]); - cluster.query(args[1], null); - cluster.queryStreaming(args[1], null); - cluster.queryStreaming(args[1], null, null); + cluster.analyticsQuery(args[1]); // $ Alert[java/sql-injection] + cluster.analyticsQuery(args[1], null); // $ Alert[java/sql-injection] + cluster.query(args[1]); // $ Alert[java/sql-injection] + cluster.query(args[1], null); // $ Alert[java/sql-injection] + cluster.queryStreaming(args[1], null); // $ Alert[java/sql-injection] + cluster.queryStreaming(args[1], null, null); // $ Alert[java/sql-injection] } } diff --git a/java/ql/test/query-tests/security/CWE-089/semmle/examples/Mongo.java b/java/ql/test/query-tests/security/CWE-089/semmle/examples/Mongo.java index 3a1cfff39f9..2761a2c52bd 100644 --- a/java/ql/test/query-tests/security/CWE-089/semmle/examples/Mongo.java +++ b/java/ql/test/query-tests/security/CWE-089/semmle/examples/Mongo.java @@ -7,19 +7,19 @@ import com.mongodb.DBCursor; import com.mongodb.*; public class Mongo { - public static void main(String[] args) { + public static void main(String[] args) { // $ Source[java/sql-injection] MongoClient mongoClient = new MongoClient(new ServerAddress("localhost", 27017)); DB db = mongoClient.getDB("mydb"); DBCollection collection = db.getCollection("test"); String name = args[1]; String stringQuery = "{ 'name' : '" + name + "'}"; - DBObject databaseQuery = (DBObject) JSON.parse(stringQuery); + DBObject databaseQuery = (DBObject) JSON.parse(stringQuery); // $ Alert[java/sql-injection] DBCursor result = collection.find(databaseQuery); String json = args[1]; - BasicDBObject bdb = BasicDBObject.parse(json); + BasicDBObject bdb = BasicDBObject.parse(json); // $ Alert[java/sql-injection] DBCursor result2 = collection.find(bdb); } -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/security/CWE-089/semmle/examples/SqlConcatenated.qlref b/java/ql/test/query-tests/security/CWE-089/semmle/examples/SqlConcatenated.qlref index 32211414c8c..2bab54f9ae6 100644 --- a/java/ql/test/query-tests/security/CWE-089/semmle/examples/SqlConcatenated.qlref +++ b/java/ql/test/query-tests/security/CWE-089/semmle/examples/SqlConcatenated.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-089/SqlConcatenated.ql +query: Security/CWE/CWE-089/SqlConcatenated.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-089/semmle/examples/SqlTainted.qlref b/java/ql/test/query-tests/security/CWE-089/semmle/examples/SqlTainted.qlref index dc9ae162efb..a60fa5dde2e 100644 --- a/java/ql/test/query-tests/security/CWE-089/semmle/examples/SqlTainted.qlref +++ b/java/ql/test/query-tests/security/CWE-089/semmle/examples/SqlTainted.qlref @@ -1,2 +1,4 @@ query: Security/CWE/CWE-089/SqlTainted.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-089/semmle/examples/Test.java b/java/ql/test/query-tests/security/CWE-089/semmle/examples/Test.java index dee0db129eb..0f357e61a43 100644 --- a/java/ql/test/query-tests/security/CWE-089/semmle/examples/Test.java +++ b/java/ql/test/query-tests/security/CWE-089/semmle/examples/Test.java @@ -33,13 +33,13 @@ abstract class Test { Statement statement = connection.createStatement(); String query1 = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + category + "' ORDER BY PRICE"; - ResultSet results = statement.executeQuery(query1); + ResultSet results = statement.executeQuery(query1); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } // BAD: don't use user input when building a prepared call { String id = args[1]; String query2 = "{ call get_product_by_id('" + id + "',?,?,?) }"; - PreparedStatement statement = connection.prepareCall(query2); + PreparedStatement statement = connection.prepareCall(query2); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] ResultSet results = statement.executeQuery(); } // BAD: don't use user input when building a prepared query @@ -47,7 +47,7 @@ abstract class Test { String category = args[1]; String query3 = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + category + "' ORDER BY PRICE"; - PreparedStatement statement = connection.prepareStatement(query3); + PreparedStatement statement = connection.prepareStatement(query3); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] ResultSet results = statement.executeQuery(); } // BAD: an injection using a StringBuilder instead of string append @@ -59,7 +59,7 @@ abstract class Test { querySb.append("' ORDER BY PRICE"); String querySbToString = querySb.toString(); Statement statement = connection.createStatement(); - ResultSet results = statement.executeQuery(querySbToString); + ResultSet results = statement.executeQuery(querySbToString); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } // BAD: executeUpdate { @@ -67,7 +67,7 @@ abstract class Test { String price = args[2]; Statement statement = connection.createStatement(); String query = "UPDATE PRODUCT SET PRICE='" + price + "' WHERE ITEM='" + item + "'"; - int count = statement.executeUpdate(query); + int count = statement.executeUpdate(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } // BAD: executeUpdate { @@ -75,7 +75,7 @@ abstract class Test { String price = args[2]; Statement statement = connection.createStatement(); String query = "UPDATE PRODUCT SET PRICE='" + price + "' WHERE ITEM='" + item + "'"; - long count = statement.executeLargeUpdate(query); + long count = statement.executeLargeUpdate(query); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] } // OK: validate the input first @@ -95,7 +95,7 @@ abstract class Test { Statement statement = connection.createStatement(); String queryFromField = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='" + categoryName + "' ORDER BY PRICE"; - ResultSet results = statement.executeQuery(queryFromField); + ResultSet results = statement.executeQuery(queryFromField); // $ Alert[java/concatenated-sql-query] } // BAD: unescaped code using a StringBuilder { @@ -105,7 +105,7 @@ abstract class Test { querySb.append("' ORDER BY PRICE"); String querySbToString = querySb.toString(); Statement statement = connection.createStatement(); - ResultSet results = statement.executeQuery(querySbToString); + ResultSet results = statement.executeQuery(querySbToString); // $ Alert[java/concatenated-sql-query] } // BAD: a StringBuilder with appends of + operations { @@ -115,7 +115,7 @@ abstract class Test { querySb2.append("ORDER BY PRICE"); String querySb2ToString = querySb2.toString(); Statement statement = connection.createStatement(); - ResultSet results = statement.executeQuery(querySb2ToString); + ResultSet results = statement.executeQuery(querySb2ToString); // $ Alert[java/concatenated-sql-query] } } @@ -206,7 +206,7 @@ abstract class Test { String queryWithUserTableName = "SELECT ITEM,PRICE FROM " + userTabName + " WHERE ITEM_CATEGORY='Biscuits' ORDER BY PRICE"; - ResultSet results = statement.executeQuery(queryWithUserTableName); + ResultSet results = statement.executeQuery(queryWithUserTableName); // $ Alert[java/sql-injection] } } @@ -218,13 +218,13 @@ abstract class Test { String prefix = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='"; String suffix = "' ORDER BY PRICE"; switch(prefix) { - case String prefixAlias when prefix.length() > 10 -> statement.executeQuery(prefixAlias + category + suffix); + case String prefixAlias when prefix.length() > 10 -> statement.executeQuery(prefixAlias + category + suffix); // $ Alert[java/sql-injection] Alert[java/concatenated-sql-query] default -> { } } } } - public static void main(String[] args) throws IOException, SQLException { + public static void main(String[] args) throws IOException, SQLException { // $ Source[java/sql-injection] tainted(args); unescaped(); good(args); diff --git a/java/ql/test/query-tests/security/CWE-090/LdapInjection.java b/java/ql/test/query-tests/security/CWE-090/LdapInjection.java index 7e585581f0b..661062f0a46 100644 --- a/java/ql/test/query-tests/security/CWE-090/LdapInjection.java +++ b/java/ql/test/query-tests/security/CWE-090/LdapInjection.java @@ -42,53 +42,53 @@ import org.springframework.web.bind.annotation.RequestMapping; public class LdapInjection { // JNDI @RequestMapping - public void testJndiBad1(@RequestParam String jBad, @RequestParam String jBadDN, DirContext ctx) + public void testJndiBad1(@RequestParam String jBad, @RequestParam String jBadDN, DirContext ctx) // $ Source throws NamingException { - ctx.search("ou=system" + jBadDN, "(uid=" + jBad + ")", new SearchControls()); + ctx.search("ou=system" + jBadDN, "(uid=" + jBad + ")", new SearchControls()); // $ Alert } @RequestMapping - public void testJndiBad2(@RequestParam String jBad, @RequestParam String jBadDNName, InitialDirContext ctx) + public void testJndiBad2(@RequestParam String jBad, @RequestParam String jBadDNName, InitialDirContext ctx) // $ Source throws NamingException { - ctx.search(new LdapName("ou=system" + jBadDNName), "(uid=" + jBad + ")", new SearchControls()); + ctx.search(new LdapName("ou=system" + jBadDNName), "(uid=" + jBad + ")", new SearchControls()); // $ Alert } @RequestMapping - public void testJndiBad3(@RequestParam String jBad, @RequestParam String jOkDN, LdapContext ctx) + public void testJndiBad3(@RequestParam String jBad, @RequestParam String jOkDN, LdapContext ctx) // $ Source throws NamingException { - ctx.search(new LdapName(List.of(new Rdn("ou=" + jOkDN))), "(uid=" + jBad + ")", new SearchControls()); + ctx.search(new LdapName(List.of(new Rdn("ou=" + jOkDN))), "(uid=" + jBad + ")", new SearchControls()); // $ Alert } @RequestMapping - public void testJndiBad4(@RequestParam String jBadInitial, InitialLdapContext ctx) + public void testJndiBad4(@RequestParam String jBadInitial, InitialLdapContext ctx) // $ Source throws NamingException { - ctx.search("ou=system", "(uid=" + jBadInitial + ")", new SearchControls()); + ctx.search("ou=system", "(uid=" + jBadInitial + ")", new SearchControls()); // $ Alert } @RequestMapping - public void testJndiBad5(@RequestParam String jBad, @RequestParam String jBadDNNameAdd, InitialDirContext ctx) + public void testJndiBad5(@RequestParam String jBad, @RequestParam String jBadDNNameAdd, InitialDirContext ctx) // $ Source throws NamingException { - ctx.search(new LdapName("").addAll(new LdapName("ou=system" + jBadDNNameAdd)), "(uid=" + jBad + ")", new SearchControls()); + ctx.search(new LdapName("").addAll(new LdapName("ou=system" + jBadDNNameAdd)), "(uid=" + jBad + ")", new SearchControls()); // $ Alert } @RequestMapping - public void testJndiBad6(@RequestParam String jBad, @RequestParam String jBadDNNameAdd2, InitialDirContext ctx) + public void testJndiBad6(@RequestParam String jBad, @RequestParam String jBadDNNameAdd2, InitialDirContext ctx) // $ Source throws NamingException { LdapName name = new LdapName(""); name.addAll(new LdapName("ou=system" + jBadDNNameAdd2).getRdns()); - ctx.search(new LdapName("").addAll(name), "(uid=" + jBad + ")", new SearchControls()); + ctx.search(new LdapName("").addAll(name), "(uid=" + jBad + ")", new SearchControls()); // $ Alert } @RequestMapping - public void testJndiBad7(@RequestParam String jBad, @RequestParam String jBadDNNameToString, InitialDirContext ctx) + public void testJndiBad7(@RequestParam String jBad, @RequestParam String jBadDNNameToString, InitialDirContext ctx) // $ Source throws NamingException { - ctx.search(new LdapName("ou=system" + jBadDNNameToString).toString(), "(uid=" + jBad + ")", new SearchControls()); + ctx.search(new LdapName("ou=system" + jBadDNNameToString).toString(), "(uid=" + jBad + ")", new SearchControls()); // $ Alert } @RequestMapping - public void testJndiBad8(@RequestParam String jBad, @RequestParam String jBadDNNameClone, InitialDirContext ctx) + public void testJndiBad8(@RequestParam String jBad, @RequestParam String jBadDNNameClone, InitialDirContext ctx) // $ Source throws NamingException { - ctx.search((Name) new LdapName("ou=system" + jBadDNNameClone).clone(), "(uid=" + jBad + ")", new SearchControls()); + ctx.search((Name) new LdapName("ou=system" + jBadDNNameClone).clone(), "(uid=" + jBad + ")", new SearchControls()); // $ Alert } @RequestMapping @@ -97,107 +97,107 @@ public class LdapInjection { } @RequestMapping - public void testJndiOk2(@RequestParam String jOkAttribute, DirContext ctx) throws NamingException { - ctx.search("ou=system", new BasicAttributes(jOkAttribute, jOkAttribute)); + public void testJndiOk2(@RequestParam String jOkAttribute, DirContext ctx) throws NamingException { // $ Source + ctx.search("ou=system", new BasicAttributes(jOkAttribute, jOkAttribute)); // $ Alert } // UnboundID @RequestMapping - public void testUnboundBad1(@RequestParam String uBad, @RequestParam String uBadDN, LDAPConnection c) + public void testUnboundBad1(@RequestParam String uBad, @RequestParam String uBadDN, LDAPConnection c) // $ Source throws LDAPSearchException { - c.search(null, "ou=system" + uBadDN, null, null, 1, 1, false, "(uid=" + uBad + ")"); + c.search(null, "ou=system" + uBadDN, null, null, 1, 1, false, "(uid=" + uBad + ")"); // $ Alert } @RequestMapping - public void testUnboundBad2(@RequestParam String uBadFilterCreate, LDAPConnection c) throws LDAPException { - c.search(null, "ou=system", null, null, 1, 1, false, Filter.create(uBadFilterCreate)); + public void testUnboundBad2(@RequestParam String uBadFilterCreate, LDAPConnection c) throws LDAPException { // $ Source + c.search(null, "ou=system", null, null, 1, 1, false, Filter.create(uBadFilterCreate)); // $ Alert } @RequestMapping - public void testUnboundBad3(@RequestParam String uBadROSearchRequest, @RequestParam String uBadROSRDN, + public void testUnboundBad3(@RequestParam String uBadROSearchRequest, @RequestParam String uBadROSRDN, // $ Source LDAPConnection c) throws LDAPException { ReadOnlySearchRequest s = new SearchRequest(null, "ou=system" + uBadROSRDN, null, null, 1, 1, false, "(uid=" + uBadROSearchRequest + ")"); - c.search(s); + c.search(s); // $ Alert } @RequestMapping - public void testUnboundBad4(@RequestParam String uBadSearchRequest, @RequestParam String uBadSRDN, LDAPConnection c) + public void testUnboundBad4(@RequestParam String uBadSearchRequest, @RequestParam String uBadSRDN, LDAPConnection c) // $ Source throws LDAPException { SearchRequest s = new SearchRequest(null, "ou=system" + uBadSRDN, null, null, 1, 1, false, "(uid=" + uBadSearchRequest + ")"); - c.search(s); + c.search(s); // $ Alert } @RequestMapping - public void testUnboundBad5(@RequestParam String uBad, @RequestParam String uBadDNSFR, LDAPConnection c) + public void testUnboundBad5(@RequestParam String uBad, @RequestParam String uBadDNSFR, LDAPConnection c) // $ Source throws LDAPSearchException { - c.searchForEntry("ou=system" + uBadDNSFR, null, null, 1, false, "(uid=" + uBad + ")"); + c.searchForEntry("ou=system" + uBadDNSFR, null, null, 1, false, "(uid=" + uBad + ")"); // $ Alert } @RequestMapping - public void testUnboundBad6(@RequestParam String uBadROSearchRequestAsync, @RequestParam String uBadROSRDNAsync, + public void testUnboundBad6(@RequestParam String uBadROSearchRequestAsync, @RequestParam String uBadROSRDNAsync, // $ Source LDAPConnection c) throws LDAPException { ReadOnlySearchRequest s = new SearchRequest(null, "ou=system" + uBadROSRDNAsync, null, null, 1, 1, false, "(uid=" + uBadROSearchRequestAsync + ")"); - c.asyncSearch(s); + c.asyncSearch(s); // $ Alert } @RequestMapping - public void testUnboundBad7(@RequestParam String uBadSearchRequestAsync, @RequestParam String uBadSRDNAsync, LDAPConnection c) + public void testUnboundBad7(@RequestParam String uBadSearchRequestAsync, @RequestParam String uBadSRDNAsync, LDAPConnection c) // $ Source throws LDAPException { SearchRequest s = new SearchRequest(null, "ou=system" + uBadSRDNAsync, null, null, 1, 1, false, "(uid=" + uBadSearchRequestAsync + ")"); - c.asyncSearch(s); + c.asyncSearch(s); // $ Alert } @RequestMapping - public void testUnboundBad8(@RequestParam String uBadFilterCreateNOT, LDAPConnection c) throws LDAPException { - c.search(null, "ou=system", null, null, 1, 1, false, Filter.createNOTFilter(Filter.create(uBadFilterCreateNOT))); + public void testUnboundBad8(@RequestParam String uBadFilterCreateNOT, LDAPConnection c) throws LDAPException { // $ Source + c.search(null, "ou=system", null, null, 1, 1, false, Filter.createNOTFilter(Filter.create(uBadFilterCreateNOT))); // $ Alert } @RequestMapping - public void testUnboundBad9(@RequestParam String uBadFilterCreateToString, LDAPConnection c) throws LDAPException { - c.search(null, "ou=system", null, null, 1, 1, false, Filter.create(uBadFilterCreateToString).toString()); + public void testUnboundBad9(@RequestParam String uBadFilterCreateToString, LDAPConnection c) throws LDAPException { // $ Source + c.search(null, "ou=system", null, null, 1, 1, false, Filter.create(uBadFilterCreateToString).toString()); // $ Alert } @RequestMapping - public void testUnboundBad10(@RequestParam String uBadFilterCreateToStringBuffer, LDAPConnection c) throws LDAPException { + public void testUnboundBad10(@RequestParam String uBadFilterCreateToStringBuffer, LDAPConnection c) throws LDAPException { // $ Source StringBuilder b = new StringBuilder(); Filter.create(uBadFilterCreateToStringBuffer).toNormalizedString(b); - c.search(null, "ou=system", null, null, 1, 1, false, b.toString()); + c.search(null, "ou=system", null, null, 1, 1, false, b.toString()); // $ Alert } @RequestMapping - public void testUnboundBad11(@RequestParam String uBadSearchRequestDuplicate, LDAPConnection c) + public void testUnboundBad11(@RequestParam String uBadSearchRequestDuplicate, LDAPConnection c) // $ Source throws LDAPException { SearchRequest s = new SearchRequest(null, "ou=system", null, null, 1, 1, false, "(uid=" + uBadSearchRequestDuplicate + ")"); - c.search(s.duplicate()); + c.search(s.duplicate()); // $ Alert } @RequestMapping - public void testUnboundBad12(@RequestParam String uBadROSearchRequestDuplicate, LDAPConnection c) + public void testUnboundBad12(@RequestParam String uBadROSearchRequestDuplicate, LDAPConnection c) // $ Source throws LDAPException { ReadOnlySearchRequest s = new SearchRequest(null, "ou=system", null, null, 1, 1, false, "(uid=" + uBadROSearchRequestDuplicate + ")"); - c.search(s.duplicate()); + c.search(s.duplicate()); // $ Alert } @RequestMapping - public void testUnboundBad13(@RequestParam String uBadSearchRequestSetDN, LDAPConnection c) + public void testUnboundBad13(@RequestParam String uBadSearchRequestSetDN, LDAPConnection c) // $ Source throws LDAPException { SearchRequest s = new SearchRequest(null, "", null, null, 1, 1, false, ""); s.setBaseDN(uBadSearchRequestSetDN); - c.search(s); + c.search(s); // $ Alert } @RequestMapping - public void testUnboundBad14(@RequestParam String uBadSearchRequestSetFilter, LDAPConnection c) + public void testUnboundBad14(@RequestParam String uBadSearchRequestSetFilter, LDAPConnection c) // $ Source throws LDAPException { SearchRequest s = new SearchRequest(null, "ou=system", null, null, 1, 1, false, ""); s.setFilter(uBadSearchRequestSetFilter); - c.search(s); + c.search(s); // $ Alert } @RequestMapping @@ -226,72 +226,72 @@ public class LdapInjection { // Spring LDAP @RequestMapping - public void testSpringBad1(@RequestParam String sBad, @RequestParam String sBadDN, LdapTemplate c) { - c.search("ou=system" + sBadDN, "(uid=" + sBad + ")", 1, false, null); + public void testSpringBad1(@RequestParam String sBad, @RequestParam String sBadDN, LdapTemplate c) { // $ Source + c.search("ou=system" + sBadDN, "(uid=" + sBad + ")", 1, false, null); // $ Alert } @RequestMapping - public void testSpringBad2(@RequestParam String sBad, @RequestParam String sBadDNLNBuilder, LdapTemplate c) { - c.authenticate(LdapNameBuilder.newInstance("ou=system" + sBadDNLNBuilder).build(), "(uid=" + sBad + ")", "pass"); + public void testSpringBad2(@RequestParam String sBad, @RequestParam String sBadDNLNBuilder, LdapTemplate c) { // $ Source + c.authenticate(LdapNameBuilder.newInstance("ou=system" + sBadDNLNBuilder).build(), "(uid=" + sBad + ")", "pass"); // $ Alert } @RequestMapping - public void testSpringBad3(@RequestParam String sBad, @RequestParam String sBadDNLNBuilderAdd, LdapTemplate c) { - c.searchForObject(LdapNameBuilder.newInstance().add("ou=system" + sBadDNLNBuilderAdd).build(), "(uid=" + sBad + ")", null); + public void testSpringBad3(@RequestParam String sBad, @RequestParam String sBadDNLNBuilderAdd, LdapTemplate c) { // $ Source + c.searchForObject(LdapNameBuilder.newInstance().add("ou=system" + sBadDNLNBuilderAdd).build(), "(uid=" + sBad + ")", null); // $ Alert } @RequestMapping - public void testSpringBad4(@RequestParam String sBadLdapQuery, LdapTemplate c) { - c.findOne(LdapQueryBuilder.query().filter("(uid=" + sBadLdapQuery + ")"), null); + public void testSpringBad4(@RequestParam String sBadLdapQuery, LdapTemplate c) { // $ Source + c.findOne(LdapQueryBuilder.query().filter("(uid=" + sBadLdapQuery + ")"), null); // $ Alert } @RequestMapping - public void testSpringBad5(@RequestParam String sBadFilter, @RequestParam String sBadDNLdapUtils, LdapTemplate c) { - c.find(LdapUtils.newLdapName("ou=system" + sBadDNLdapUtils), new HardcodedFilter("(uid=" + sBadFilter + ")"), null, null); + public void testSpringBad5(@RequestParam String sBadFilter, @RequestParam String sBadDNLdapUtils, LdapTemplate c) { // $ Source + c.find(LdapUtils.newLdapName("ou=system" + sBadDNLdapUtils), new HardcodedFilter("(uid=" + sBadFilter + ")"), null, null); // $ Alert } @RequestMapping - public void testSpringBad6(@RequestParam String sBadLdapQuery, LdapTemplate c) { - c.searchForContext(LdapQueryBuilder.query().filter("(uid=" + sBadLdapQuery + ")")); + public void testSpringBad6(@RequestParam String sBadLdapQuery, LdapTemplate c) { // $ Source + c.searchForContext(LdapQueryBuilder.query().filter("(uid=" + sBadLdapQuery + ")")); // $ Alert } @RequestMapping - public void testSpringBad7(@RequestParam String sBadLdapQuery2, LdapTemplate c) { + public void testSpringBad7(@RequestParam String sBadLdapQuery2, LdapTemplate c) { // $ Source LdapQuery q = LdapQueryBuilder.query().filter("(uid=" + sBadLdapQuery2 + ")"); - c.searchForContext(q); + c.searchForContext(q); // $ Alert } @RequestMapping - public void testSpringBad8(@RequestParam String sBadLdapQueryWithFilter, LdapTemplate c) { - c.searchForContext(LdapQueryBuilder.query().filter(new HardcodedFilter("(uid=" + sBadLdapQueryWithFilter + ")"))); + public void testSpringBad8(@RequestParam String sBadLdapQueryWithFilter, LdapTemplate c) { // $ Source + c.searchForContext(LdapQueryBuilder.query().filter(new HardcodedFilter("(uid=" + sBadLdapQueryWithFilter + ")"))); // $ Alert } @RequestMapping - public void testSpringBad9(@RequestParam String sBadLdapQueryWithFilter2, LdapTemplate c) { + public void testSpringBad9(@RequestParam String sBadLdapQueryWithFilter2, LdapTemplate c) { // $ Source org.springframework.ldap.filter.Filter f = new HardcodedFilter("(uid=" + sBadLdapQueryWithFilter2 + ")"); - c.searchForContext(LdapQueryBuilder.query().filter(f)); + c.searchForContext(LdapQueryBuilder.query().filter(f)); // $ Alert } @RequestMapping - public void testSpringBad10(@RequestParam String sBadLdapQueryBase, LdapTemplate c) { - c.find(LdapQueryBuilder.query().base(sBadLdapQueryBase).base(), null, null, null); + public void testSpringBad10(@RequestParam String sBadLdapQueryBase, LdapTemplate c) { // $ Source + c.find(LdapQueryBuilder.query().base(sBadLdapQueryBase).base(), null, null, null); // $ Alert } @RequestMapping - public void testSpringBad11(@RequestParam String sBadLdapQueryComplex, LdapTemplate c) { - c.searchForContext(LdapQueryBuilder.query().base(sBadLdapQueryComplex).where("uid").is("test")); + public void testSpringBad11(@RequestParam String sBadLdapQueryComplex, LdapTemplate c) { // $ Source + c.searchForContext(LdapQueryBuilder.query().base(sBadLdapQueryComplex).where("uid").is("test")); // $ Alert } @RequestMapping - public void testSpringBad12(@RequestParam String sBadFilterToString, LdapTemplate c) { - c.search("", new HardcodedFilter("(uid=" + sBadFilterToString + ")").toString(), 1, false, null); + public void testSpringBad12(@RequestParam String sBadFilterToString, LdapTemplate c) { // $ Source + c.search("", new HardcodedFilter("(uid=" + sBadFilterToString + ")").toString(), 1, false, null); // $ Alert } @RequestMapping - public void testSpringBad13(@RequestParam String sBadFilterEncode, LdapTemplate c) { + public void testSpringBad13(@RequestParam String sBadFilterEncode, LdapTemplate c) { // $ Source StringBuffer s = new StringBuffer(); new HardcodedFilter("(uid=" + sBadFilterEncode + ")").encode(s); - c.search("", s.toString(), 1, false, null); + c.search("", s.toString(), 1, false, null); // $ Alert } @RequestMapping @@ -311,39 +311,39 @@ public class LdapInjection { // Apache LDAP API @RequestMapping - public void testApacheBad1(@RequestParam String aBad, @RequestParam String aBadDN, LdapConnection c) + public void testApacheBad1(@RequestParam String aBad, @RequestParam String aBadDN, LdapConnection c) // $ Source throws LdapException { - c.search("ou=system" + aBadDN, "(uid=" + aBad + ")", null); + c.search("ou=system" + aBadDN, "(uid=" + aBad + ")", null); // $ Alert } @RequestMapping - public void testApacheBad2(@RequestParam String aBad, @RequestParam String aBadDNObjToString, LdapNetworkConnection c) + public void testApacheBad2(@RequestParam String aBad, @RequestParam String aBadDNObjToString, LdapNetworkConnection c) // $ Source throws LdapException { - c.search(new Dn("ou=system" + aBadDNObjToString).getName(), "(uid=" + aBad + ")", null); + c.search(new Dn("ou=system" + aBadDNObjToString).getName(), "(uid=" + aBad + ")", null); // $ Alert } @RequestMapping - public void testApacheBad3(@RequestParam String aBadSearchRequest, LdapConnection c) + public void testApacheBad3(@RequestParam String aBadSearchRequest, LdapConnection c) // $ Source throws LdapException { org.apache.directory.api.ldap.model.message.SearchRequest s = new SearchRequestImpl(); s.setFilter("(uid=" + aBadSearchRequest + ")"); - c.search(s); + c.search(s); // $ Alert } @RequestMapping - public void testApacheBad4(@RequestParam String aBadSearchRequestImpl, @RequestParam String aBadDNObj, LdapConnection c) + public void testApacheBad4(@RequestParam String aBadSearchRequestImpl, @RequestParam String aBadDNObj, LdapConnection c) // $ Source throws LdapException { SearchRequestImpl s = new SearchRequestImpl(); s.setBase(new Dn("ou=system" + aBadDNObj)); - c.search(s); + c.search(s); // $ Alert } @RequestMapping - public void testApacheBad5(@RequestParam String aBadDNSearchRequestGet, LdapConnection c) + public void testApacheBad5(@RequestParam String aBadDNSearchRequestGet, LdapConnection c) // $ Source throws LdapException { org.apache.directory.api.ldap.model.message.SearchRequest s = new SearchRequestImpl(); s.setBase(new Dn("ou=system" + aBadDNSearchRequestGet)); - c.search(s.getBase(), "(uid=test", null); + c.search(s.getBase(), "(uid=test", null); // $ Alert } @RequestMapping diff --git a/java/ql/test/query-tests/security/CWE-090/LdapInjection.qlref b/java/ql/test/query-tests/security/CWE-090/LdapInjection.qlref index 53b04e4c00f..01bec30b84b 100644 --- a/java/ql/test/query-tests/security/CWE-090/LdapInjection.qlref +++ b/java/ql/test/query-tests/security/CWE-090/LdapInjection.qlref @@ -1,2 +1,4 @@ query: Security/CWE/CWE-090/LdapInjection.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-094/InsecureBeanValidation.java b/java/ql/test/query-tests/security/CWE-094/InsecureBeanValidation.java index 71d4145adfc..bfa94bbe3a8 100644 --- a/java/ql/test/query-tests/security/CWE-094/InsecureBeanValidation.java +++ b/java/ql/test/query-tests/security/CWE-094/InsecureBeanValidation.java @@ -4,11 +4,11 @@ import javax.validation.ConstraintValidatorContext; public class InsecureBeanValidation implements ConstraintValidator { @Override - public boolean isValid(String object, ConstraintValidatorContext constraintContext) { + public boolean isValid(String object, ConstraintValidatorContext constraintContext) { // $ Source String value = object + " is invalid"; // Bad: Bean properties (normally user-controlled) are passed directly to `buildConstraintViolationWithTemplate` - constraintContext.buildConstraintViolationWithTemplate(value).addConstraintViolation().disableDefaultConstraintViolation(); + constraintContext.buildConstraintViolationWithTemplate(value).addConstraintViolation().disableDefaultConstraintViolation(); // $ Alert // Good: Using message parameters constraintContext.buildConstraintViolationWithTemplate("literal {message_parameter}").addConstraintViolation().disableDefaultConstraintViolation(); diff --git a/java/ql/test/query-tests/security/CWE-094/InsecureBeanValidation.qlref b/java/ql/test/query-tests/security/CWE-094/InsecureBeanValidation.qlref index 73254e55f93..d65ecf968f5 100644 --- a/java/ql/test/query-tests/security/CWE-094/InsecureBeanValidation.qlref +++ b/java/ql/test/query-tests/security/CWE-094/InsecureBeanValidation.qlref @@ -1,2 +1,4 @@ query: Security/CWE/CWE-094/InsecureBeanValidation.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-1104/semmle/tests/MavenPomDependsOnBintray.qlref b/java/ql/test/query-tests/security/CWE-1104/semmle/tests/MavenPomDependsOnBintray.qlref index 9f05b219bfe..8f21e578165 100644 --- a/java/ql/test/query-tests/security/CWE-1104/semmle/tests/MavenPomDependsOnBintray.qlref +++ b/java/ql/test/query-tests/security/CWE-1104/semmle/tests/MavenPomDependsOnBintray.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-1104/MavenPomDependsOnBintray.ql +query: Security/CWE/CWE-1104/MavenPomDependsOnBintray.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-1104/semmle/tests/bad-bintray-pom.xml b/java/ql/test/query-tests/security/CWE-1104/semmle/tests/bad-bintray-pom.xml index 7e133256428..e5a87437df7 100644 --- a/java/ql/test/query-tests/security/CWE-1104/semmle/tests/bad-bintray-pom.xml +++ b/java/ql/test/query-tests/security/CWE-1104/semmle/tests/bad-bintray-pom.xml @@ -19,13 +19,13 @@ JCenter https://jcenter.bintray.com - + jcenter-snapshots JCenter https://jcenter.bintray.com - + @@ -33,7 +33,7 @@ JCenter https://jcenter.bintray.com - + @@ -41,7 +41,7 @@ JCenter https://dl.bintray.com/groovy/maven - + @@ -49,6 +49,6 @@ JCenter https://jcenter.bintray.com - + diff --git a/java/ql/test/query-tests/security/CWE-113/semmle/tests/ResponseSplitting.java b/java/ql/test/query-tests/security/CWE-113/semmle/tests/ResponseSplitting.java index b2ea8780e8e..abe71180838 100644 --- a/java/ql/test/query-tests/security/CWE-113/semmle/tests/ResponseSplitting.java +++ b/java/ql/test/query-tests/security/CWE-113/semmle/tests/ResponseSplitting.java @@ -19,14 +19,14 @@ public class ResponseSplitting extends HttpServlet { // BAD: setting a cookie with an unvalidated parameter // can lead to HTTP splitting { - Cookie cookie = new Cookie("name", request.getParameter("name")); - response.addCookie(cookie); + Cookie cookie = new Cookie("name", request.getParameter("name")); // $ Source + response.addCookie(cookie); // $ Alert } // BAD: setting a header with an unvalidated parameter // can lead to HTTP splitting - response.addHeader("Content-type", request.getParameter("contentType")); - response.setHeader("Content-type", request.getParameter("contentType")); + response.addHeader("Content-type", request.getParameter("contentType")); // $ Alert + response.setHeader("Content-type", request.getParameter("contentType")); // $ Alert // GOOD: remove special characters before putting them in the header { @@ -50,13 +50,13 @@ public class ResponseSplitting extends HttpServlet { } public void sanitizerTests(HttpServletRequest request, HttpServletResponse response){ - String t = request.getParameter("contentType"); + String t = request.getParameter("contentType"); // $ Source // GOOD: whitelist-based sanitization response.setHeader("h", t.replaceAll("[^a-zA-Z]", "")); // BAD: not replacing all problematic characters - response.setHeader("h", t.replaceFirst("[^a-zA-Z]", "")); + response.setHeader("h", t.replaceFirst("[^a-zA-Z]", "")); // $ Alert // GOOD: replace all line breaks response.setHeader("h", t.replace('\n', ' ').replace('\r', ' ')); diff --git a/java/ql/test/query-tests/security/CWE-113/semmle/tests/ResponseSplitting.qlref b/java/ql/test/query-tests/security/CWE-113/semmle/tests/ResponseSplitting.qlref index 897d985e9d4..561c8aa65a3 100644 --- a/java/ql/test/query-tests/security/CWE-113/semmle/tests/ResponseSplitting.qlref +++ b/java/ql/test/query-tests/security/CWE-113/semmle/tests/ResponseSplitting.qlref @@ -1,2 +1,4 @@ query: Security/CWE/CWE-113/ResponseSplitting.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-129/semmle/tests/ImproperValidationOfArrayConstruction.qlref b/java/ql/test/query-tests/security/CWE-129/semmle/tests/ImproperValidationOfArrayConstruction.qlref index fc09d33596a..883151805d4 100644 --- a/java/ql/test/query-tests/security/CWE-129/semmle/tests/ImproperValidationOfArrayConstruction.qlref +++ b/java/ql/test/query-tests/security/CWE-129/semmle/tests/ImproperValidationOfArrayConstruction.qlref @@ -1,2 +1,4 @@ query: Security/CWE/CWE-129/ImproperValidationOfArrayConstruction.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-129/semmle/tests/ImproperValidationOfArrayConstructionCodeSpecified.qlref b/java/ql/test/query-tests/security/CWE-129/semmle/tests/ImproperValidationOfArrayConstructionCodeSpecified.qlref index 4cff7c39aa6..e8277291432 100644 --- a/java/ql/test/query-tests/security/CWE-129/semmle/tests/ImproperValidationOfArrayConstructionCodeSpecified.qlref +++ b/java/ql/test/query-tests/security/CWE-129/semmle/tests/ImproperValidationOfArrayConstructionCodeSpecified.qlref @@ -1,2 +1,4 @@ query: Security/CWE/CWE-129/ImproperValidationOfArrayConstructionCodeSpecified.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-129/semmle/tests/ImproperValidationOfArrayIndex.qlref b/java/ql/test/query-tests/security/CWE-129/semmle/tests/ImproperValidationOfArrayIndex.qlref index 4dd969c5476..b9d7cd83e49 100644 --- a/java/ql/test/query-tests/security/CWE-129/semmle/tests/ImproperValidationOfArrayIndex.qlref +++ b/java/ql/test/query-tests/security/CWE-129/semmle/tests/ImproperValidationOfArrayIndex.qlref @@ -1,2 +1,4 @@ query: Security/CWE/CWE-129/ImproperValidationOfArrayIndex.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-129/semmle/tests/ImproperValidationOfArrayIndexCodeSpecified.qlref b/java/ql/test/query-tests/security/CWE-129/semmle/tests/ImproperValidationOfArrayIndexCodeSpecified.qlref index b267f488b34..98cc770b734 100644 --- a/java/ql/test/query-tests/security/CWE-129/semmle/tests/ImproperValidationOfArrayIndexCodeSpecified.qlref +++ b/java/ql/test/query-tests/security/CWE-129/semmle/tests/ImproperValidationOfArrayIndexCodeSpecified.qlref @@ -1,2 +1,4 @@ query: Security/CWE/CWE-129/ImproperValidationOfArrayIndexCodeSpecified.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-129/semmle/tests/Test.java b/java/ql/test/query-tests/security/CWE-129/semmle/tests/Test.java index c7be8b0031c..956912f0aba 100644 --- a/java/ql/test/query-tests/security/CWE-129/semmle/tests/Test.java +++ b/java/ql/test/query-tests/security/CWE-129/semmle/tests/Test.java @@ -11,12 +11,12 @@ class Test { public static void basic() { int array[] = { 0, 1, 2, 3, 4 }; - String userProperty = System.getProperty("userProperty"); + String userProperty = System.getProperty("userProperty"); // $ Source[java/improper-validation-of-array-index] try { int index = Integer.parseInt(userProperty.trim()); // BAD Accessing array without conditional check - System.out.println(array[index]); + System.out.println(array[index]); // $ Alert[java/improper-validation-of-array-index] if (index >= 0 && index < array.length) { // GOOD Accessing array under conditions @@ -38,10 +38,10 @@ class Test { public static void random() { int array[] = { 0, 1, 2, 3, 4 }; - int index = (new SecureRandom()).nextInt(10); + int index = (new SecureRandom()).nextInt(10); // $ Source[java/improper-validation-of-array-index-code-specified] // BAD Accessing array without conditional check - System.out.println(array[index]); + System.out.println(array[index]); // $ Alert[java/improper-validation-of-array-index-code-specified] if (index < array.length) { // GOOD Accessing array under conditions @@ -56,10 +56,10 @@ class Test { public static void apacheRandom() { int array[] = { 0, 1, 2, 3, 4 }; - int index = RandomUtils.nextInt(0, 10); + int index = RandomUtils.nextInt(0, 10); // $ Source[java/improper-validation-of-array-index-code-specified] // BAD Accessing array without conditional check - System.out.println(array[index]); + System.out.println(array[index]); // $ Alert[java/improper-validation-of-array-index-code-specified] if (index < array.length) { // GOOD Accessing array under conditions @@ -73,20 +73,20 @@ class Test { public static void construction() { - String userProperty = System.getProperty("userProperty"); + String userProperty = System.getProperty("userProperty"); // $ Source[java/improper-validation-of-array-construction] try { int size = Integer.parseInt(userProperty.trim()); - int[] array = new int[size]; + int[] array = new int[size]; // $ Sink[java/improper-validation-of-array-construction] // BAD The array was created without checking the size, so this access may be dubious - System.out.println(array[0]); + System.out.println(array[0]); // $ Alert[java/improper-validation-of-array-construction] if (size >= 0) { - int[] array2 = new int[size]; + int[] array2 = new int[size]; // $ Sink[java/improper-validation-of-array-construction] // BAD The array was created without checking that the size is greater than zero - System.out.println(array2[0]); + System.out.println(array2[0]); // $ Alert[java/improper-validation-of-array-construction] } if (size > 0) { @@ -102,12 +102,12 @@ class Test { public static void constructionBounded() { - int size = 0; + int size = 0; // $ Source[java/improper-validation-of-array-construction-code-specified] - int[] array = new int[size]; + int[] array = new int[size]; // $ Sink[java/improper-validation-of-array-construction-code-specified] // BAD Array may be empty. - System.out.println(array[0]); + System.out.println(array[0]); // $ Alert[java/improper-validation-of-array-construction-code-specified] int index = 0; if (index < array.length) { diff --git a/java/ql/test/query-tests/security/CWE-134/semmle/tests/ExternallyControlledFormatString.qlref b/java/ql/test/query-tests/security/CWE-134/semmle/tests/ExternallyControlledFormatString.qlref index 6309a7eb502..ee54ac69fe1 100644 --- a/java/ql/test/query-tests/security/CWE-134/semmle/tests/ExternallyControlledFormatString.qlref +++ b/java/ql/test/query-tests/security/CWE-134/semmle/tests/ExternallyControlledFormatString.qlref @@ -1,2 +1,4 @@ query: Security/CWE/CWE-134/ExternallyControlledFormatString.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-134/semmle/tests/Test.java b/java/ql/test/query-tests/security/CWE-134/semmle/tests/Test.java index 140c9974086..56c9930f94d 100644 --- a/java/ql/test/query-tests/security/CWE-134/semmle/tests/Test.java +++ b/java/ql/test/query-tests/security/CWE-134/semmle/tests/Test.java @@ -14,29 +14,29 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; class Test { public static void basic() { - String userProperty = System.getProperty("userProperty"); + String userProperty = System.getProperty("userProperty"); // $ Source // BAD User provided value as format string for String.format - String.format(userProperty); + String.format(userProperty); // $ Alert // BAD User provided value as format string for PrintStream.format - System.out.format(userProperty); + System.out.format(userProperty); // $ Alert // BAD User provided value as format string for PrintStream.printf - System.out.printf(userProperty); + System.out.printf(userProperty); // $ Alert // BAD User provided value as format string for Formatter.format - new Formatter().format(userProperty); + new Formatter().format(userProperty); // $ Alert // BAD User provided value as format string for Formatter.format - new Formatter().format(Locale.ENGLISH, userProperty); + new Formatter().format(Locale.ENGLISH, userProperty); // $ Alert } public class FileUploadServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - String userParameter = request.getParameter("userProvidedParameter"); + String userParameter = request.getParameter("userProvidedParameter"); // $ Source formatString(userParameter); } private void formatString(String format) { // BAD This is used with user provided parameter - System.out.format(format); + System.out.format(format); // $ Alert } } } diff --git a/java/ql/test/query-tests/security/CWE-190/semmle/tests/ArithmeticTainted.java b/java/ql/test/query-tests/security/CWE-190/semmle/tests/ArithmeticTainted.java index 04020aac31f..0167af87497 100644 --- a/java/ql/test/query-tests/security/CWE-190/semmle/tests/ArithmeticTainted.java +++ b/java/ql/test/query-tests/security/CWE-190/semmle/tests/ArithmeticTainted.java @@ -14,7 +14,7 @@ public class ArithmeticTainted { try { - readerInputStream = new InputStreamReader(System.in, "UTF-8"); + readerInputStream = new InputStreamReader(System.in, "UTF-8"); // $ Source[java/tainted-arithmetic] readerBuffered = new BufferedReader(readerInputStream); String stringNumber = readerBuffered.readLine(); if (stringNumber != null) { @@ -29,7 +29,7 @@ public class ArithmeticTainted { { // BAD: may overflow if input data is very large - int scaled = data + 10; + int scaled = data + 10; // $ Alert[java/tainted-arithmetic] } { @@ -37,7 +37,7 @@ public class ArithmeticTainted { if (data > Integer.MIN_VALUE) { System.out.println("I'm guarded"); } - int output = data - 10; + int output = data - 10; // $ Alert[java/tainted-arithmetic] } { @@ -47,7 +47,7 @@ public class ArithmeticTainted { } else { System.out.println("I'm not guarded"); } - int output = data + 1; + int output = data + 1; // $ Alert[java/tainted-arithmetic] } { @@ -68,7 +68,7 @@ public class ArithmeticTainted { // GOOD int output_ok = ok + 1; // BAD - int output = herring + 1; + int output = herring + 1; // $ Alert[java/tainted-arithmetic] } { @@ -92,7 +92,7 @@ public class ArithmeticTainted { { // BAD: tainted int value is widened to type long, but subsequently // cast to narrower type int - int widenedThenNarrowed = (int) (data + 10L); + int widenedThenNarrowed = (int) (data + 10L); // $ Alert[java/tainted-arithmetic] } // The following test case has an arbitrary guard on hashcode @@ -126,19 +126,19 @@ public class ArithmeticTainted { public static void test(int data) { // BAD: may overflow if input data is very large - data++; + data++; // $ Alert[java/tainted-arithmetic] } public static void test2(int data) { // BAD: may overflow if input data is very large - ++data; + ++data; // $ Alert[java/tainted-arithmetic] } public static void test3(int data) { // BAD: may underflow if input data is very small - data--; + data--; // $ Alert[java/tainted-arithmetic] } public static void test4(int data) { // BAD: may underflow if input data is very small - --data; + --data; // $ Alert[java/tainted-arithmetic] } public static void boundsCheckGood(byte[] bs, int off, int len) { diff --git a/java/ql/test/query-tests/security/CWE-190/semmle/tests/ArithmeticTainted.qlref b/java/ql/test/query-tests/security/CWE-190/semmle/tests/ArithmeticTainted.qlref index 938a60cfc01..38ee81494e1 100644 --- a/java/ql/test/query-tests/security/CWE-190/semmle/tests/ArithmeticTainted.qlref +++ b/java/ql/test/query-tests/security/CWE-190/semmle/tests/ArithmeticTainted.qlref @@ -1,2 +1,4 @@ query: Security/CWE/CWE-190/ArithmeticTainted.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-190/semmle/tests/ArithmeticUncontrolled.qlref b/java/ql/test/query-tests/security/CWE-190/semmle/tests/ArithmeticUncontrolled.qlref index c6d57c73510..e298fb9edc1 100644 --- a/java/ql/test/query-tests/security/CWE-190/semmle/tests/ArithmeticUncontrolled.qlref +++ b/java/ql/test/query-tests/security/CWE-190/semmle/tests/ArithmeticUncontrolled.qlref @@ -1,2 +1,4 @@ query: Security/CWE/CWE-190/ArithmeticUncontrolled.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-190/semmle/tests/ArithmeticWithExtremeValues.qlref b/java/ql/test/query-tests/security/CWE-190/semmle/tests/ArithmeticWithExtremeValues.qlref index 0eaecb36941..f01d5c0f24f 100644 --- a/java/ql/test/query-tests/security/CWE-190/semmle/tests/ArithmeticWithExtremeValues.qlref +++ b/java/ql/test/query-tests/security/CWE-190/semmle/tests/ArithmeticWithExtremeValues.qlref @@ -1,2 +1,4 @@ query: Security/CWE/CWE-190/ArithmeticWithExtremeValues.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-190/semmle/tests/ComparisonWithWiderType.java b/java/ql/test/query-tests/security/CWE-190/semmle/tests/ComparisonWithWiderType.java index 88c520307a4..ace1fff92c1 100644 --- a/java/ql/test/query-tests/security/CWE-190/semmle/tests/ComparisonWithWiderType.java +++ b/java/ql/test/query-tests/security/CWE-190/semmle/tests/ComparisonWithWiderType.java @@ -1,7 +1,7 @@ public class ComparisonWithWiderType { public void testLt(long l) { // BAD: loop variable is an int, but the upper bound is a long - for (int i = 0; i < l; i++) { + for (int i = 0; i < l; i++) { // $ Alert[java/comparison-with-wider-type] System.out.println(i); } @@ -13,7 +13,7 @@ public class ComparisonWithWiderType { public void testGt(short c) { // BAD: loop variable is a byte, but the upper bound is a short - for (byte b = 0; c > b; b++) { + for (byte b = 0; c > b; b++) { // $ Alert[java/comparison-with-wider-type] System.out.println(b); } } @@ -24,4 +24,4 @@ public class ComparisonWithWiderType { System.out.println(l); } } -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/security/CWE-190/semmle/tests/ComparisonWithWiderType.qlref b/java/ql/test/query-tests/security/CWE-190/semmle/tests/ComparisonWithWiderType.qlref index 4605189317f..f836a00c9c4 100644 --- a/java/ql/test/query-tests/security/CWE-190/semmle/tests/ComparisonWithWiderType.qlref +++ b/java/ql/test/query-tests/security/CWE-190/semmle/tests/ComparisonWithWiderType.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-190/ComparisonWithWiderType.ql \ No newline at end of file +query: Security/CWE/CWE-190/ComparisonWithWiderType.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-190/semmle/tests/InformationLoss.qlref b/java/ql/test/query-tests/security/CWE-190/semmle/tests/InformationLoss.qlref index ce7d4116a76..c9ab00052ae 100644 --- a/java/ql/test/query-tests/security/CWE-190/semmle/tests/InformationLoss.qlref +++ b/java/ql/test/query-tests/security/CWE-190/semmle/tests/InformationLoss.qlref @@ -1 +1,2 @@ -Likely Bugs/Arithmetic/InformationLoss.ql \ No newline at end of file +query: Likely Bugs/Arithmetic/InformationLoss.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-190/semmle/tests/IntMultToLong.qlref b/java/ql/test/query-tests/security/CWE-190/semmle/tests/IntMultToLong.qlref index 9f172bbac42..4616a5ea9dc 100644 --- a/java/ql/test/query-tests/security/CWE-190/semmle/tests/IntMultToLong.qlref +++ b/java/ql/test/query-tests/security/CWE-190/semmle/tests/IntMultToLong.qlref @@ -1 +1,2 @@ -Likely Bugs/Arithmetic/IntMultToLong.ql \ No newline at end of file +query: Likely Bugs/Arithmetic/IntMultToLong.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-190/semmle/tests/Test.java b/java/ql/test/query-tests/security/CWE-190/semmle/tests/Test.java index f24d16a236c..ed1cf0bbe1f 100644 --- a/java/ql/test/query-tests/security/CWE-190/semmle/tests/Test.java +++ b/java/ql/test/query-tests/security/CWE-190/semmle/tests/Test.java @@ -18,21 +18,21 @@ class Test { // BAD: result of multiplication will be too large for // int, and will overflow before being stored in the long - long timeInNanos = timeInSeconds * 1000000000; + long timeInNanos = timeInSeconds * 1000000000; // $ Alert[java/integer-multiplication-cast-to-long] } { int timeInSeconds = 1000000; // BAD - long timeInNanos = timeInSeconds * 1000000000 + 4; + long timeInNanos = timeInSeconds * 1000000000 + 4; // $ Alert[java/integer-multiplication-cast-to-long] } { int timeInSeconds = 1000000; // BAD - long timeInNanos = true ? timeInSeconds * 1000000000 + 4 : 0; + long timeInNanos = true ? timeInSeconds * 1000000000 + 4 : 0; // $ Alert[java/integer-multiplication-cast-to-long] } { @@ -65,7 +65,7 @@ class Test { while (i < 1000000) { // BAD: getLargeNumber is implicitly narrowed to an integer // which will result in overflows if it is large - i += getLargeNumber(); + i += getLargeNumber(); // $ Alert[java/implicit-cast-in-compound-assignment] } } @@ -84,16 +84,16 @@ class Test { // FALSE POSITIVE: the query check purely based on the type, it // can't try to // determine whether the value may in fact always be in bounds - i += j; + i += j; // $ Alert[java/implicit-cast-in-compound-assignment] } // ArithmeticWithExtremeValues { int i = 0; - i = Integer.MAX_VALUE; + i = Integer.MAX_VALUE; // $ Source[java/extreme-value-arithmetic] int j = 0; // BAD: overflow - j = i + 1; + j = i + 1; // $ Alert[java/extreme-value-arithmetic] } { @@ -106,9 +106,9 @@ class Test { } { - long i = Long.MIN_VALUE; + long i = Long.MIN_VALUE; // $ Source[java/extreme-value-arithmetic] // BAD: overflow - long j = i - 1; + long j = i - 1; // $ Alert[java/extreme-value-arithmetic] } { @@ -135,16 +135,16 @@ class Test { int i = Integer.MAX_VALUE; if (i < Integer.MAX_VALUE) { // BAD: reassigned after guard - i = Integer.MAX_VALUE; - long j = i + 1; + i = Integer.MAX_VALUE; // $ Source[java/extreme-value-arithmetic] + long j = i + 1; // $ Alert[java/extreme-value-arithmetic] } } { - int i = Integer.MAX_VALUE; + int i = Integer.MAX_VALUE; // $ Source[java/extreme-value-arithmetic] // BAD: guarded the wrong way if (i > Integer.MIN_VALUE) { - long j = i + 1; + long j = i + 1; // $ Alert[java/extreme-value-arithmetic] } } @@ -182,32 +182,32 @@ class Test { } { - byte b = Byte.MAX_VALUE; + byte b = Byte.MAX_VALUE; // $ Source[java/extreme-value-arithmetic] // BAD: extreme byte value is widened to type int, but subsequently // cast to narrower type byte - byte widenedThenNarrowed = (byte) (b + 1); + byte widenedThenNarrowed = (byte) (b + 1); // $ Alert[java/extreme-value-arithmetic] } { - short s = Short.MAX_VALUE; + short s = Short.MAX_VALUE; // $ Source[java/extreme-value-arithmetic] // BAD: extreme short value is widened to type int, but subsequently // cast to narrower type short - short widenedThenNarrowed = (short) (s + 1); + short widenedThenNarrowed = (short) (s + 1); // $ Alert[java/extreme-value-arithmetic] } { - int i = Integer.MAX_VALUE; + int i = Integer.MAX_VALUE; // $ Source[java/extreme-value-arithmetic] // BAD: extreme int value is widened to type long, but subsequently // cast to narrower type int - int widenedThenNarrowed = (int) (i + 1L); + int widenedThenNarrowed = (int) (i + 1L); // $ Alert[java/extreme-value-arithmetic] } // ArithmeticUncontrolled - int data = (new java.security.SecureRandom()).nextInt(); + int data = (new java.security.SecureRandom()).nextInt(); // $ Source[java/uncontrolled-arithmetic] { // BAD: may overflow if data is large - int output = data + 1; + int output = data + 1; // $ Alert[java/uncontrolled-arithmetic] } { @@ -238,15 +238,15 @@ class Test { { // BAD: uncontrolled int value is widened to type long, but // subsequently cast to narrower type int - int widenedThenNarrowed = (int) (data + 10L); + int widenedThenNarrowed = (int) (data + 10L); // $ Alert[java/uncontrolled-arithmetic] } // ArithmeticUncontrolled using Apache RandomUtils - int data2 = RandomUtils.nextInt(); + int data2 = RandomUtils.nextInt(); // $ Source[java/uncontrolled-arithmetic] { // BAD: may overflow if data is large - int output = data2 + 1; + int output = data2 + 1; // $ Alert[java/uncontrolled-arithmetic] } { @@ -277,7 +277,7 @@ class Test { { // BAD: uncontrolled int value is widened to type long, but // subsequently cast to narrower type int - int widenedThenNarrowed = (int) (data2 + 10L); + int widenedThenNarrowed = (int) (data2 + 10L); // $ Alert[java/uncontrolled-arithmetic] } // InformationLoss @@ -286,11 +286,11 @@ class Test { while (arr[2] < 1000000) { // BAD: getLargeNumber is implicitly narrowed to an integer // which will result in overflows if it is large - arr[2] += getLargeNumber(); + arr[2] += getLargeNumber(); // $ Alert[java/implicit-cast-in-compound-assignment] } // BAD. - getAnIntArray()[0] += getLargeNumber(); + getAnIntArray()[0] += getLargeNumber(); // $ Alert[java/implicit-cast-in-compound-assignment] } } diff --git a/java/ql/test/query-tests/security/CWE-200/semmle/tests/TempDirLocalInformationDisclosure/Files.java b/java/ql/test/query-tests/security/CWE-200/semmle/tests/TempDirLocalInformationDisclosure/Files.java index cc8c1a736ad..89875947d76 100644 --- a/java/ql/test/query-tests/security/CWE-200/semmle/tests/TempDirLocalInformationDisclosure/Files.java +++ b/java/ql/test/query-tests/security/CWE-200/semmle/tests/TempDirLocalInformationDisclosure/Files.java @@ -7,12 +7,12 @@ public class Files { private static final int TEMP_DIR_ATTEMPTS = 10000; public static File createTempDir() { - File baseDir = new File(System.getProperty("java.io.tmpdir")); + File baseDir = new File(System.getProperty("java.io.tmpdir")); // $ Alert String baseName = System.currentTimeMillis() + "-"; for (int counter = 0; counter < TEMP_DIR_ATTEMPTS; counter++) { File tempDir = new File(baseDir, baseName + counter); - if (tempDir.mkdir()) { + if (tempDir.mkdir()) { // $ Sink return tempDir; } } diff --git a/java/ql/test/query-tests/security/CWE-200/semmle/tests/TempDirLocalInformationDisclosure/TempDirLocalInformationDisclosure.qlref b/java/ql/test/query-tests/security/CWE-200/semmle/tests/TempDirLocalInformationDisclosure/TempDirLocalInformationDisclosure.qlref index b7836c96d60..5c3a603d216 100644 --- a/java/ql/test/query-tests/security/CWE-200/semmle/tests/TempDirLocalInformationDisclosure/TempDirLocalInformationDisclosure.qlref +++ b/java/ql/test/query-tests/security/CWE-200/semmle/tests/TempDirLocalInformationDisclosure/TempDirLocalInformationDisclosure.qlref @@ -1,2 +1,4 @@ query: Security/CWE/CWE-200/TempDirLocalInformationDisclosure.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-200/semmle/tests/TempDirLocalInformationDisclosure/Test.java b/java/ql/test/query-tests/security/CWE-200/semmle/tests/TempDirLocalInformationDisclosure/Test.java index e1ec05ac51c..45a455a6232 100644 --- a/java/ql/test/query-tests/security/CWE-200/semmle/tests/TempDirLocalInformationDisclosure/Test.java +++ b/java/ql/test/query-tests/security/CWE-200/semmle/tests/TempDirLocalInformationDisclosure/Test.java @@ -17,7 +17,7 @@ public class Test { void vulnerableFileCreateTempFile() throws IOException { // VULNERABLE VERSION: - File tempVuln = File.createTempFile("random", "file"); + File tempVuln = File.createTempFile("random", "file"); // $ Alert // TO MAKE SAFE REWRITE TO: File tempSafe = Files.createTempFile("random", "file").toFile(); @@ -25,7 +25,7 @@ public class Test { void vulnerableFileCreateTempFileNull() throws IOException { // VULNERABLE VERSION: - File tempVuln = File.createTempFile("random", "file", null); + File tempVuln = File.createTempFile("random", "file", null); // $ Alert // TO MAKE SAFE REWRITE TO: File tempSafe = Files.createTempFile("random", "file").toFile(); @@ -33,10 +33,10 @@ public class Test { void vulnerableFileCreateTempFileTainted() throws IOException { // GIVEN: - File tempDir = new File(System.getProperty("java.io.tmpdir")); + File tempDir = new File(System.getProperty("java.io.tmpdir")); // $ Alert // VULNERABLE VERSION: - File tempVuln = File.createTempFile("random", "file", tempDir); + File tempVuln = File.createTempFile("random", "file", tempDir); // $ Sink // TO MAKE SAFE REWRITE TO (v1): File tempSafe1 = Files.createTempFile(tempDir.toPath(), "random", "file").toFile(); @@ -47,10 +47,10 @@ public class Test { void vulnerableFileCreateTempFileChildTainted() throws IOException { // GIVEN: - File tempDirChild = new File(new File(System.getProperty("java.io.tmpdir")), "/child"); + File tempDirChild = new File(new File(System.getProperty("java.io.tmpdir")), "/child"); // $ Alert // VULNERABLE VERSION: - File tempVuln = File.createTempFile("random", "file", tempDirChild); + File tempVuln = File.createTempFile("random", "file", tempDirChild); // $ Sink // TO MAKE SAFE REWRITE TO: File tempSafe = Files.createTempFile(tempDirChild.toPath(), "random", "file").toFile(); @@ -58,10 +58,10 @@ public class Test { void vulnerableFileCreateTempFileCanonical() throws IOException { // GIVEN: - File tempDir = new File(System.getProperty("java.io.tmpdir")).getCanonicalFile(); + File tempDir = new File(System.getProperty("java.io.tmpdir")).getCanonicalFile(); // $ Alert // VULNERABLE VERSION: - File tempVuln = File.createTempFile("random", "file", tempDir); + File tempVuln = File.createTempFile("random", "file", tempDir); // $ Sink // TO MAKE SAFE REWRITE TO (v1): File tempSafe1 = Files.createTempFile(tempDir.toPath(), "random", "file").toFile(); @@ -72,10 +72,10 @@ public class Test { void vulnerableFileCreateTempFileAbsolute() throws IOException { // GIVEN: - File tempDir = new File(System.getProperty("java.io.tmpdir")).getAbsoluteFile(); + File tempDir = new File(System.getProperty("java.io.tmpdir")).getAbsoluteFile(); // $ Alert // VULNERABLE VERSION: - File tempVuln = File.createTempFile("random", "file", tempDir); + File tempVuln = File.createTempFile("random", "file", tempDir); // $ Sink // TO MAKE SAFE REWRITE TO (v1): File tempSafe1 = Files.createTempFile(tempDir.toPath(), "random", "file").toFile(); @@ -94,7 +94,7 @@ public class Test { void vulnerableGuavaFilesCreateTempDir() { // VULNERABLE VERSION: - File tempDir = com.google.common.io.Files.createTempDir(); + File tempDir = com.google.common.io.Files.createTempDir(); // $ Alert // TO MAKE SAFE REWRITE TO: File tempSafe; @@ -107,10 +107,10 @@ public class Test { void vulnerableFileCreateTempFileMkdirTainted() { // GIVEN: - File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child"); + File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child"); // $ Alert // VULNERABLE VERSION: - tempDirChild.mkdir(); + tempDirChild.mkdir(); // $ Sink // TO MAKE SAFE REWRITE TO (v1): File tempSafe1; @@ -131,10 +131,10 @@ public class Test { void vulnerableFileCreateTempFileMkdirsTainted() { // GIVEN: - File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child"); + File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child"); // $ Alert // VULNERABLE VERSION: - tempDirChild.mkdirs(); + tempDirChild.mkdirs(); // $ Sink // TO MAKE SAFE REWRITE TO (v1): File tempSafe1; @@ -155,8 +155,8 @@ public class Test { void vulnerableFileCreateTempFilesWrite1() throws IOException { // VULNERABLE VERSION: - File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child.txt"); - Files.write(tempDirChild.toPath(), Arrays.asList("secret"), StandardCharsets.UTF_8, StandardOpenOption.CREATE); + File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child.txt"); // $ Alert + Files.write(tempDirChild.toPath(), Arrays.asList("secret"), StandardCharsets.UTF_8, StandardOpenOption.CREATE); // $ Sink // TO MAKE SAFE REWRITE TO (v1): // Use this version if you care that the file has the exact path of `[java.io.tmpdir]/child.txt` @@ -184,8 +184,8 @@ public class Test { byte[] byteArrray = secret.getBytes(); // VULNERABLE VERSION: - File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child.txt"); - Files.write(tempDirChild.toPath(), byteArrray, StandardOpenOption.CREATE); + File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child.txt"); // $ Alert + Files.write(tempDirChild.toPath(), byteArrray, StandardOpenOption.CREATE); // $ Sink // TO MAKE SAFE REWRITE TO (v1): // Use this version if you care that the file has the exact path of `[java.io.tmpdir]/child.txt` @@ -201,10 +201,10 @@ public class Test { void vulnerableFileCreateTempFilesNewBufferedWriter() throws IOException { // GIVEN: - Path tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-buffered-writer.txt").toPath(); + Path tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-buffered-writer.txt").toPath(); // $ Alert // VULNERABLE VERSION: - Files.newBufferedWriter(tempDirChild); + Files.newBufferedWriter(tempDirChild); // $ Sink // TO MAKE SAFE REWRITE TO: Files.createFile(tempDirChild, PosixFilePermissions.asFileAttribute(EnumSet.of(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE))); @@ -213,10 +213,10 @@ public class Test { void vulnerableFileCreateTempFilesNewOutputStream() throws IOException { // GIVEN: - Path tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-output-stream.txt").toPath(); + Path tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-output-stream.txt").toPath(); // $ Alert // VULNERABLE VERSION: - Files.newOutputStream(tempDirChild).close(); + Files.newOutputStream(tempDirChild).close(); // $ Sink // TO MAKE SAFE REWRITE TO: Files.createFile(tempDirChild, PosixFilePermissions.asFileAttribute(EnumSet.of(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE))); @@ -225,10 +225,10 @@ public class Test { void vulnerableFileCreateTempFilesCreateFile() throws IOException { // GIVEN: - File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-create-file.txt"); + File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-create-file.txt"); // $ Alert // VULNERABLE VERSION: - Files.createFile(tempDirChild.toPath()); + Files.createFile(tempDirChild.toPath()); // $ Sink // TO MAKE SAFE REWRITE TO: Files.createFile(tempDirChild.toPath(), PosixFilePermissions.asFileAttribute(EnumSet.of(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE))); @@ -246,10 +246,10 @@ public class Test { void vulnerableFileCreateDirectory() throws IOException { // GIVEN: - File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-create-directory"); + File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-create-directory"); // $ Alert // VULNERABLE VERSION: - Files.createDirectory(tempDirChild.toPath()); // Creates with permissions 'drwxr-xr-x' + Files.createDirectory(tempDirChild.toPath()); // $ Sink // Creates with permissions 'drwxr-xr-x' // TO MAKE SAFE REWRITE TO: Files.createDirectory(tempDirChild.toPath(), PosixFilePermissions.asFileAttribute(EnumSet.of(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE))); @@ -257,10 +257,10 @@ public class Test { void vulnerableFileCreateDirectories() throws IOException { // GIVEN: - File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-create-directories/child"); + File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-create-directories/child"); // $ Alert // VULNERABLE VERSION: - Files.createDirectories(tempDirChild.toPath()); // Creates with permissions 'drwxr-xr-x' + Files.createDirectories(tempDirChild.toPath()); // $ Sink // Creates with permissions 'drwxr-xr-x' // TO MAKE SAFE REWRITE TO: Files.createDirectories(tempDirChild.toPath(), PosixFilePermissions.asFileAttribute(EnumSet.of(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE))); @@ -291,11 +291,11 @@ public class Test { void vulnerableBecauseInvertedPosixCheck() throws IOException { // GIVEN: - File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-create-directory"); + File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-create-directory"); // $ Alert // Oops, this check should be inverted if (tempDirChild.toPath().getFileSystem().supportedFileAttributeViews().contains("posix")) { - Files.createDirectory(tempDirChild.toPath()); // Creates with permissions 'drwxr-xr-x' + Files.createDirectory(tempDirChild.toPath()); // $ Sink // Creates with permissions 'drwxr-xr-x' } } @@ -310,20 +310,20 @@ public class Test { void vulnerableBecauseCheckingForNotLinux() throws IOException { // GIVEN: - File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-create-directory"); + File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-create-directory"); // $ Alert if (!SystemUtils.IS_OS_LINUX) { - Files.createDirectory(tempDirChild.toPath()); + Files.createDirectory(tempDirChild.toPath()); // $ Sink } } void vulnerableBecauseInvertedFileSeparatorCheck() throws IOException { // GIVEN: - File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-create-directory"); + File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-create-directory"); // $ Alert // Oops, this check should be inverted if (File.separatorChar != '\\') { - Files.createDirectory(tempDirChild.toPath()); // Creates with permissions 'drwxr-xr-x' + Files.createDirectory(tempDirChild.toPath()); // $ Sink // Creates with permissions 'drwxr-xr-x' } } @@ -347,23 +347,23 @@ public class Test { void vulnerableBecauseFileSeparatorCheckElseCase() throws IOException { // GIVEN: - File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-create-directory"); + File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-create-directory"); // $ Alert if (File.separatorChar == '\\') { Files.createDirectory(tempDirChild.toPath()); // Safe } else { - Files.createDirectory(tempDirChild.toPath()); // Vulnerable + Files.createDirectory(tempDirChild.toPath()); // $ Sink // Vulnerable } } void vulnerableBecauseInvertedFileSeperatorCheckElseCase() throws IOException { // GIVEN: - File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-create-directory"); + File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-create-directory"); // $ Alert if (File.separatorChar != '/') { Files.createDirectory(tempDirChild.toPath()); // Safe } else { - Files.createDirectory(tempDirChild.toPath()); // Vulnerable + Files.createDirectory(tempDirChild.toPath()); // $ Sink // Vulnerable } } } diff --git a/java/ql/test/query-tests/security/CWE-200/semmle/tests/WebViewAccess/WebViewContentAccess.java b/java/ql/test/query-tests/security/CWE-200/semmle/tests/WebViewAccess/WebViewContentAccess.java index 7dd4aa89347..8901b40715b 100644 --- a/java/ql/test/query-tests/security/CWE-200/semmle/tests/WebViewAccess/WebViewContentAccess.java +++ b/java/ql/test/query-tests/security/CWE-200/semmle/tests/WebViewAccess/WebViewContentAccess.java @@ -12,7 +12,7 @@ interface WebViewGetter { public class WebViewContentAccess extends Activity { void enableContentAccess(WebView webview) { - webview.getSettings().setAllowContentAccess(true); + webview.getSettings().setAllowContentAccess(true); // $ Alert[java/android/websettings-allow-content-access] } void disableContentAccess(WebView webview) { @@ -35,25 +35,25 @@ public class WebViewContentAccess extends Activity { void configureWebViewUnsafe(WebView view1, WebViewGetter getter) { WebSettings settings; - view1.getSettings().setAllowContentAccess(true); + view1.getSettings().setAllowContentAccess(true); // $ Alert[java/android/websettings-allow-content-access] // Cast expression - WebView view2 = (WebView) findViewById(0); + WebView view2 = (WebView) findViewById(0); // $ Alert[java/android/websettings-allow-content-access] settings = view2.getSettings(); - settings.setAllowContentAccess(true); + settings.setAllowContentAccess(true); // $ Alert[java/android/websettings-allow-content-access] // Constructor - WebView view3 = new WebView(this); + WebView view3 = new WebView(this); // $ Alert[java/android/websettings-allow-content-access] settings = view3.getSettings(); - settings.setAllowContentAccess(true); + settings.setAllowContentAccess(true); // $ Alert[java/android/websettings-allow-content-access] // Method access - WebView view4 = getter.getAWebView(); + WebView view4 = getter.getAWebView(); // $ Alert[java/android/websettings-allow-content-access] settings = view4.getSettings(); - settings.setAllowContentAccess(true); + settings.setAllowContentAccess(true); // $ Alert[java/android/websettings-allow-content-access] - enableContentAccess(getter.getAWebView()); + enableContentAccess(getter.getAWebView()); // $ Alert[java/android/websettings-allow-content-access] - WebView view5 = getter.getAWebView(); + WebView view5 = getter.getAWebView(); // $ Alert[java/android/websettings-allow-content-access] } } diff --git a/java/ql/test/query-tests/security/CWE-200/semmle/tests/WebViewAccess/WebViewContentAccess.qlref b/java/ql/test/query-tests/security/CWE-200/semmle/tests/WebViewAccess/WebViewContentAccess.qlref index 7c9eba28b6e..cb5fbbc2676 100644 --- a/java/ql/test/query-tests/security/CWE-200/semmle/tests/WebViewAccess/WebViewContentAccess.qlref +++ b/java/ql/test/query-tests/security/CWE-200/semmle/tests/WebViewAccess/WebViewContentAccess.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-200/AndroidWebViewSettingsAllowsContentAccess.ql \ No newline at end of file +query: Security/CWE/CWE-200/AndroidWebViewSettingsAllowsContentAccess.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-200/semmle/tests/WebViewAccess/WebViewFileAccess.java b/java/ql/test/query-tests/security/CWE-200/semmle/tests/WebViewAccess/WebViewFileAccess.java index f42dbfaa84a..72b054e2589 100644 --- a/java/ql/test/query-tests/security/CWE-200/semmle/tests/WebViewAccess/WebViewFileAccess.java +++ b/java/ql/test/query-tests/security/CWE-200/semmle/tests/WebViewAccess/WebViewFileAccess.java @@ -5,11 +5,11 @@ class WebViewFileAccess { void configure(WebView view) { WebSettings settings = view.getSettings(); - settings.setAllowFileAccess(true); + settings.setAllowFileAccess(true); // $ Alert[java/android/websettings-file-access] - settings.setAllowFileAccessFromFileURLs(true); + settings.setAllowFileAccessFromFileURLs(true); // $ Alert[java/android/websettings-file-access] - settings.setAllowUniversalAccessFromFileURLs(true); + settings.setAllowUniversalAccessFromFileURLs(true); // $ Alert[java/android/websettings-file-access] } void configureSafe(WebView view) { diff --git a/java/ql/test/query-tests/security/CWE-200/semmle/tests/WebViewAccess/WebViewFileAccess.qlref b/java/ql/test/query-tests/security/CWE-200/semmle/tests/WebViewAccess/WebViewFileAccess.qlref index 6c3224a4a61..af0434e7711 100644 --- a/java/ql/test/query-tests/security/CWE-200/semmle/tests/WebViewAccess/WebViewFileAccess.qlref +++ b/java/ql/test/query-tests/security/CWE-200/semmle/tests/WebViewAccess/WebViewFileAccess.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-200/AndroidWebViewSettingsFileAccess.ql +query: Security/CWE/CWE-200/AndroidWebViewSettingsFileAccess.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-209/semmle/tests/SensitiveDataExposureThroughErrorMessage.qlref b/java/ql/test/query-tests/security/CWE-209/semmle/tests/SensitiveDataExposureThroughErrorMessage.qlref index 25d68a7fcef..c763b46a077 100644 --- a/java/ql/test/query-tests/security/CWE-209/semmle/tests/SensitiveDataExposureThroughErrorMessage.qlref +++ b/java/ql/test/query-tests/security/CWE-209/semmle/tests/SensitiveDataExposureThroughErrorMessage.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-209/SensitiveDataExposureThroughErrorMessage.ql +query: Security/CWE/CWE-209/SensitiveDataExposureThroughErrorMessage.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-209/semmle/tests/StackTraceExposure.qlref b/java/ql/test/query-tests/security/CWE-209/semmle/tests/StackTraceExposure.qlref index ea39c4fe8c6..1e5f0d4e2b6 100644 --- a/java/ql/test/query-tests/security/CWE-209/semmle/tests/StackTraceExposure.qlref +++ b/java/ql/test/query-tests/security/CWE-209/semmle/tests/StackTraceExposure.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-209/StackTraceExposure.ql +query: Security/CWE/CWE-209/StackTraceExposure.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-209/semmle/tests/Test.java b/java/ql/test/query-tests/security/CWE-209/semmle/tests/Test.java index 54d64f05ff6..51f48471be8 100644 --- a/java/ql/test/query-tests/security/CWE-209/semmle/tests/Test.java +++ b/java/ql/test/query-tests/security/CWE-209/semmle/tests/Test.java @@ -22,7 +22,7 @@ class Test extends HttpServlet { doSomeWork(); } catch (NullPointerException ex) { // BAD: printing a stack trace back to the response - ex.printStackTrace(response.getWriter()); + ex.printStackTrace(response.getWriter()); // $ Alert[java/stack-trace-exposure] return; } @@ -32,7 +32,7 @@ class Test extends HttpServlet { // BAD: printing a stack trace back to the response response.sendError( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, - printTrace(ex)); + printTrace(ex)); // $ Alert[java/stack-trace-exposure] return; } @@ -42,7 +42,7 @@ class Test extends HttpServlet { // BAD: printing a stack trace back to the response response.sendError( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, - printTrace2(ex)); + printTrace2(ex)); // $ Alert[java/stack-trace-exposure] return; } @@ -52,7 +52,7 @@ class Test extends HttpServlet { // BAD: printing an exception message back to the response response.sendError( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, - ex.getMessage()); + ex.getMessage()); // $ Alert[java/error-message-exposure] } } diff --git a/java/ql/test/query-tests/security/CWE-297/UnsafeHostnameVerification.java b/java/ql/test/query-tests/security/CWE-297/UnsafeHostnameVerification.java index 09fdf89e0f0..77ab00cc432 100644 --- a/java/ql/test/query-tests/security/CWE-297/UnsafeHostnameVerification.java +++ b/java/ql/test/query-tests/security/CWE-297/UnsafeHostnameVerification.java @@ -11,19 +11,19 @@ public class UnsafeHostnameVerification { * Test the implementation of trusting all hostnames as an anonymous class */ public void testTrustAllHostnameOfAnonymousClass() { - HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { + HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { // $ @Override public boolean verify(String hostname, SSLSession session) { return true; // BAD, always returns true } - }); + }); // $ Alert[java/unsafe-hostname-verification] } /** * Test the implementation of trusting all hostnames as a lambda. */ public void testTrustAllHostnameLambda() { - HttpsURLConnection.setDefaultHostnameVerifier((name, s) -> true); // BAD, always returns true + HttpsURLConnection.setDefaultHostnameVerifier((name, s) -> true); // $ Alert[java/unsafe-hostname-verification] // BAD, always returns true } /** @@ -44,7 +44,7 @@ public class UnsafeHostnameVerification { } private void functionThatActuallyDisablesVerification() { - HttpsURLConnection.setDefaultHostnameVerifier((name, s) -> true); // GOOD [but detected as BAD], because we only + HttpsURLConnection.setDefaultHostnameVerifier((name, s) -> true); // $ Alert[java/unsafe-hostname-verification] // GOOD [but detected as BAD], because we only // check guards inside a function // and not across function calls. This is considerer GOOD because the call to // `functionThatActuallyDisablesVerification` is guarded by a feature flag in @@ -63,7 +63,7 @@ public class UnsafeHostnameVerification { } public void testTrustAllHostnameWithExceptions() { - HostnameVerifier verifier = new HostnameVerifier() { + HostnameVerifier verifier = new HostnameVerifier() { // $ @Override public boolean verify(String hostname, SSLSession session) { try { verify(hostname, session.getPeerCertificates()); } catch (Exception e) { throw new RuntimeException(); } @@ -77,21 +77,21 @@ public class UnsafeHostnameVerification { // `Exception` in the case of a mismatch. private void verify(String hostname, Certificate[] certs) { } - }; - HttpsURLConnection.setDefaultHostnameVerifier(verifier); + }; // $ Source[java/unsafe-hostname-verification] + HttpsURLConnection.setDefaultHostnameVerifier(verifier); // $ Alert[java/unsafe-hostname-verification] } /** * Test the implementation of trusting all hostnames as a variable */ public void testTrustAllHostnameOfVariable() { - HostnameVerifier verifier = new HostnameVerifier() { + HostnameVerifier verifier = new HostnameVerifier() { // $ @Override public boolean verify(String hostname, SSLSession session) { return true; // BAD, always returns true } - }; - HttpsURLConnection.setDefaultHostnameVerifier(verifier); + }; // $ Source[java/unsafe-hostname-verification] + HttpsURLConnection.setDefaultHostnameVerifier(verifier); // $ Alert[java/unsafe-hostname-verification] } public static final HostnameVerifier ALLOW_ALL_HOSTNAME_VERIFIER = new HostnameVerifier() { @@ -113,7 +113,7 @@ public class UnsafeHostnameVerification { * This is for testing the diff-informed functionality of the query. */ public void testTrustAllHostnameOfNamedClass() { - HttpsURLConnection.setDefaultHostnameVerifier(new AlwaysTrueVerifier()); + HttpsURLConnection.setDefaultHostnameVerifier(new AlwaysTrueVerifier()); // $ Alert[java/unsafe-hostname-verification] } } diff --git a/java/ql/test/query-tests/security/CWE-297/UnsafeHostnameVerification.qlref b/java/ql/test/query-tests/security/CWE-297/UnsafeHostnameVerification.qlref index 5c82af8f3f7..fc028d3814e 100644 --- a/java/ql/test/query-tests/security/CWE-297/UnsafeHostnameVerification.qlref +++ b/java/ql/test/query-tests/security/CWE-297/UnsafeHostnameVerification.qlref @@ -1,2 +1,4 @@ query: Security/CWE/CWE-297/UnsafeHostnameVerification.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-311/CWE-319/HttpsUrls.qlref b/java/ql/test/query-tests/security/CWE-311/CWE-319/HttpsUrls.qlref index ee69b6e12ca..e7d9ba08897 100644 --- a/java/ql/test/query-tests/security/CWE-311/CWE-319/HttpsUrls.qlref +++ b/java/ql/test/query-tests/security/CWE-311/CWE-319/HttpsUrls.qlref @@ -1,2 +1,4 @@ query: Security/CWE/CWE-319/HttpsUrls.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-311/CWE-319/HttpsUrlsTest.java b/java/ql/test/query-tests/security/CWE-311/CWE-319/HttpsUrlsTest.java index 900718904d2..362361a7171 100644 --- a/java/ql/test/query-tests/security/CWE-311/CWE-319/HttpsUrlsTest.java +++ b/java/ql/test/query-tests/security/CWE-311/CWE-319/HttpsUrlsTest.java @@ -20,12 +20,12 @@ class HelloImpl implements Hello { try { // HttpsUrls { - String protocol = "http://"; + String protocol = "http://"; // $ Source[java/non-https-url] URL u = new URL(protocol + "www.secret.example.org/"); // using HttpsURLConnections to enforce SSL is desirable // BAD: this will give a ClassCastException at runtime, as the // http URL cannot be used to make an HttpsURLConnection - HttpsURLConnection hu = (HttpsURLConnection) u.openConnection(); + HttpsURLConnection hu = (HttpsURLConnection) u.openConnection(); // $ Alert[java/non-https-url] hu.setRequestMethod("PUT"); hu.connect(); OutputStream os = hu.getOutputStream(); @@ -33,12 +33,12 @@ class HelloImpl implements Hello { } { - String protocol = "http"; + String protocol = "http"; // $ Source[java/non-https-url] URL u = new URL(protocol, "www.secret.example.org", "foo"); // using HttpsURLConnections to enforce SSL is desirable // BAD: this will give a ClassCastException at runtime, as the // http URL cannot be used to make an HttpsURLConnection - HttpsURLConnection hu = (HttpsURLConnection) u.openConnection(); + HttpsURLConnection hu = (HttpsURLConnection) u.openConnection(); // $ Alert[java/non-https-url] hu.setRequestMethod("PUT"); hu.connect(); OutputStream os = hu.getOutputStream(); @@ -46,13 +46,13 @@ class HelloImpl implements Hello { } { - String protocol = "http://"; + String protocol = "http://"; // $ Source[java/non-https-url] // the second URL overwrites the first, as it has a protocol URL u = new URL(new URL("https://www.secret.example.org"), protocol + "www.secret.example.org"); // using HttpsURLConnections to enforce SSL is desirable // BAD: this will give a ClassCastException at runtime, as the // http URL cannot be used to make an HttpsURLConnection - HttpsURLConnection hu = (HttpsURLConnection) u.openConnection(); + HttpsURLConnection hu = (HttpsURLConnection) u.openConnection(); // $ Alert[java/non-https-url] hu.setRequestMethod("PUT"); hu.connect(); OutputStream os = hu.getOutputStream(); @@ -84,12 +84,12 @@ class HelloImpl implements Hello { } { - String protocol = "http"; + String protocol = "http"; // $ Source[java/non-https-url] URL u = new URL(protocol, "internal-url", "foo"); // FALSE POSITIVE: the query has no way of knowing whether the url will // resolve to somewhere outside the internal network, where there // are unlikely to be interception attempts - HttpsURLConnection hu = (HttpsURLConnection) u.openConnection(); + HttpsURLConnection hu = (HttpsURLConnection) u.openConnection(); // $ Alert[java/non-https-url] hu.setRequestMethod("PUT"); hu.connect(); OutputStream os = hu.getOutputStream(); @@ -116,4 +116,4 @@ class HelloImpl implements Hello { public String sayHello() { return "Hello"; } -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/security/CWE-311/CWE-319/UseSSL.qlref b/java/ql/test/query-tests/security/CWE-311/CWE-319/UseSSL.qlref index cd19c71e3ad..b1aaff7c300 100644 --- a/java/ql/test/query-tests/security/CWE-311/CWE-319/UseSSL.qlref +++ b/java/ql/test/query-tests/security/CWE-311/CWE-319/UseSSL.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-319/UseSSL.ql \ No newline at end of file +query: Security/CWE/CWE-319/UseSSL.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-311/CWE-319/UseSSLTest.java b/java/ql/test/query-tests/security/CWE-311/CWE-319/UseSSLTest.java index b6ff8b57fbf..19e4951f249 100644 --- a/java/ql/test/query-tests/security/CWE-311/CWE-319/UseSSLTest.java +++ b/java/ql/test/query-tests/security/CWE-311/CWE-319/UseSSLTest.java @@ -8,7 +8,7 @@ class UseSSLTest { if (connection instanceof HttpsURLConnection) { input = connection.getInputStream(); // OK } else { - input = connection.getInputStream(); // BAD + input = connection.getInputStream(); // $ Alert[java/non-ssl-connection] // BAD } } } diff --git a/java/ql/test/query-tests/security/CWE-311/CWE-614/semmle/tests/InsecureCookie.qlref b/java/ql/test/query-tests/security/CWE-311/CWE-614/semmle/tests/InsecureCookie.qlref index 38042f8864c..f286f8858ee 100644 --- a/java/ql/test/query-tests/security/CWE-311/CWE-614/semmle/tests/InsecureCookie.qlref +++ b/java/ql/test/query-tests/security/CWE-311/CWE-614/semmle/tests/InsecureCookie.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-614/InsecureCookie.ql \ No newline at end of file +query: Security/CWE/CWE-614/InsecureCookie.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-311/CWE-614/semmle/tests/Test.java b/java/ql/test/query-tests/security/CWE-311/CWE-614/semmle/tests/Test.java index c198f522e30..83c0038b7a0 100644 --- a/java/ql/test/query-tests/security/CWE-311/CWE-614/semmle/tests/Test.java +++ b/java/ql/test/query-tests/security/CWE-311/CWE-614/semmle/tests/Test.java @@ -16,7 +16,7 @@ class Test { Cookie cookie = new Cookie("secret" ,"fakesecret"); // BAD: secure flag not set - response.addCookie(cookie); + response.addCookie(cookie); // $ Alert } @@ -25,7 +25,7 @@ class Test { // BAD: secure flag set to false cookie.setSecure(false); - response.addCookie(cookie); + response.addCookie(cookie); // $ Alert } @@ -34,7 +34,7 @@ class Test { // BAD: secure flag set to something not clearly true or request.isSecure() cookie.setSecure(otherInput); - response.addCookie(cookie); + response.addCookie(cookie); // $ Alert } @@ -48,7 +48,7 @@ class Test { else secureVal = otherInput; cookie.setSecure(secureVal); - response.addCookie(cookie); + response.addCookie(cookie); // $ Alert } diff --git a/java/ql/test/query-tests/security/CWE-312/android/backup/AllowBackupEnabledTest.qlref b/java/ql/test/query-tests/security/CWE-312/android/backup/AllowBackupEnabledTest.qlref index 2b7a5375dab..b08b50829f8 100644 --- a/java/ql/test/query-tests/security/CWE-312/android/backup/AllowBackupEnabledTest.qlref +++ b/java/ql/test/query-tests/security/CWE-312/android/backup/AllowBackupEnabledTest.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-312/AllowBackupAttributeEnabled.ql \ No newline at end of file +query: Security/CWE/CWE-312/AllowBackupAttributeEnabled.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-312/android/backup/TestExplicitlyEnabled/AndroidManifest.xml b/java/ql/test/query-tests/security/CWE-312/android/backup/TestExplicitlyEnabled/AndroidManifest.xml index 4b69c52ccae..8e33b872caa 100644 --- a/java/ql/test/query-tests/security/CWE-312/android/backup/TestExplicitlyEnabled/AndroidManifest.xml +++ b/java/ql/test/query-tests/security/CWE-312/android/backup/TestExplicitlyEnabled/AndroidManifest.xml @@ -24,6 +24,6 @@ - + diff --git a/java/ql/test/query-tests/security/CWE-312/android/backup/TestMissing/AndroidManifest.xml b/java/ql/test/query-tests/security/CWE-312/android/backup/TestMissing/AndroidManifest.xml index 9db4c7429fe..3a61d35c95d 100644 --- a/java/ql/test/query-tests/security/CWE-312/android/backup/TestMissing/AndroidManifest.xml +++ b/java/ql/test/query-tests/security/CWE-312/android/backup/TestMissing/AndroidManifest.xml @@ -24,6 +24,6 @@ - + diff --git a/java/ql/test/query-tests/security/CWE-327/semmle/tests/BrokenCryptoAlgorithm.qlref b/java/ql/test/query-tests/security/CWE-327/semmle/tests/BrokenCryptoAlgorithm.qlref index 32cbef3d0fb..4a8ddcd9e7c 100644 --- a/java/ql/test/query-tests/security/CWE-327/semmle/tests/BrokenCryptoAlgorithm.qlref +++ b/java/ql/test/query-tests/security/CWE-327/semmle/tests/BrokenCryptoAlgorithm.qlref @@ -1,2 +1,4 @@ query: Security/CWE/CWE-327/BrokenCryptoAlgorithm.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-327/semmle/tests/MaybeBrokenCryptoAlgorithm.qlref b/java/ql/test/query-tests/security/CWE-327/semmle/tests/MaybeBrokenCryptoAlgorithm.qlref index 42fa4845cac..4c32da91dea 100644 --- a/java/ql/test/query-tests/security/CWE-327/semmle/tests/MaybeBrokenCryptoAlgorithm.qlref +++ b/java/ql/test/query-tests/security/CWE-327/semmle/tests/MaybeBrokenCryptoAlgorithm.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-327/MaybeBrokenCryptoAlgorithm.ql \ No newline at end of file +query: Security/CWE/CWE-327/MaybeBrokenCryptoAlgorithm.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-327/semmle/tests/Test.java b/java/ql/test/query-tests/security/CWE-327/semmle/tests/Test.java index 23aff65161c..1136594a5a5 100644 --- a/java/ql/test/query-tests/security/CWE-327/semmle/tests/Test.java +++ b/java/ql/test/query-tests/security/CWE-327/semmle/tests/Test.java @@ -16,7 +16,7 @@ class Test { { // BAD: DES is a weak algorithm - keyGenerator = KeyGenerator.getInstance("DES"); + keyGenerator = KeyGenerator.getInstance("DES"); // $ Alert[java/weak-cryptographic-algorithm] } // GOOD: RSA is a strong algorithm @@ -31,7 +31,7 @@ class Test { { // BAD: foo is an unknown algorithm that may not be secure - secretKeySpec = new SecretKeySpec(byteKey, "foo"); + secretKeySpec = new SecretKeySpec(byteKey, "foo"); // $ Alert[java/potentially-weak-cryptographic-algorithm] } // GOOD: GCM is a strong algorithm @@ -39,7 +39,7 @@ class Test { { // BAD: RC2 is a weak algorithm - cipher = Cipher.getInstance("RC2"); + cipher = Cipher.getInstance("RC2"); // $ Alert[java/weak-cryptographic-algorithm] } // GOOD: ECIES is a strong algorithm cipher = Cipher.getInstance("ECIES"); diff --git a/java/ql/test/query-tests/security/CWE-327/semmle/tests/WeakHashing.java b/java/ql/test/query-tests/security/CWE-327/semmle/tests/WeakHashing.java index c79c025a41c..5ce2e316280 100644 --- a/java/ql/test/query-tests/security/CWE-327/semmle/tests/WeakHashing.java +++ b/java/ql/test/query-tests/security/CWE-327/semmle/tests/WeakHashing.java @@ -12,13 +12,13 @@ public class WeakHashing { props.load(new FileInputStream("example.properties")); // BAD: Using a weak hashing algorithm - MessageDigest bad = MessageDigest.getInstance(props.getProperty("hashAlg1")); + MessageDigest bad = MessageDigest.getInstance(props.getProperty("hashAlg1")); // $ Alert[java/potentially-weak-cryptographic-algorithm] // BAD: Using a weak hashing algorithm even with a secure default - MessageDigest bad2 = MessageDigest.getInstance(props.getProperty("hashAlg1", "SHA-256")); + MessageDigest bad2 = MessageDigest.getInstance(props.getProperty("hashAlg1", "SHA-256")); // $ Alert[java/potentially-weak-cryptographic-algorithm] // BAD: Using a strong hashing algorithm but with a weak default - MessageDigest bad3 = MessageDigest.getInstance(props.getProperty("hashAlg2", "MD5")); + MessageDigest bad3 = MessageDigest.getInstance(props.getProperty("hashAlg2", "MD5")); // $ Alert[java/potentially-weak-cryptographic-algorithm] // GOOD: Using a strong hashing algorithm MessageDigest ok = MessageDigest.getInstance(props.getProperty("hashAlg2")); diff --git a/java/ql/test/query-tests/security/CWE-335/semmle/tests/PredictableSeed.qlref b/java/ql/test/query-tests/security/CWE-335/semmle/tests/PredictableSeed.qlref index 090a64a67ce..053e69913e0 100644 --- a/java/ql/test/query-tests/security/CWE-335/semmle/tests/PredictableSeed.qlref +++ b/java/ql/test/query-tests/security/CWE-335/semmle/tests/PredictableSeed.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-335/PredictableSeed.ql \ No newline at end of file +query: Security/CWE/CWE-335/PredictableSeed.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-335/semmle/tests/Test.java b/java/ql/test/query-tests/security/CWE-335/semmle/tests/Test.java index 3c38f57d562..db7e8eabfa4 100644 --- a/java/ql/test/query-tests/security/CWE-335/semmle/tests/Test.java +++ b/java/ql/test/query-tests/security/CWE-335/semmle/tests/Test.java @@ -25,16 +25,16 @@ class Test { SecureRandom r_time1 = new SecureRandom(new BigInteger(Long.toString(time1)).toByteArray()); // BAD: SecureRandom initialized with times. SecureRandom r_time2 = new SecureRandom(new BigInteger(Long.toString(time2)).toByteArray()); - r_time1.nextInt(); r_time2.nextInt(); + r_time1.nextInt(); r_time2.nextInt(); // $ Alert // BAD: SecureRandom initialized with constant value. SecureRandom r_const = new SecureRandom(new BigInteger(Long.toString(12345L)).toByteArray()); - r_const.nextInt(); + r_const.nextInt(); // $ Alert // BAD: SecureRandom's seed set to constant with setSeed. SecureRandom r_const_set = new SecureRandom(); r_const_set.setSeed(12345L); - r_const_set.nextInt(); + r_const_set.nextInt(); // $ Alert // GOOD: SecureRandom self seeded and then seed is supplemented. SecureRandom r_selfseed = new SecureRandom(); diff --git a/java/ql/test/query-tests/security/CWE-338/semmle/tests/JHipsterGeneratedPRNG.qlref b/java/ql/test/query-tests/security/CWE-338/semmle/tests/JHipsterGeneratedPRNG.qlref index 441bcf25929..b908d757218 100644 --- a/java/ql/test/query-tests/security/CWE-338/semmle/tests/JHipsterGeneratedPRNG.qlref +++ b/java/ql/test/query-tests/security/CWE-338/semmle/tests/JHipsterGeneratedPRNG.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-338/JHipsterGeneratedPRNG.ql +query: Security/CWE/CWE-338/JHipsterGeneratedPRNG.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-338/semmle/tests/vulnerable/RandomUtil.java b/java/ql/test/query-tests/security/CWE-338/semmle/tests/vulnerable/RandomUtil.java index 22e0c0b9150..e6707a41649 100644 --- a/java/ql/test/query-tests/security/CWE-338/semmle/tests/vulnerable/RandomUtil.java +++ b/java/ql/test/query-tests/security/CWE-338/semmle/tests/vulnerable/RandomUtil.java @@ -17,7 +17,7 @@ public final class RandomUtil { * * @return the generated password. */ - public static String generatePassword() { + public static String generatePassword() { // $ Alert return RandomStringUtils.randomAlphanumeric(DEF_COUNT); } @@ -26,7 +26,7 @@ public final class RandomUtil { * * @return the generated activation key. */ - public static String generateActivationKey() { + public static String generateActivationKey() { // $ Alert return RandomStringUtils.randomNumeric(DEF_COUNT); } @@ -35,7 +35,7 @@ public final class RandomUtil { * * @return the generated reset key. */ - public static String generateResetKey() { + public static String generateResetKey() { // $ Alert return RandomStringUtils.randomNumeric(DEF_COUNT); } @@ -45,7 +45,7 @@ public final class RandomUtil { * * @return the generated series data. */ - public static String generateSeriesData() { + public static String generateSeriesData() { // $ Alert return RandomStringUtils.randomAlphanumeric(DEF_COUNT); } @@ -54,7 +54,7 @@ public final class RandomUtil { * * @return the generated token data. */ - public static String generateTokenData() { + public static String generateTokenData() { // $ Alert return RandomStringUtils.randomAlphanumeric(DEF_COUNT); } } diff --git a/java/ql/test/query-tests/security/CWE-421/semmle/SocketAuthRace.qlref b/java/ql/test/query-tests/security/CWE-421/semmle/SocketAuthRace.qlref index 6ee9791ad63..efdf86cc251 100644 --- a/java/ql/test/query-tests/security/CWE-421/semmle/SocketAuthRace.qlref +++ b/java/ql/test/query-tests/security/CWE-421/semmle/SocketAuthRace.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-421/SocketAuthRace.ql \ No newline at end of file +query: Security/CWE/CWE-421/SocketAuthRace.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-421/semmle/Test.java b/java/ql/test/query-tests/security/CWE-421/semmle/Test.java index 0e2dc665a4b..d2850f39899 100644 --- a/java/ql/test/query-tests/security/CWE-421/semmle/Test.java +++ b/java/ql/test/query-tests/security/CWE-421/semmle/Test.java @@ -35,7 +35,7 @@ class Test { ServerSocket listenSocket = new ServerSocket(desiredPort); if (isAuthenticated(username)) { - Socket connection1 = listenSocket.accept(); + Socket connection1 = listenSocket.accept(); // $ Alert // BAD: no authentication over the socket connection1.getOutputStream().write(secretData); } @@ -48,7 +48,7 @@ class Test { if (isAuthenticated(username)) { // FP: we authenticate both beforehand and over the socket - Socket connection3 = listenSocket.accept(); + Socket connection3 = listenSocket.accept(); // $ Alert if (doAuthenticate(connection3, username)) { connection3.getOutputStream().write(secretData); } @@ -62,7 +62,7 @@ class Test { listenChannel.bind(port); if (isAuthenticated(username)) { - SocketChannel connection1 = listenChannel.accept(); + SocketChannel connection1 = listenChannel.accept(); // $ Alert // BAD: no authentication over the socket connection1.write(ByteBuffer.wrap(secretData)); } diff --git a/java/ql/test/query-tests/security/CWE-601/semmle/tests/UrlRedirect.java b/java/ql/test/query-tests/security/CWE-601/semmle/tests/UrlRedirect.java index 01cee2d59f2..90a08ada8a2 100644 --- a/java/ql/test/query-tests/security/CWE-601/semmle/tests/UrlRedirect.java +++ b/java/ql/test/query-tests/security/CWE-601/semmle/tests/UrlRedirect.java @@ -20,7 +20,7 @@ public class UrlRedirect extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // BAD: a request parameter is incorporated without validation into a URL redirect - response.sendRedirect(request.getParameter("target")); + response.sendRedirect(request.getParameter("target")); // $ Alert // GOOD: the request parameter is validated against a known fixed string if (VALID_REDIRECT.equals(request.getParameter("target"))) { @@ -29,17 +29,17 @@ public class UrlRedirect extends HttpServlet { // BAD: the user attempts to clean the string, but this will fail // if the argument is "hthttp://tp://malicious.com" - response.sendRedirect(weakCleanup(request.getParameter("target"))); + response.sendRedirect(weakCleanup(request.getParameter("target"))); // $ Alert // GOOD: the user input is not used in a position that allows it to dictate // the target of the redirect response.sendRedirect("http://example.com?username=" + request.getParameter("username")); // BAD: set the "Location" header - response.setHeader("Location", request.getParameter("target")); + response.setHeader("Location", request.getParameter("target")); // $ Alert // BAD: set the "Location" header - response.addHeader(LOCATION_HEADER_KEY, request.getParameter("target")); + response.addHeader(LOCATION_HEADER_KEY, request.getParameter("target")); // $ Alert } public String weakCleanup(String input) { diff --git a/java/ql/test/query-tests/security/CWE-601/semmle/tests/UrlRedirect.qlref b/java/ql/test/query-tests/security/CWE-601/semmle/tests/UrlRedirect.qlref index 933c3569eed..f41f720f725 100644 --- a/java/ql/test/query-tests/security/CWE-601/semmle/tests/UrlRedirect.qlref +++ b/java/ql/test/query-tests/security/CWE-601/semmle/tests/UrlRedirect.qlref @@ -1,2 +1,4 @@ query: Security/CWE/CWE-601/UrlRedirect.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-601/semmle/tests/UrlRedirect2.java b/java/ql/test/query-tests/security/CWE-601/semmle/tests/UrlRedirect2.java index 9014dcae7f2..b7e8d673e3c 100644 --- a/java/ql/test/query-tests/security/CWE-601/semmle/tests/UrlRedirect2.java +++ b/java/ql/test/query-tests/security/CWE-601/semmle/tests/UrlRedirect2.java @@ -24,7 +24,7 @@ public class UrlRedirect2 extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // BAD: a request parameter is incorporated without validation into a URL redirect - response.sendRedirect(request.getParameter("target")); + response.sendRedirect(request.getParameter("target")); // $ Alert // GOOD: the request parameter is validated against a known list of strings String target = request.getParameter("target"); diff --git a/java/ql/test/query-tests/security/CWE-601/semmle/tests/mad/Test.java b/java/ql/test/query-tests/security/CWE-601/semmle/tests/mad/Test.java index e222c3d9fbe..baf278ab3ae 100644 --- a/java/ql/test/query-tests/security/CWE-601/semmle/tests/mad/Test.java +++ b/java/ql/test/query-tests/security/CWE-601/semmle/tests/mad/Test.java @@ -6,11 +6,11 @@ public class Test { private static HttpServletRequest request; public static Object source() { - return request.getParameter(null); + return request.getParameter(null); // $ Source } public void test(HttpResponses r) { // "org.kohsuke.stapler;HttpResponses;true;redirectTo;(String);;Argument[0];open-url;ai-generated" - r.redirectTo((String) source()); + r.redirectTo((String) source()); // $ Alert } } diff --git a/java/ql/test/query-tests/security/CWE-676/semmle/tests/PotentiallyDangerousFunction.qlref b/java/ql/test/query-tests/security/CWE-676/semmle/tests/PotentiallyDangerousFunction.qlref index 45388d46e2e..8fb8f0fceaf 100644 --- a/java/ql/test/query-tests/security/CWE-676/semmle/tests/PotentiallyDangerousFunction.qlref +++ b/java/ql/test/query-tests/security/CWE-676/semmle/tests/PotentiallyDangerousFunction.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-676/PotentiallyDangerousFunction.ql +query: Security/CWE/CWE-676/PotentiallyDangerousFunction.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-676/semmle/tests/Test.java b/java/ql/test/query-tests/security/CWE-676/semmle/tests/Test.java index 6d9367d2063..8e76feb1330 100644 --- a/java/ql/test/query-tests/security/CWE-676/semmle/tests/Test.java +++ b/java/ql/test/query-tests/security/CWE-676/semmle/tests/Test.java @@ -11,6 +11,6 @@ class Test { public void quit() { // Stop - worker.stop(); // BAD: Thread.stop can result in corrupted data + worker.stop(); // $ Alert // BAD: Thread.stop can result in corrupted data } } diff --git a/java/ql/test/query-tests/security/CWE-681/semmle/tests/NumericCastTainted.qlref b/java/ql/test/query-tests/security/CWE-681/semmle/tests/NumericCastTainted.qlref index f06664e19d4..fbe1ae7ab46 100644 --- a/java/ql/test/query-tests/security/CWE-681/semmle/tests/NumericCastTainted.qlref +++ b/java/ql/test/query-tests/security/CWE-681/semmle/tests/NumericCastTainted.qlref @@ -1,2 +1,4 @@ query: Security/CWE/CWE-681/NumericCastTainted.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-681/semmle/tests/Test.java b/java/ql/test/query-tests/security/CWE-681/semmle/tests/Test.java index f50652c032f..75862e683e0 100644 --- a/java/ql/test/query-tests/security/CWE-681/semmle/tests/Test.java +++ b/java/ql/test/query-tests/security/CWE-681/semmle/tests/Test.java @@ -8,7 +8,7 @@ class Test { long data; BufferedReader readerBuffered = new BufferedReader( - new InputStreamReader(System.in, "UTF-8")); + new InputStreamReader(System.in, "UTF-8")); // $ Source String stringNumber = readerBuffered.readLine(); if (stringNumber != null) { data = Long.parseLong(stringNumber.trim()); @@ -18,7 +18,7 @@ class Test { // AVOID: potential truncation if input data is very large, for example // 'Long.MAX_VALUE' - int scaled = (int)data; + int scaled = (int)data; // $ Alert //... @@ -30,4 +30,4 @@ class Test { throw new IllegalArgumentException("Invalid input"); } } -} \ No newline at end of file +} diff --git a/java/ql/test/query-tests/security/CWE-732/semmle/tests/ReadingFromWorldWritableFile.qlref b/java/ql/test/query-tests/security/CWE-732/semmle/tests/ReadingFromWorldWritableFile.qlref index cd90cfe2c17..d5c7df733ef 100644 --- a/java/ql/test/query-tests/security/CWE-732/semmle/tests/ReadingFromWorldWritableFile.qlref +++ b/java/ql/test/query-tests/security/CWE-732/semmle/tests/ReadingFromWorldWritableFile.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-732/ReadingFromWorldWritableFile.ql +query: Security/CWE/CWE-732/ReadingFromWorldWritableFile.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-732/semmle/tests/Test.java b/java/ql/test/query-tests/security/CWE-732/semmle/tests/Test.java index 8717203802d..ceca3b1a384 100644 --- a/java/ql/test/query-tests/security/CWE-732/semmle/tests/Test.java +++ b/java/ql/test/query-tests/security/CWE-732/semmle/tests/Test.java @@ -14,20 +14,20 @@ class Test { public static void main(String[] args) throws IOException { // Using the File API File f = new File("file"); - setWorldWritable(f); + setWorldWritable(f); // $ Alert readFile(f); // Using the Path API Path p = Paths.get("file"); Set filePermissions = EnumSet.of(PosixFilePermission.OTHERS_WRITE); - Files.setPosixFilePermissions(p, filePermissions); + Files.setPosixFilePermissions(p, filePermissions); // $ Alert Files.readAllLines(p); // Convert file to path File f2 = new File("file2"); Set file2Permissions = new LinkedHashSet<>(); file2Permissions.add(PosixFilePermission.OTHERS_WRITE); - Files.setPosixFilePermissions(Paths.get(f2.getCanonicalPath()), file2Permissions); + Files.setPosixFilePermissions(Paths.get(f2.getCanonicalPath()), file2Permissions); // $ Alert new FileInputStream(f2); } diff --git a/java/ql/test/query-tests/security/CWE-807/semmle/tests/TaintedPermissionsCheck.qlref b/java/ql/test/query-tests/security/CWE-807/semmle/tests/TaintedPermissionsCheck.qlref index 8c69ea7e994..cf5503cf706 100644 --- a/java/ql/test/query-tests/security/CWE-807/semmle/tests/TaintedPermissionsCheck.qlref +++ b/java/ql/test/query-tests/security/CWE-807/semmle/tests/TaintedPermissionsCheck.qlref @@ -1,2 +1,4 @@ query: Security/CWE/CWE-807/TaintedPermissionsCheck.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-807/semmle/tests/TaintedPermissionsCheckTest.java b/java/ql/test/query-tests/security/CWE-807/semmle/tests/TaintedPermissionsCheckTest.java index 622538b7e35..4a274c25b91 100644 --- a/java/ql/test/query-tests/security/CWE-807/semmle/tests/TaintedPermissionsCheckTest.java +++ b/java/ql/test/query-tests/security/CWE-807/semmle/tests/TaintedPermissionsCheckTest.java @@ -9,10 +9,10 @@ import org.apache.shiro.subject.Subject; class TaintedPermissionsCheckTest { public static void main(HttpServletRequest request) throws Exception { // Apache Shiro permissions system - String action = request.getParameter("action"); + String action = request.getParameter("action"); // $ Source[java/tainted-permissions-check] Subject subject = SecurityUtils.getSubject(); // BAD: permissions decision made using tainted data - if (subject.isPermitted("domain:sublevel:" + action)) + if (subject.isPermitted("domain:sublevel:" + action)) // $ Alert[java/tainted-permissions-check] doIt(); // GOOD: use fixed checks diff --git a/java/ql/test/query-tests/security/CWE-829/semmle/tests/InsecureDependencyResolution.qlref b/java/ql/test/query-tests/security/CWE-829/semmle/tests/InsecureDependencyResolution.qlref index 84f2c1b82cd..2e4d7f2519a 100644 --- a/java/ql/test/query-tests/security/CWE-829/semmle/tests/InsecureDependencyResolution.qlref +++ b/java/ql/test/query-tests/security/CWE-829/semmle/tests/InsecureDependencyResolution.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-829/InsecureDependencyResolution.ql +query: Security/CWE/CWE-829/InsecureDependencyResolution.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-829/semmle/tests/insecure-pom.xml b/java/ql/test/query-tests/security/CWE-829/semmle/tests/insecure-pom.xml index 7f7585d9429..9234bd68251 100644 --- a/java/ql/test/query-tests/security/CWE-829/semmle/tests/insecure-pom.xml +++ b/java/ql/test/query-tests/security/CWE-829/semmle/tests/insecure-pom.xml @@ -21,19 +21,19 @@ Insecure Repository Releases http://insecure-repository.example - + insecure-snapshots Insecure Repository Snapshots http://insecure-repository.example - + insecure-snapshots Insecure Repository Snapshots http://localhost.example - + @@ -41,7 +41,7 @@ Insecure Repository http://insecure-repository.example - + @@ -49,6 +49,6 @@ Insecure Repository Releases http://insecure-repository.example - + diff --git a/java/ql/test/query-tests/security/CWE-833/semmle/tests/LockOrderInconsistency.qlref b/java/ql/test/query-tests/security/CWE-833/semmle/tests/LockOrderInconsistency.qlref index 74ebeec5d12..3bd8029485d 100644 --- a/java/ql/test/query-tests/security/CWE-833/semmle/tests/LockOrderInconsistency.qlref +++ b/java/ql/test/query-tests/security/CWE-833/semmle/tests/LockOrderInconsistency.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-833/LockOrderInconsistency.ql +query: Security/CWE/CWE-833/LockOrderInconsistency.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/query-tests/security/CWE-833/semmle/tests/MethodAccessLockOrder.java b/java/ql/test/query-tests/security/CWE-833/semmle/tests/MethodAccessLockOrder.java index e02364c05ec..684fc55f946 100644 --- a/java/ql/test/query-tests/security/CWE-833/semmle/tests/MethodAccessLockOrder.java +++ b/java/ql/test/query-tests/security/CWE-833/semmle/tests/MethodAccessLockOrder.java @@ -26,7 +26,7 @@ class MethodAccessLockOrder { public boolean initiateTransfer(boolean fromSavings, int amount) { // AVOID: inconsistent lock order if (fromSavings) { - return primary.transferFrom(savings, amount); + return primary.transferFrom(savings, amount); // $ Alert } else { return savings.transferFrom(primary, amount); } diff --git a/java/ql/test/query-tests/security/CWE-833/semmle/tests/ReentrantLockOrder.java b/java/ql/test/query-tests/security/CWE-833/semmle/tests/ReentrantLockOrder.java index 83d395ccad5..65903ec0034 100644 --- a/java/ql/test/query-tests/security/CWE-833/semmle/tests/ReentrantLockOrder.java +++ b/java/ql/test/query-tests/security/CWE-833/semmle/tests/ReentrantLockOrder.java @@ -8,7 +8,7 @@ class ReentrantLockOrder { public boolean transferToSavings(int amount) { try { - primaryLock.lock(); + primaryLock.lock(); // $ Alert savingsLock.lock(); if (amount>0 && primaryAccountBalance>=amount) { primaryAccountBalance -= amount; @@ -25,7 +25,7 @@ class ReentrantLockOrder { // AVOID: lock order is different from "transferToSavings" // and may result in deadlock try { - savingsLock.lock(); + savingsLock.lock(); // $ Alert primaryLock.lock(); if (amount>0 && primaryAccountBalance>=amount) { primaryAccountBalance -= amount; diff --git a/java/ql/test/query-tests/security/CWE-833/semmle/tests/SynchronizedStmtLockOrder.java b/java/ql/test/query-tests/security/CWE-833/semmle/tests/SynchronizedStmtLockOrder.java index f4a2e626e86..1da9afd01fe 100644 --- a/java/ql/test/query-tests/security/CWE-833/semmle/tests/SynchronizedStmtLockOrder.java +++ b/java/ql/test/query-tests/security/CWE-833/semmle/tests/SynchronizedStmtLockOrder.java @@ -5,7 +5,7 @@ class SynchronizedStmtLockOrder { private Object savingsLock = new Object(); public boolean transferToSavings(int amount) { - synchronized(primaryLock) { + synchronized(primaryLock) { // $ Alert synchronized(savingsLock) { if (amount>0 && primaryAccountBalance>=amount) { primaryAccountBalance -= amount; @@ -19,7 +19,7 @@ class SynchronizedStmtLockOrder { public boolean transferToPrimary(int amount) { // AVOID: lock order is different from "transferToSavings" // and may result in deadlock - synchronized(savingsLock) { + synchronized(savingsLock) { // $ Alert synchronized(primaryLock) { if (amount>0 && savingsAccountBalance>=amount) { savingsAccountBalance -= amount; diff --git a/java/ql/test/query-tests/security/CWE-835/semmle/tests/InfiniteLoop.java b/java/ql/test/query-tests/security/CWE-835/semmle/tests/InfiniteLoop.java index 69a23502aa3..75c54016267 100644 --- a/java/ql/test/query-tests/security/CWE-835/semmle/tests/InfiniteLoop.java +++ b/java/ql/test/query-tests/security/CWE-835/semmle/tests/InfiniteLoop.java @@ -1,7 +1,7 @@ class Test { public void bad() { for (int i=0; i<10; i++) { - for (int j=0; i<10; j++) { + for (int j=0; i<10; j++) { // $ Alert // potentially infinite loop due to test on wrong variable if (shouldBreak()) break; } diff --git a/java/ql/test/query-tests/security/CWE-835/semmle/tests/InfiniteLoop.qlref b/java/ql/test/query-tests/security/CWE-835/semmle/tests/InfiniteLoop.qlref index caed88100e6..51b2ad7ece7 100644 --- a/java/ql/test/query-tests/security/CWE-835/semmle/tests/InfiniteLoop.qlref +++ b/java/ql/test/query-tests/security/CWE-835/semmle/tests/InfiniteLoop.qlref @@ -1 +1,2 @@ -Security/CWE/CWE-835/InfiniteLoop.ql +query: Security/CWE/CWE-835/InfiniteLoop.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/Consume.java b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/Consume.java index 70f5a0b2bee..6bd0966ff28 100644 --- a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/Consume.java +++ b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/Consume.java @@ -38,7 +38,7 @@ public @interface Consume { /** * The uri to consume from */ - String value() default ""; + String value() default ""; // $ Alert[java/dead-function] /** * The uri to consume from @@ -46,12 +46,12 @@ public @interface Consume { * @deprecated use value instead */ @Deprecated - String uri() default ""; + String uri() default ""; // $ Alert[java/dead-function] /** * Use the field or getter on the bean to provide the uri to consume from */ - String property() default ""; + String property() default ""; // $ Alert[java/dead-function] /** * Optional predicate (using simple language) to only consume if the predicate matches . This can be used to filter @@ -60,5 +60,5 @@ public @interface Consume { * Notice that only the first method that matches the predicate will be used. And if no predicate matches then the * message is dropped. */ - String predicate() default ""; + String predicate() default ""; // $ Alert[java/dead-function] } diff --git a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/builder/ExpressionClause.java b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/builder/ExpressionClause.java index 2dcc3ad5a7a..e90e607e50c 100644 --- a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/builder/ExpressionClause.java +++ b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/builder/ExpressionClause.java @@ -20,6 +20,6 @@ package org.apache.camel.builder; * Represents an expression clause within the DSL which when the expression is complete the clause continues to another * part of the DSL */ -public class ExpressionClause { +public class ExpressionClause { // $ Alert[java/dead-class] public T method(String ref) { return null; } } diff --git a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/builder/RouteBuilder.java b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/builder/RouteBuilder.java index 9c1b8c45d68..0cb300895bc 100644 --- a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/builder/RouteBuilder.java +++ b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/builder/RouteBuilder.java @@ -31,9 +31,9 @@ public abstract class RouteBuilder implements RoutesBuilder { * @param uri the from uri * @return the builder */ - public RouteDefinition from(String uri) { + public RouteDefinition from(String uri) { // $ Alert[java/dead-function] return null; } - public abstract void configure() throws Exception; + public abstract void configure() throws Exception; // $ Alert[java/dead-function] } diff --git a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/impl/DefaultCamelContext.java b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/impl/DefaultCamelContext.java index 2180623054b..22140d4b2f5 100644 --- a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/impl/DefaultCamelContext.java +++ b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/impl/DefaultCamelContext.java @@ -21,7 +21,7 @@ import org.apache.camel.RoutesBuilder; public class DefaultCamelContext implements ModelCamelContext { - public void configure() throws Exception {} + public void configure() throws Exception {} // $ Alert[java/dead-function] public void addRoutes(RoutesBuilder arg0) {} diff --git a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/FilterDefinition.java b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/FilterDefinition.java index 1138c8d3783..d3bed4347b5 100644 --- a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/FilterDefinition.java +++ b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/FilterDefinition.java @@ -16,4 +16,4 @@ */ package org.apache.camel.model; -public class FilterDefinition { } +public class FilterDefinition { } // $ Alert[java/dead-class] diff --git a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/OutputDefinition.java b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/OutputDefinition.java index cfe55f5cc17..5c4045cdc95 100644 --- a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/OutputDefinition.java +++ b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/OutputDefinition.java @@ -19,5 +19,5 @@ package org.apache.camel.model; /** * A useful base class for output types */ -public class OutputDefinition> extends ProcessorDefinition { +public class OutputDefinition> extends ProcessorDefinition { // $ Alert[java/dead-class] } diff --git a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/ProcessorDefinition.java b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/ProcessorDefinition.java index 2423e907b01..37931b91796 100644 --- a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/ProcessorDefinition.java +++ b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/ProcessorDefinition.java @@ -18,7 +18,7 @@ package org.apache.camel.model; import org.apache.camel.builder.ExpressionClause; -public abstract class ProcessorDefinition> { +public abstract class ProcessorDefinition> { // $ Alert[java/dead-class] public Type to(String uri) { return null; } public Type bean(Object bean) { return null; } diff --git a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/RouteDefinition.java b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/RouteDefinition.java index 2ab31d2126a..2052e6a0cdd 100644 --- a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/RouteDefinition.java +++ b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/RouteDefinition.java @@ -16,7 +16,7 @@ */ package org.apache.camel.model; -public class RouteDefinition extends OutputDefinition { +public class RouteDefinition extends OutputDefinition { // $ Alert[java/dead-class] } From 3693185b6b155caa236ed873728e1cf5968275ca Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Wed, 10 Jun 2026 09:14:47 +0200 Subject: [PATCH 06/23] Second pass --- .../DeadCode/camel/DeadClass.qlref | 3 +- .../DeadCode/camel/DeadMethod.qlref | 3 +- .../camel/com/semmle/camel/DeadTarget.java | 4 +- .../camel/javadsl/CustomRouteBuilder.java | 2 +- .../Javadoc/ImpossibleJavadocThrows.java | 4 +- .../Javadoc/ImpossibleJavadocThrows.qlref | 3 +- .../test/query-tests/MissingSpaceTypo/A.java | 14 +- .../SpuriousJavadocParam/Test.java | 34 ++-- .../SpuriousJavadocParam/test.qlref | 3 +- .../CWE-020/ExternalAPISinkExample.java | 2 +- .../CWE-022/semmle/tests/TaintedPath.java | 4 +- .../security/CWE-022/semmle/tests/Test.java | 154 +++++++++--------- .../security/CWE-079/semmle/tests/JaxXSS.java | 74 ++++----- .../security/CWE-079/semmle/tests/JsfXSS.java | 20 +-- .../CWE-079/semmle/tests/SpringXSS.java | 56 +++---- .../security/CWE-079/semmle/tests/XSS.java | 18 +- .../ApkInstallationTest/ApkInstallation.java | 12 +- .../GroovyClassLoaderTest.java | 24 +-- .../GroovyCompilationUnitTest.java | 36 ++-- .../GroovyInjection/GroovyEvalTest.java | 20 +-- .../GroovyInjection/GroovyShellTest.java | 80 ++++----- .../GroovyInjection/TemplateEngineTest.java | 10 +- .../CWE-094/InsecureBeanValidation.java | 4 +- .../CWE-094/JexlInjection/Jexl2Injection.java | 20 +-- .../CWE-094/JexlInjection/Jexl3Injection.java | 28 ++-- .../MvelInjection/MvelInjectionTest.java | 28 ++-- .../SpelInjection/SpelInjectionTest.java | 28 ++-- .../TemplateInjection/FreemarkerSSTI.java | 36 ++-- .../TemplateInjection/JinJavaSSTI.java | 12 +- .../CWE-094/TemplateInjection/PebbleSSTI.java | 8 +- .../TemplateInjection/ThymeleafSSTI.java | 20 +-- .../TemplateInjection/VelocitySSTI.java | 22 +-- .../semmle/tests/ConditionalBypassTest.java | 26 +-- .../org/apache/camel/Consume.java | 8 +- .../camel/builder/ExpressionClause.java | 2 +- .../apache/camel/builder/RouteBuilder.java | 4 +- .../camel/impl/DefaultCamelContext.java | 2 +- .../apache/camel/model/FilterDefinition.java | 2 +- .../apache/camel/model/OutputDefinition.java | 2 +- .../camel/model/ProcessorDefinition.java | 2 +- .../apache/camel/model/RouteDefinition.java | 2 +- 41 files changed, 416 insertions(+), 420 deletions(-) diff --git a/java/ql/test/query-tests/DeadCode/camel/DeadClass.qlref b/java/ql/test/query-tests/DeadCode/camel/DeadClass.qlref index b94832ebfca..d726e7e0849 100644 --- a/java/ql/test/query-tests/DeadCode/camel/DeadClass.qlref +++ b/java/ql/test/query-tests/DeadCode/camel/DeadClass.qlref @@ -1,2 +1 @@ -query: DeadCode/DeadClass.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +DeadCode/DeadClass.ql diff --git a/java/ql/test/query-tests/DeadCode/camel/DeadMethod.qlref b/java/ql/test/query-tests/DeadCode/camel/DeadMethod.qlref index 743a5f15775..76204a1df5a 100644 --- a/java/ql/test/query-tests/DeadCode/camel/DeadMethod.qlref +++ b/java/ql/test/query-tests/DeadCode/camel/DeadMethod.qlref @@ -1,2 +1 @@ -query: DeadCode/DeadMethod.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +DeadCode/DeadMethod.ql diff --git a/java/ql/test/query-tests/DeadCode/camel/com/semmle/camel/DeadTarget.java b/java/ql/test/query-tests/DeadCode/camel/com/semmle/camel/DeadTarget.java index d2ccfa90e36..f4fabc7d22e 100644 --- a/java/ql/test/query-tests/DeadCode/camel/com/semmle/camel/DeadTarget.java +++ b/java/ql/test/query-tests/DeadCode/camel/com/semmle/camel/DeadTarget.java @@ -1,10 +1,10 @@ package com.semmle.camel; /** Dead because it is not referenced in the {@code config.xml} file, or in the Java DSL. */ -public class DeadTarget { // $ Alert[java/dead-class] +public class DeadTarget { public Foo getFoo(Foo foo1) { return new Foo(); } - public static class Foo {} // $ Alert[java/dead-class] + public static class Foo {} } diff --git a/java/ql/test/query-tests/DeadCode/camel/com/semmle/camel/javadsl/CustomRouteBuilder.java b/java/ql/test/query-tests/DeadCode/camel/com/semmle/camel/javadsl/CustomRouteBuilder.java index 01baa30e0a9..437a4d7b56d 100644 --- a/java/ql/test/query-tests/DeadCode/camel/com/semmle/camel/javadsl/CustomRouteBuilder.java +++ b/java/ql/test/query-tests/DeadCode/camel/com/semmle/camel/javadsl/CustomRouteBuilder.java @@ -5,7 +5,7 @@ import org.apache.camel.impl.DefaultCamelContext; public class CustomRouteBuilder extends RouteBuilder { @Override - public void configure() throws Exception { // $ Alert[java/dead-function] + public void configure() throws Exception { from("direct:test") .to("bean:dslToTarget") .bean(DSLBeanTarget.class) diff --git a/java/ql/test/query-tests/Javadoc/ImpossibleJavadocThrows.java b/java/ql/test/query-tests/Javadoc/ImpossibleJavadocThrows.java index 9795251ce9a..3a087f6ea92 100644 --- a/java/ql/test/query-tests/Javadoc/ImpossibleJavadocThrows.java +++ b/java/ql/test/query-tests/Javadoc/ImpossibleJavadocThrows.java @@ -6,14 +6,14 @@ class ImpossibleJavadocThrows { /** * - * @throws InterruptedException // $ Alert + * @throws InterruptedException */ public void bad1() { } /** * - * @exception Exception // $ Alert + * @exception Exception */ public void bad2() { } diff --git a/java/ql/test/query-tests/Javadoc/ImpossibleJavadocThrows.qlref b/java/ql/test/query-tests/Javadoc/ImpossibleJavadocThrows.qlref index dc001712b07..51541686bfc 100644 --- a/java/ql/test/query-tests/Javadoc/ImpossibleJavadocThrows.qlref +++ b/java/ql/test/query-tests/Javadoc/ImpossibleJavadocThrows.qlref @@ -1,2 +1 @@ -query: Advisory/Documentation/ImpossibleJavadocThrows.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Advisory/Documentation/ImpossibleJavadocThrows.ql diff --git a/java/ql/test/query-tests/MissingSpaceTypo/A.java b/java/ql/test/query-tests/MissingSpaceTypo/A.java index a095d8568d8..284fd20c863 100644 --- a/java/ql/test/query-tests/MissingSpaceTypo/A.java +++ b/java/ql/test/query-tests/MissingSpaceTypo/A.java @@ -1,19 +1,19 @@ public class A { public void missing() { String s; - s = "this text" + // $ + s = "this text" + "is missing a space"; // $ Alert - s = "the class java.util.ArrayList" + // $ + s = "the class java.util.ArrayList" + "without a space"; // $ Alert - s = "This isn't" + // $ + s = "This isn't" + "right."; // $ Alert - s = "There's 1" + // $ + s = "There's 1" + "thing wrong"; // $ Alert - s = "There's A/B" + // $ + s = "There's A/B" + "and no space"; // $ Alert - s = "Wait for it...." + // $ + s = "Wait for it...." + "No space!"; // $ Alert - s = "Is there a space?" + // $ + s = "Is there a space?" + "No!"; // $ Alert } diff --git a/java/ql/test/query-tests/SpuriousJavadocParam/Test.java b/java/ql/test/query-tests/SpuriousJavadocParam/Test.java index ca724cf468c..d8891afb756 100644 --- a/java/ql/test/query-tests/SpuriousJavadocParam/Test.java +++ b/java/ql/test/query-tests/SpuriousJavadocParam/Test.java @@ -54,83 +54,83 @@ public class Test { protected void ok9(int...param){ } /** - * @param prameter typo // $ Alert + * @param prameter typo */ public void problem1(int parameter){ } /** - * @param Parameter capitalization // $ Alert + * @param Parameter capitalization */ public void problem2(int parameter){ } /** - * @param parameter unmatched // $ Alert + * @param parameter unmatched */ public void problem3(){ } /** * @param someOtherParameter matched - * @param parameter unmatched // $ Alert + * @param parameter unmatched */ public void problem4(int someOtherParameter){ } /** - * @param unmatched type parameter // $ Alert + * @param unmatched type parameter */ private T problem5(){ return null; } /** * @param matched type parameter - * @param

unmatched type parameter // $ Alert - * @param n unmatched normal parameter // $ Alert + * @param

unmatched type parameter + * @param n unmatched normal parameter */ private T problem6(V p){ return null; } /** * param with immediate newline - * @param // $ Alert + * @param */ protected void problem7(){ } /** * param without a value (followed by blanks) - * @param // $ Alert + * @param */ protected void problem8(){ } class SomeClass { /** * @param i exists - * @param k does not // $ Alert + * @param k does not */ SomeClass(int i, int j) {} } /** * @param exists - * @param T wrong syntax // $ Alert - * @param does not exist // $ Alert + * @param T wrong syntax + * @param does not exist */ class GenericClass {} /** * @param exists - * @param T wrong syntax // $ Alert - * @param does not exist // $ Alert + * @param T wrong syntax + * @param does not exist */ interface GenericInterface {} /** * @param i exists - * @param k does not // $ Alert + * @param k does not */ static record SomeRecord(int i, int j) {} /** * @param exists - * @param does not // $ Alert + * @param does not * @param i exists - * @param k does not // $ Alert + * @param k does not */ static record GenericRecord(int i, int j) {} } diff --git a/java/ql/test/query-tests/SpuriousJavadocParam/test.qlref b/java/ql/test/query-tests/SpuriousJavadocParam/test.qlref index 85c1971658c..05f7231fe6b 100644 --- a/java/ql/test/query-tests/SpuriousJavadocParam/test.qlref +++ b/java/ql/test/query-tests/SpuriousJavadocParam/test.qlref @@ -1,2 +1 @@ -query: Advisory/Documentation/SpuriousJavadocParam.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Advisory/Documentation/SpuriousJavadocParam.ql diff --git a/java/ql/test/query-tests/security/CWE-020/ExternalAPISinkExample.java b/java/ql/test/query-tests/security/CWE-020/ExternalAPISinkExample.java index de76455c201..9e30b228c48 100644 --- a/java/ql/test/query-tests/security/CWE-020/ExternalAPISinkExample.java +++ b/java/ql/test/query-tests/security/CWE-020/ExternalAPISinkExample.java @@ -9,6 +9,6 @@ public class ExternalAPISinkExample extends HttpServlet { throws ServletException, IOException { // BAD: a request parameter is written directly to an error response page response.sendError(HttpServletResponse.SC_NOT_FOUND, - "The page \"" + request.getParameter("page") + "\" was not found."); // $ Alert + "The page \"" + request.getParameter("page") + "\" was not found."); // $ Alert[java/untrusted-data-to-external-api] } } diff --git a/java/ql/test/query-tests/security/CWE-022/semmle/tests/TaintedPath.java b/java/ql/test/query-tests/security/CWE-022/semmle/tests/TaintedPath.java index fb87c687823..fffb93c6291 100644 --- a/java/ql/test/query-tests/security/CWE-022/semmle/tests/TaintedPath.java +++ b/java/ql/test/query-tests/security/CWE-022/semmle/tests/TaintedPath.java @@ -10,10 +10,10 @@ import java.nio.file.Paths; public class TaintedPath { public void sendUserFile(Socket sock, String user) throws IOException { BufferedReader filenameReader = - new BufferedReader(new InputStreamReader(sock.getInputStream(), "UTF-8")); // $ Source + new BufferedReader(new InputStreamReader(sock.getInputStream(), "UTF-8")); // $ Source[java/path-injection] String filename = filenameReader.readLine(); // BAD: read from a file without checking its path - BufferedReader fileReader = new BufferedReader(new FileReader(filename)); // $ Alert + BufferedReader fileReader = new BufferedReader(new FileReader(filename)); // $ Alert[java/path-injection] String fileLine = fileReader.readLine(); while (fileLine != null) { sock.getOutputStream().write(fileLine.getBytes()); diff --git a/java/ql/test/query-tests/security/CWE-022/semmle/tests/Test.java b/java/ql/test/query-tests/security/CWE-022/semmle/tests/Test.java index 362c84f4b16..6ef57737226 100644 --- a/java/ql/test/query-tests/security/CWE-022/semmle/tests/Test.java +++ b/java/ql/test/query-tests/security/CWE-022/semmle/tests/Test.java @@ -29,143 +29,143 @@ public class Test { private HttpServletRequest request; public Object source() { - return request.getParameter("source"); // $ Source + return request.getParameter("source"); // $ Source[java/path-injection] } void test() throws IOException { // "java.lang;Module;true;getResourceAsStream;(String);;Argument[0];read-file;ai-generated" - getClass().getModule().getResourceAsStream((String) source()); // $ Alert + getClass().getModule().getResourceAsStream((String) source()); // $ Alert[java/path-injection] // "java.lang;Class;false;getResource;(String);;Argument[0];read-file;ai-generated" - getClass().getResource((String) source()); // $ Alert + getClass().getResource((String) source()); // $ Alert[java/path-injection] // "java.lang;ClassLoader;true;getSystemResourceAsStream;(String);;Argument[0];read-file;ai-generated" - ClassLoader.getSystemResourceAsStream((String) source()); // $ Alert + ClassLoader.getSystemResourceAsStream((String) source()); // $ Alert[java/path-injection] // "java.io;File;True;canExecute;();;Argument[this];path-injection;manual" - ((File) source()).canExecute(); // $ Alert + ((File) source()).canExecute(); // $ Alert[java/path-injection] // "java.io;File;True;canRead;();;Argument[this];path-injection;manual" - ((File) source()).canRead(); // $ Alert + ((File) source()).canRead(); // $ Alert[java/path-injection] // "java.io;File;True;canWrite;();;Argument[this];path-injection;manual" - ((File) source()).canWrite(); // $ Alert + ((File) source()).canWrite(); // $ Alert[java/path-injection] // "java.io;File;True;createNewFile;();;Argument[this];path-injection;ai-manual" - ((File) source()).createNewFile(); // $ Alert + ((File) source()).createNewFile(); // $ Alert[java/path-injection] // "java.io;File;true;createTempFile;(String,String,File);;Argument[2];create-file;ai-generated" - File.createTempFile(";", ";", (File) source()); // $ Alert + File.createTempFile(";", ";", (File) source()); // $ Alert[java/path-injection] // "java.io;File;True;delete;();;Argument[this];path-injection;manual" - ((File) source()).delete(); // $ Alert + ((File) source()).delete(); // $ Alert[java/path-injection] // "java.io;File;True;deleteOnExit;();;Argument[this];path-injection;manual" - ((File) source()).deleteOnExit(); // $ Alert + ((File) source()).deleteOnExit(); // $ Alert[java/path-injection] // "java.io;File;True;exists;();;Argument[this];path-injection;manual" - ((File) source()).exists(); // $ Alert + ((File) source()).exists(); // $ Alert[java/path-injection] // "java.io:File;True;isDirectory;();;Argument[this];path-injection;manual" - ((File) source()).isDirectory(); // $ Alert + ((File) source()).isDirectory(); // $ Alert[java/path-injection] // "java.io:File;True;isFile;();;Argument[this];path-injection;manual" - ((File) source()).isFile(); // $ Alert + ((File) source()).isFile(); // $ Alert[java/path-injection] // "java.io:File;True;isHidden;();;Argument[this];path-injection;manual" - ((File) source()).isHidden(); // $ Alert + ((File) source()).isHidden(); // $ Alert[java/path-injection] // "java.io;File;True;mkdir;();;Argument[this];path-injection;manual" - ((File) source()).mkdir(); // $ Alert + ((File) source()).mkdir(); // $ Alert[java/path-injection] // "java.io;File;True;mkdirs;();;Argument[this];path-injection;manual" - ((File) source()).mkdirs(); // $ Alert + ((File) source()).mkdirs(); // $ Alert[java/path-injection] // "java.io;File;True;renameTo;(File);;Argument[0];path-injection;ai-manual" - new File("").renameTo((File) source()); // $ Alert + new File("").renameTo((File) source()); // $ Alert[java/path-injection] // "java.io;File;True;renameTo;(File);;Argument[this];path-injection;ai-manual" - ((File) source()).renameTo(null); // $ Alert + ((File) source()).renameTo(null); // $ Alert[java/path-injection] // "java.io;File;True;setExecutable;;;Argument[this];path-injection;manual" - ((File) source()).setExecutable(true); // $ Alert + ((File) source()).setExecutable(true); // $ Alert[java/path-injection] // "java.io;File;True;setLastModified;;;Argument[this];path-injection;manual" - ((File) source()).setLastModified(0); // $ Alert + ((File) source()).setLastModified(0); // $ Alert[java/path-injection] // "java.io;File;True;setReadable;;;Argument[this];path-injection;manual" - ((File) source()).setReadable(true); // $ Alert + ((File) source()).setReadable(true); // $ Alert[java/path-injection] // "java.io;File;True;setReadOnly;;;Argument[this];path-injection;manual" - ((File) source()).setReadOnly(); // $ Alert + ((File) source()).setReadOnly(); // $ Alert[java/path-injection] // "java.io;File;True;setWritable;;;Argument[this];path-injection;manual" - ((File) source()).setWritable(true); // $ Alert + ((File) source()).setWritable(true); // $ Alert[java/path-injection] // "java.io;File;true;renameTo;(File);;Argument[0];create-file;ai-generated" - new File("").renameTo((File) source()); // $ Alert + new File("").renameTo((File) source()); // $ Alert[java/path-injection] // "java.io;FileInputStream;true;FileInputStream;(File);;Argument[0];read-file;ai-generated" - new FileInputStream((File) source()); // $ Alert + new FileInputStream((File) source()); // $ Alert[java/path-injection] // "java.io;FileInputStream;true;FileInputStream;(FileDescriptor);;Argument[0];read-file;manual" - new FileInputStream((FileDescriptor) source()); // $ Alert + new FileInputStream((FileDescriptor) source()); // $ Alert[java/path-injection] // "java.io;FileInputStream;true;FileInputStream;(String);;Argument[0];read-file;manual" - new FileInputStream((String) source()); // $ Alert + new FileInputStream((String) source()); // $ Alert[java/path-injection] // "java.io;FileReader;true;FileReader;(File);;Argument[0];read-file;ai-generated" - new FileReader((File) source()); // $ Alert + new FileReader((File) source()); // $ Alert[java/path-injection] // "java.io;FileReader;true;FileReader;(FileDescriptor);;Argument[0];read-file;manual" - new FileReader((FileDescriptor) source()); // $ Alert + new FileReader((FileDescriptor) source()); // $ Alert[java/path-injection] // "java.io;FileReader;true;FileReader;(File,Charset);;Argument[0];read-file;manual" - new FileReader((File) source(), null); // $ Alert + new FileReader((File) source(), null); // $ Alert[java/path-injection] // "java.io;FileReader;true;FileReader;(String);;Argument[0];read-file;ai-generated" - new FileReader((String) source()); // $ Alert + new FileReader((String) source()); // $ Alert[java/path-injection] // "java.io;FileReader;true;FileReader;(String,Charset);;Argument[0];read-file;manual" - new FileReader((String) source(), null); // $ Alert + new FileReader((String) source(), null); // $ Alert[java/path-injection] // "java.nio.file;Files;false;copy;;;Argument[0];read-file;manual" - Files.copy((Path) source(), (Path) null); // $ Alert - Files.copy((Path) source(), (OutputStream) null); // $ Alert + Files.copy((Path) source(), (Path) null); // $ Alert[java/path-injection] + Files.copy((Path) source(), (OutputStream) null); // $ Alert[java/path-injection] // "java.nio.file;Files;false;copy;;;Argument[1];create-file;manual" - Files.copy((Path) null, (Path) source()); // $ Alert - Files.copy((InputStream) null, (Path) source()); // $ Alert + Files.copy((Path) null, (Path) source()); // $ Alert[java/path-injection] + Files.copy((InputStream) null, (Path) source()); // $ Alert[java/path-injection] // "java.nio.file;Files;false;createDirectories;;;Argument[0];create-file;manual" - Files.createDirectories((Path) source()); // $ Alert + Files.createDirectories((Path) source()); // $ Alert[java/path-injection] // "java.nio.file;Files;false;createDirectory;;;Argument[0];create-file;manual" - Files.createDirectory((Path) source()); // $ Alert + Files.createDirectory((Path) source()); // $ Alert[java/path-injection] // "java.nio.file;Files;false;createFile;;;Argument[0];create-file;manual" - Files.createFile((Path) source()); // $ Alert + Files.createFile((Path) source()); // $ Alert[java/path-injection] // "java.nio.file;Files;false;createLink;;;Argument[0];create-file;manual" - Files.createLink((Path) source(), null); // $ Alert + Files.createLink((Path) source(), null); // $ Alert[java/path-injection] // "java.nio.file;Files;false;createSymbolicLink;;;Argument[0];create-file;manual" - Files.createSymbolicLink((Path) source(), null); // $ Alert + Files.createSymbolicLink((Path) source(), null); // $ Alert[java/path-injection] // "java.nio.file;Files;false;createTempDirectory;(Path,String,FileAttribute[]);;Argument[0];create-file;manual" - Files.createTempDirectory((Path) source(), null); // $ Alert + Files.createTempDirectory((Path) source(), null); // $ Alert[java/path-injection] // "java.nio.file;Files;false;createTempFile;(Path,String,String,FileAttribute[]);;Argument[0];create-file;manual" - Files.createTempFile((Path) source(), null, null); // $ Alert + Files.createTempFile((Path) source(), null, null); // $ Alert[java/path-injection] // "java.nio.file;Files;false;delete;(Path);;Argument[0];delete-file;ai-generated" - Files.delete((Path) source()); // $ Alert + Files.delete((Path) source()); // $ Alert[java/path-injection] // "java.nio.file;Files;false;deleteIfExists;(Path);;Argument[0];delete-file;ai-generated" - Files.deleteIfExists((Path) source()); // $ Alert + Files.deleteIfExists((Path) source()); // $ Alert[java/path-injection] // "java.nio.file;Files;false;lines;(Path,Charset);;Argument[0];read-file;ai-generated" - Files.lines((Path) source(), null); // $ Alert + Files.lines((Path) source(), null); // $ Alert[java/path-injection] // "java.nio.file;Files;false;move;;;Argument[1];create-file;manual" - Files.move(null, (Path) source()); // $ Alert + Files.move(null, (Path) source()); // $ Alert[java/path-injection] // "java.nio.file;Files;false;newBufferedReader;(Path,Charset);;Argument[0];read-file;ai-generated" - Files.newBufferedReader((Path) source(), null); // $ Alert + Files.newBufferedReader((Path) source(), null); // $ Alert[java/path-injection] // "java.nio.file;Files;false;newBufferedWriter;;;Argument[0];create-file;manual" - Files.newBufferedWriter((Path) source()); // $ Alert - Files.newBufferedWriter((Path) source(), (Charset) null); // $ Alert + Files.newBufferedWriter((Path) source()); // $ Alert[java/path-injection] + Files.newBufferedWriter((Path) source(), (Charset) null); // $ Alert[java/path-injection] // "java.nio.file;Files;false;newOutputStream;;;Argument[0];create-file;manual" - Files.newOutputStream((Path) source()); // $ Alert + Files.newOutputStream((Path) source()); // $ Alert[java/path-injection] // "java.nio.file;Files;false;write;;;Argument[0];create-file;manual" - Files.write((Path) source(), (byte[]) null); // $ Alert - Files.write((Path) source(), (Iterable) null); // $ Alert - Files.write((Path) source(), (Iterable) null, (Charset) null); // $ Alert + Files.write((Path) source(), (byte[]) null); // $ Alert[java/path-injection] + Files.write((Path) source(), (Iterable) null); // $ Alert[java/path-injection] + Files.write((Path) source(), (Iterable) null, (Charset) null); // $ Alert[java/path-injection] // "java.nio.file;Files;false;writeString;;;Argument[0];create-file;manual" - Files.writeString((Path) source(), (CharSequence) null); // $ Alert - Files.writeString((Path) source(), (CharSequence) null, (Charset) null); // $ Alert + Files.writeString((Path) source(), (CharSequence) null); // $ Alert[java/path-injection] + Files.writeString((Path) source(), (CharSequence) null, (Charset) null); // $ Alert[java/path-injection] // "javax.xml.transform.stream;StreamResult";true;"StreamResult;(File);;Argument[0];create-file;ai-generated" - new StreamResult((File) source()); // $ Alert + new StreamResult((File) source()); // $ Alert[java/path-injection] // "org.apache.commons.io;FileUtils;true;openInputStream;(File);;Argument[0];read-file;ai-generated" - FileUtils.openInputStream((File) source()); // $ Alert + FileUtils.openInputStream((File) source()); // $ Alert[java/path-injection] // "org.codehaus.cargo.container.installer;ZipURLInstaller;true;ZipURLInstaller;(URL,String,String);;Argument[1];create-file;ai-generated" - new ZipURLInstaller((URL) null, (String) source(), ""); // $ Alert + new ZipURLInstaller((URL) null, (String) source(), ""); // $ Alert[java/path-injection] // "org.codehaus.cargo.container.installer;ZipURLInstaller;true;ZipURLInstaller;(URL,String,String);;Argument[2];create-file;ai-generated" - new ZipURLInstaller((URL) null, "", (String) source()); // $ Alert + new ZipURLInstaller((URL) null, "", (String) source()); // $ Alert[java/path-injection] // "org.springframework.util;FileCopyUtils;false;copy;(byte[],File);;Argument[1];create-file;manual" - FileCopyUtils.copy((byte[]) null, (File) source()); // $ Alert + FileCopyUtils.copy((byte[]) null, (File) source()); // $ Alert[java/path-injection] // "org.springframework.util;FileCopyUtils;false;copy;(File,File);;Argument[0];create-file;manual" - FileCopyUtils.copy((File) source(), null); // $ Alert + FileCopyUtils.copy((File) source(), null); // $ Alert[java/path-injection] // "org.springframework.util;FileCopyUtils;false;copy;(File,File);;Argument[1];create-file;manual" - FileCopyUtils.copy((File) null, (File) source()); // $ Alert + FileCopyUtils.copy((File) null, (File) source()); // $ Alert[java/path-injection] } void test(AntClassLoader acl) { // "org.apache.tools.ant;AntClassLoader;true;addPathComponent;(File);;Argument[0];read-file;ai-generated" - acl.addPathComponent((File) source()); // $ Alert + acl.addPathComponent((File) source()); // $ Alert[java/path-injection] // "org.apache.tools.ant;AntClassLoader;true;AntClassLoader;(ClassLoader,Project,Path,boolean);;Argument[2];read-file;ai-generated" - new AntClassLoader(null, null, (org.apache.tools.ant.types.Path) source(), false); // $ Alert + new AntClassLoader(null, null, (org.apache.tools.ant.types.Path) source(), false); // $ Alert[java/path-injection] // "org.apache.tools.ant;AntClassLoader;true;AntClassLoader;(Project,Path,boolean);;Argument[1];read-file;ai-generated" - new AntClassLoader(null, (org.apache.tools.ant.types.Path) source(), false); // $ Alert + new AntClassLoader(null, (org.apache.tools.ant.types.Path) source(), false); // $ Alert[java/path-injection] // "org.apache.tools.ant;AntClassLoader;true;AntClassLoader;(Project,Path);;Argument[1];read-file;ai-generated" - new AntClassLoader(null, (org.apache.tools.ant.types.Path) source()); // $ Alert + new AntClassLoader(null, (org.apache.tools.ant.types.Path) source()); // $ Alert[java/path-injection] // "org.kohsuke.stapler.framework.io;LargeText;true;LargeText;(File,Charset,boolean,boolean);;Argument[0];read-file;ai-generated" - new LargeText((File) source(), null, false, false); // $ Alert + new LargeText((File) source(), null, false, false); // $ Alert[java/path-injection] } void doGet6(String root, HttpServletRequest request) throws IOException { @@ -178,29 +178,29 @@ public class Test { void test(DirectoryScanner ds) { // "org.apache.tools.ant;DirectoryScanner;true;setBasedir;(File);;Argument[0];read-file;ai-generated" - ds.setBasedir((File) source()); // $ Alert + ds.setBasedir((File) source()); // $ Alert[java/path-injection] } void test(Copy cp) { // "org.apache.tools.ant.taskdefs;Copy;true;addFileset;(FileSet);;Argument[0];read-file;ai-generated" - cp.addFileset((FileSet) source()); // $ Alert + cp.addFileset((FileSet) source()); // $ Alert[java/path-injection] // "org.apache.tools.ant.taskdefs;Copy;true;setFile;(File);;Argument[0];read-file;ai-generated" - cp.setFile((File) source()); // $ Alert + cp.setFile((File) source()); // $ Alert[java/path-injection] // "org.apache.tools.ant.taskdefs;Copy;true;setTodir;(File);;Argument[0];create-file;ai-generated" - cp.setTodir((File) source()); // $ Alert + cp.setTodir((File) source()); // $ Alert[java/path-injection] // "org.apache.tools.ant.taskdefs;Copy;true;setTofile;(File);;Argument[0];create-file;ai-generated" - cp.setTofile((File) source()); // $ Alert + cp.setTofile((File) source()); // $ Alert[java/path-injection] } void test(Expand ex) { // "org.apache.tools.ant.taskdefs;Expand;true;setDest;(File);;Argument[0];create-file;ai-generated" - ex.setDest((File) source()); // $ Alert + ex.setDest((File) source()); // $ Alert[java/path-injection] // "org.apache.tools.ant.taskdefs;Expand;true;setSrc;(File);;Argument[0];read-file;ai-generated" - ex.setSrc((File) source()); // $ Alert + ex.setSrc((File) source()); // $ Alert[java/path-injection] } void test(ChainedOptionsBuilder cob) { // "org.openjdk.jmh.runner.options;ChainedOptionsBuilder;true;result;(String);;Argument[0];create-file;ai-generated" - cob.result((String) source()); // $ Alert + cob.result((String) source()); // $ Alert[java/path-injection] } } diff --git a/java/ql/test/query-tests/security/CWE-079/semmle/tests/JaxXSS.java b/java/ql/test/query-tests/security/CWE-079/semmle/tests/JaxXSS.java index 0e096ab94e0..0ca5b737d86 100644 --- a/java/ql/test/query-tests/security/CWE-079/semmle/tests/JaxXSS.java +++ b/java/ql/test/query-tests/security/CWE-079/semmle/tests/JaxXSS.java @@ -12,25 +12,25 @@ import java.util.Locale; public class JaxXSS { @GET - public static Response specificContentType(boolean safeContentType, boolean chainDirectly, boolean contentTypeFirst, String userControlled) { // $ Source + public static Response specificContentType(boolean safeContentType, boolean chainDirectly, boolean contentTypeFirst, String userControlled) { // $ Source[java/xss] Response.ResponseBuilder builder = Response.ok(); if(!safeContentType) { if(chainDirectly) { if(contentTypeFirst) - return builder.type(MediaType.TEXT_HTML).entity(userControlled).build(); // $ Alert + return builder.type(MediaType.TEXT_HTML).entity(userControlled).build(); // $ Alert[java/xss] else - return builder.entity(userControlled).type(MediaType.TEXT_HTML).build(); // $ Alert + return builder.entity(userControlled).type(MediaType.TEXT_HTML).build(); // $ Alert[java/xss] } else { if(contentTypeFirst) { Response.ResponseBuilder builder2 = builder.type(MediaType.TEXT_HTML); - return builder2.entity(userControlled).build(); // $ Alert + return builder2.entity(userControlled).build(); // $ Alert[java/xss] } else { Response.ResponseBuilder builder2 = builder.entity(userControlled); - return builder2.type(MediaType.TEXT_HTML).build(); // $ Alert + return builder2.type(MediaType.TEXT_HTML).build(); // $ Alert[java/xss] } } } @@ -56,7 +56,7 @@ public class JaxXSS { } @GET - public static Response specificContentTypeSetterMethods(int route, boolean safeContentType, String userControlled) { // $ Source + public static Response specificContentTypeSetterMethods(int route, boolean safeContentType, String userControlled) { // $ Source[java/xss] // Test the remarkably many routes to setting a content-type in Jax-RS, besides the ResponseBuilder.entity method used above: @@ -105,39 +105,39 @@ public class JaxXSS { else { if(route == 0) { // via ok, as a string literal: - return Response.ok("text/html").entity(userControlled).build(); // $ Alert + return Response.ok("text/html").entity(userControlled).build(); // $ Alert[java/xss] } else if(route == 1) { // via ok, as a string constant: - return Response.ok(MediaType.TEXT_HTML).entity(userControlled).build(); // $ Alert + return Response.ok(MediaType.TEXT_HTML).entity(userControlled).build(); // $ Alert[java/xss] } else if(route == 2) { // via ok, as a MediaType constant: - return Response.ok(MediaType.TEXT_HTML_TYPE).entity(userControlled).build(); // $ Alert + return Response.ok(MediaType.TEXT_HTML_TYPE).entity(userControlled).build(); // $ Alert[java/xss] } else if(route == 3) { // via ok, as a Variant, via constructor: - return Response.ok(new Variant(MediaType.TEXT_HTML_TYPE, "language", "encoding")).entity(userControlled).build(); // $ Alert + return Response.ok(new Variant(MediaType.TEXT_HTML_TYPE, "language", "encoding")).entity(userControlled).build(); // $ Alert[java/xss] } else if(route == 4) { // via ok, as a Variant, via static method: - return Response.ok(Variant.mediaTypes(MediaType.TEXT_HTML_TYPE).build()).entity(userControlled).build(); // $ Alert + return Response.ok(Variant.mediaTypes(MediaType.TEXT_HTML_TYPE).build()).entity(userControlled).build(); // $ Alert[java/xss] } else if(route == 5) { // via ok, as a Variant, via instance method: - return Response.ok(Variant.languages(Locale.UK).mediaTypes(MediaType.TEXT_HTML_TYPE).build()).entity(userControlled).build(); // $ Alert + return Response.ok(Variant.languages(Locale.UK).mediaTypes(MediaType.TEXT_HTML_TYPE).build()).entity(userControlled).build(); // $ Alert[java/xss] } else if(route == 6) { // via builder variant, before entity: - return Response.ok().variant(new Variant(MediaType.TEXT_HTML_TYPE, "language", "encoding")).entity(userControlled).build(); // $ Alert + return Response.ok().variant(new Variant(MediaType.TEXT_HTML_TYPE, "language", "encoding")).entity(userControlled).build(); // $ Alert[java/xss] } else if(route == 7) { // via builder variant, after entity: - return Response.ok().entity(userControlled).variant(new Variant(MediaType.TEXT_HTML_TYPE, "language", "encoding")).build(); // $ Alert + return Response.ok().entity(userControlled).variant(new Variant(MediaType.TEXT_HTML_TYPE, "language", "encoding")).build(); // $ Alert[java/xss] } else if(route == 8) { // provide entity via ok, then content-type via builder: - return Response.ok(userControlled).type(MediaType.TEXT_HTML_TYPE).build(); // $ Alert + return Response.ok(userControlled).type(MediaType.TEXT_HTML_TYPE).build(); // $ Alert[java/xss] } } @@ -161,28 +161,28 @@ public class JaxXSS { } @GET @Produces(MediaType.TEXT_HTML) - public static Response methodContentTypeUnsafe(String userControlled) { // $ Source - return Response.ok(userControlled).build(); // $ Alert + public static Response methodContentTypeUnsafe(String userControlled) { // $ Source[java/xss] + return Response.ok(userControlled).build(); // $ Alert[java/xss] } @POST @Produces(MediaType.TEXT_HTML) - public static Response methodContentTypeUnsafePost(String userControlled) { // $ Source - return Response.ok(userControlled).build(); // $ Alert + public static Response methodContentTypeUnsafePost(String userControlled) { // $ Source[java/xss] + return Response.ok(userControlled).build(); // $ Alert[java/xss] } @GET @Produces("text/html") - public static Response methodContentTypeUnsafeStringLiteral(String userControlled) { // $ Source - return Response.ok(userControlled).build(); // $ Alert + public static Response methodContentTypeUnsafeStringLiteral(String userControlled) { // $ Source[java/xss] + return Response.ok(userControlled).build(); // $ Alert[java/xss] } @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) - public static Response methodContentTypeMaybeSafe(String userControlled) { // $ Source - return Response.ok(userControlled).build(); // $ Alert + public static Response methodContentTypeMaybeSafe(String userControlled) { // $ Source[java/xss] + return Response.ok(userControlled).build(); // $ Alert[java/xss] } @GET @Produces(MediaType.APPLICATION_JSON) - public static Response methodContentTypeSafeOverriddenWithUnsafe(String userControlled) { // $ Source - return Response.ok().type(MediaType.TEXT_HTML).entity(userControlled).build(); // $ Alert + public static Response methodContentTypeSafeOverriddenWithUnsafe(String userControlled) { // $ Source[java/xss] + return Response.ok().type(MediaType.TEXT_HTML).entity(userControlled).build(); // $ Alert[java/xss] } @GET @Produces(MediaType.TEXT_HTML) @@ -204,13 +204,13 @@ public class JaxXSS { } @GET @Produces({"text/html"}) - public Response overridesWithUnsafe(String userControlled) { // $ Source - return Response.ok(userControlled).build(); // $ Alert + public Response overridesWithUnsafe(String userControlled) { // $ Source[java/xss] + return Response.ok(userControlled).build(); // $ Alert[java/xss] } @GET - public Response overridesWithUnsafe2(String userControlled) { // $ Source - return Response.ok().type(MediaType.TEXT_HTML).entity(userControlled).build(); // $ Alert + public Response overridesWithUnsafe2(String userControlled) { // $ Source[java/xss] + return Response.ok().type(MediaType.TEXT_HTML).entity(userControlled).build(); // $ Alert[java/xss] } } @@ -218,13 +218,13 @@ public class JaxXSS { @Produces({"text/html"}) public static class ClassContentTypeUnsafe { @GET - public Response test(String userControlled) { // $ Source - return Response.ok(userControlled).build(); // $ Alert + public Response test(String userControlled) { // $ Source[java/xss] + return Response.ok(userControlled).build(); // $ Alert[java/xss] } @GET - public String testDirectReturn(String userControlled) { // $ Source - return userControlled; // $ Alert + public String testDirectReturn(String userControlled) { // $ Source[java/xss] + return userControlled; // $ Alert[java/xss] } @GET @Produces({"application/json"}) @@ -239,13 +239,13 @@ public class JaxXSS { } @GET - public static Response entityWithNoMediaType(String userControlled) { // $ Source - return Response.ok(userControlled).build(); // $ Alert + public static Response entityWithNoMediaType(String userControlled) { // $ Source[java/xss] + return Response.ok(userControlled).build(); // $ Alert[java/xss] } @GET - public static String stringWithNoMediaType(String userControlled) { // $ Source - return userControlled; // $ Alert + public static String stringWithNoMediaType(String userControlled) { // $ Source[java/xss] + return userControlled; // $ Alert[java/xss] } } diff --git a/java/ql/test/query-tests/security/CWE-079/semmle/tests/JsfXSS.java b/java/ql/test/query-tests/security/CWE-079/semmle/tests/JsfXSS.java index f3efab3ddfe..a6f95bccfa6 100644 --- a/java/ql/test/query-tests/security/CWE-079/semmle/tests/JsfXSS.java +++ b/java/ql/test/query-tests/security/CWE-079/semmle/tests/JsfXSS.java @@ -18,7 +18,7 @@ public class JsfXSS extends Renderer { super.encodeBegin(facesContext, component); - Map requestParameters = facesContext.getExternalContext().getRequestParameterMap(); // $ Source + Map requestParameters = facesContext.getExternalContext().getRequestParameterMap(); // $ Source[java/xss] String windowId = requestParameters.get("window_id"); ResponseWriter writer = facesContext.getResponseWriter(); @@ -26,7 +26,7 @@ public class JsfXSS extends Renderer writer.write("(function(){"); writer.write("dswh.init('" + windowId + "','" + "......" + "'," - + -1 + ",{"); // $ Alert + + -1 + ",{"); // $ Alert[java/xss] writer.write("});"); writer.write("})();"); writer.write(""); @@ -57,13 +57,13 @@ public class JsfXSS extends Renderer { ExternalContext ec = facesContext.getExternalContext(); ResponseWriter writer = facesContext.getResponseWriter(); - writer.write(ec.getRequestParameterMap().keySet().iterator().next()); // $ Alert - writer.write(ec.getRequestParameterNames().next()); // $ Alert - writer.write(ec.getRequestParameterValuesMap().get("someKey")[0]); // $ Alert - writer.write(ec.getRequestParameterValuesMap().keySet().iterator().next()); // $ Alert - writer.write(ec.getRequestPathInfo()); // $ Alert - writer.write(((Cookie)ec.getRequestCookieMap().get("someKey")).getName()); // $ Alert - writer.write(ec.getRequestHeaderMap().get("someKey")); // $ Alert - writer.write(ec.getRequestHeaderValuesMap().get("someKey")[0]); // $ Alert + writer.write(ec.getRequestParameterMap().keySet().iterator().next()); // $ Alert[java/xss] + writer.write(ec.getRequestParameterNames().next()); // $ Alert[java/xss] + writer.write(ec.getRequestParameterValuesMap().get("someKey")[0]); // $ Alert[java/xss] + writer.write(ec.getRequestParameterValuesMap().keySet().iterator().next()); // $ Alert[java/xss] + writer.write(ec.getRequestPathInfo()); // $ Alert[java/xss] + writer.write(((Cookie)ec.getRequestCookieMap().get("someKey")).getName()); // $ Alert[java/xss] + writer.write(ec.getRequestHeaderMap().get("someKey")); // $ Alert[java/xss] + writer.write(ec.getRequestHeaderValuesMap().get("someKey")[0]); // $ Alert[java/xss] } } diff --git a/java/ql/test/query-tests/security/CWE-079/semmle/tests/SpringXSS.java b/java/ql/test/query-tests/security/CWE-079/semmle/tests/SpringXSS.java index fd3a26bcf10..53b45c678af 100644 --- a/java/ql/test/query-tests/security/CWE-079/semmle/tests/SpringXSS.java +++ b/java/ql/test/query-tests/security/CWE-079/semmle/tests/SpringXSS.java @@ -13,17 +13,17 @@ import java.util.Optional; public class SpringXSS { @GetMapping - public static ResponseEntity specificContentType(boolean safeContentType, boolean chainDirectly, String userControlled) { // $ Source + public static ResponseEntity specificContentType(boolean safeContentType, boolean chainDirectly, String userControlled) { // $ Source[java/xss] ResponseEntity.BodyBuilder builder = ResponseEntity.ok(); if(!safeContentType) { if(chainDirectly) { - return builder.contentType(MediaType.TEXT_HTML).body(userControlled); // $ Alert + return builder.contentType(MediaType.TEXT_HTML).body(userControlled); // $ Alert[java/xss] } else { ResponseEntity.BodyBuilder builder2 = builder.contentType(MediaType.TEXT_HTML); - return builder2.body(userControlled); // $ Alert + return builder2.body(userControlled); // $ Alert[java/xss] } } else { @@ -59,23 +59,23 @@ public class SpringXSS { } @GetMapping(value = "/xyz", produces = MediaType.TEXT_HTML_VALUE) - public static ResponseEntity methodContentTypeUnsafe(String userControlled) { // $ Source - return ResponseEntity.ok(userControlled); // $ Alert + public static ResponseEntity methodContentTypeUnsafe(String userControlled) { // $ Source[java/xss] + return ResponseEntity.ok(userControlled); // $ Alert[java/xss] } @GetMapping(value = "/xyz", produces = "text/html") - public static ResponseEntity methodContentTypeUnsafeStringLiteral(String userControlled) { // $ Source - return ResponseEntity.ok(userControlled); // $ Alert + public static ResponseEntity methodContentTypeUnsafeStringLiteral(String userControlled) { // $ Source[java/xss] + return ResponseEntity.ok(userControlled); // $ Alert[java/xss] } @GetMapping(value = "/xyz", produces = {MediaType.TEXT_HTML_VALUE, MediaType.APPLICATION_JSON_VALUE}) - public static ResponseEntity methodContentTypeMaybeSafe(String userControlled) { // $ Source - return ResponseEntity.ok(userControlled); // $ Alert + public static ResponseEntity methodContentTypeMaybeSafe(String userControlled) { // $ Source[java/xss] + return ResponseEntity.ok(userControlled); // $ Alert[java/xss] } @GetMapping(value = "/xyz", produces = MediaType.APPLICATION_JSON_VALUE) - public static ResponseEntity methodContentTypeSafeOverriddenWithUnsafe(String userControlled) { // $ Source - return ResponseEntity.ok().contentType(MediaType.TEXT_HTML).body(userControlled); // $ Alert + public static ResponseEntity methodContentTypeSafeOverriddenWithUnsafe(String userControlled) { // $ Source[java/xss] + return ResponseEntity.ok().contentType(MediaType.TEXT_HTML).body(userControlled); // $ Alert[java/xss] } @GetMapping(value = "/xyz", produces = MediaType.TEXT_HTML_VALUE) @@ -84,17 +84,17 @@ public class SpringXSS { } @GetMapping(value = "/xyz", produces = {"text/html", "application/json"}) - public static ResponseEntity methodContentTypeMaybeSafeStringLiterals(String userControlled, int constructionMethod) { // $ Source + public static ResponseEntity methodContentTypeMaybeSafeStringLiterals(String userControlled, int constructionMethod) { // $ Source[java/xss] // Also try out some alternative constructors for the ResponseEntity: switch(constructionMethod) { case 0: - return ResponseEntity.ok(userControlled); // $ Alert + return ResponseEntity.ok(userControlled); // $ Alert[java/xss] case 1: - return ResponseEntity.of(Optional.of(userControlled)); // $ Alert + return ResponseEntity.of(Optional.of(userControlled)); // $ Alert[java/xss] case 2: - return ResponseEntity.ok().body(userControlled); // $ Alert + return ResponseEntity.ok().body(userControlled); // $ Alert[java/xss] case 3: - return new ResponseEntity(userControlled, HttpStatus.OK); // $ Alert + return new ResponseEntity(userControlled, HttpStatus.OK); // $ Alert[java/xss] default: return null; } @@ -114,13 +114,13 @@ public class SpringXSS { } @GetMapping(value = "/xyz", produces = {"text/html"}) - public ResponseEntity overridesWithUnsafe(String userControlled) { // $ Source - return ResponseEntity.ok(userControlled); // $ Alert + public ResponseEntity overridesWithUnsafe(String userControlled) { // $ Source[java/xss] + return ResponseEntity.ok(userControlled); // $ Alert[java/xss] } @GetMapping(value = "/abc") - public ResponseEntity overridesWithUnsafe2(String userControlled) { // $ Source - return ResponseEntity.ok().contentType(MediaType.TEXT_HTML).body(userControlled); // $ Alert + public ResponseEntity overridesWithUnsafe2(String userControlled) { // $ Source[java/xss] + return ResponseEntity.ok().contentType(MediaType.TEXT_HTML).body(userControlled); // $ Alert[java/xss] } } @@ -128,13 +128,13 @@ public class SpringXSS { @RequestMapping(produces = {"text/html"}) private static class ClassContentTypeUnsafe { @GetMapping(value = "/abc") - public ResponseEntity test(String userControlled) { // $ Source - return ResponseEntity.ok(userControlled); // $ Alert + public ResponseEntity test(String userControlled) { // $ Source[java/xss] + return ResponseEntity.ok(userControlled); // $ Alert[java/xss] } @GetMapping(value = "/abc") - public String testDirectReturn(String userControlled) { // $ Source - return userControlled; // $ Alert + public String testDirectReturn(String userControlled) { // $ Source[java/xss] + return userControlled; // $ Alert[java/xss] } @GetMapping(value = "/xyz", produces = {"application/json"}) @@ -149,13 +149,13 @@ public class SpringXSS { } @GetMapping(value = "/abc") - public static ResponseEntity entityWithNoMediaType(String userControlled) { // $ Source - return ResponseEntity.ok(userControlled); // $ Alert + public static ResponseEntity entityWithNoMediaType(String userControlled) { // $ Source[java/xss] + return ResponseEntity.ok(userControlled); // $ Alert[java/xss] } @GetMapping(value = "/abc") - public static String stringWithNoMediaType(String userControlled) { // $ Source - return userControlled; // $ Alert + public static String stringWithNoMediaType(String userControlled) { // $ Source[java/xss] + return userControlled; // $ Alert[java/xss] } @GetMapping(value = "/abc") diff --git a/java/ql/test/query-tests/security/CWE-079/semmle/tests/XSS.java b/java/ql/test/query-tests/security/CWE-079/semmle/tests/XSS.java index 13ae6b62e10..b12099673b8 100644 --- a/java/ql/test/query-tests/security/CWE-079/semmle/tests/XSS.java +++ b/java/ql/test/query-tests/security/CWE-079/semmle/tests/XSS.java @@ -16,7 +16,7 @@ public class XSS extends HttpServlet { throws ServletException, IOException { // BAD: a request parameter is written directly to the Servlet response stream response.getWriter() - .print("The page \"" + request.getParameter("page") + "\" was not found."); // $ Alert + .print("The page \"" + request.getParameter("page") + "\" was not found."); // $ Alert[java/xss] // GOOD: servlet API encodes the error message HTML for the HTML context response.sendError(HttpServletResponse.SC_NOT_FOUND, @@ -31,10 +31,10 @@ public class XSS extends HttpServlet { "The page \"" + capitalizeName(request.getParameter("page")) + "\" was not found."); // BAD: outputting the path of the resource - response.getWriter().print("The path section of the URL was " + request.getPathInfo()); // $ Alert + response.getWriter().print("The path section of the URL was " + request.getPathInfo()); // $ Alert[java/xss] // BAD: typical XSS, this time written to an OutputStream instead of a Writer - response.getOutputStream().write(request.getPathInfo().getBytes()); // $ Alert + response.getOutputStream().write(request.getPathInfo().getBytes()); // $ Alert[java/xss] // GOOD: sanitizer response.getOutputStream().write(hudson.Util.escape(request.getPathInfo()).getBytes()); // safe @@ -80,34 +80,34 @@ public class XSS extends HttpServlet { if(setContentMethod == 0) { // BAD: set content-type to something that is not safe response.setContentType("text/html"); - response.getWriter().print(request.getPathInfo()); // $ Alert + response.getWriter().print(request.getPathInfo()); // $ Alert[java/xss] } else if(setContentMethod == 1) { // BAD: set content-type to something that is not safe response.setHeader("Content-Type", "text/html"); - response.getWriter().print(request.getPathInfo()); // $ Alert + response.getWriter().print(request.getPathInfo()); // $ Alert[java/xss] } else { // BAD: set content-type to something that is not safe response.addHeader("Content-Type", "text/html"); - response.getWriter().print(request.getPathInfo()); // $ Alert + response.getWriter().print(request.getPathInfo()); // $ Alert[java/xss] } } else { if(setContentMethod == 0) { // BAD: set content-type to something that is not safe response.setContentType("text/html"); - response.getOutputStream().write(request.getPathInfo().getBytes()); // $ Alert + response.getOutputStream().write(request.getPathInfo().getBytes()); // $ Alert[java/xss] } else if(setContentMethod == 1) { // BAD: set content-type to something that is not safe response.setHeader("Content-Type", "text/html"); - response.getOutputStream().write(request.getPathInfo().getBytes()); // $ Alert + response.getOutputStream().write(request.getPathInfo().getBytes()); // $ Alert[java/xss] } else { // BAD: set content-type to something that is not safe response.addHeader("Content-Type", "text/html"); - response.getOutputStream().write(request.getPathInfo().getBytes()); // $ Alert + response.getOutputStream().write(request.getPathInfo().getBytes()); // $ Alert[java/xss] } } } diff --git a/java/ql/test/query-tests/security/CWE-094/ApkInstallationTest/ApkInstallation.java b/java/ql/test/query-tests/security/CWE-094/ApkInstallationTest/ApkInstallation.java index ee6a0c56b70..5f13a16d690 100644 --- a/java/ql/test/query-tests/security/CWE-094/ApkInstallationTest/ApkInstallation.java +++ b/java/ql/test/query-tests/security/CWE-094/ApkInstallationTest/ApkInstallation.java @@ -11,7 +11,7 @@ public class ApkInstallation extends Activity { public void installAPK(String path) { // BAD: the path is not checked Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setDataAndType(Uri.fromFile(new File(path)), "application/vnd.android.package-archive"); // $ Alert + intent.setDataAndType(Uri.fromFile(new File(path)), "application/vnd.android.package-archive"); // $ Alert[java/android/arbitrary-apk-installation] startActivity(intent); } @@ -19,7 +19,7 @@ public class ApkInstallation extends Activity { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setType(APK_MIMETYPE); // BAD: the path is not checked - intent.setData(Uri.fromFile(new File(path))); // $ Alert + intent.setData(Uri.fromFile(new File(path))); // $ Alert[java/android/arbitrary-apk-installation] startActivity(intent); } @@ -27,7 +27,7 @@ public class ApkInstallation extends Activity { // BAD: file is from external storage File file = new File(Environment.getExternalStorageDirectory(), path); Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setDataAndType(Uri.fromFile(file), APK_MIMETYPE); // $ Alert + intent.setDataAndType(Uri.fromFile(file), APK_MIMETYPE); // $ Alert[java/android/arbitrary-apk-installation] startActivity(intent); } @@ -35,14 +35,14 @@ public class ApkInstallation extends Activity { // BAD: file is from external storage File file = new File(Environment.getExternalStorageDirectory(), path); Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE); - intent.setData(Uri.fromFile(file)); // $ Alert + intent.setData(Uri.fromFile(file)); // $ Alert[java/android/arbitrary-apk-installation] startActivity(intent); } public void installAPKInstallPackageLiteral(String path) { File file = new File(Environment.getExternalStorageDirectory(), path); Intent intent = new Intent("android.intent.action.INSTALL_PACKAGE"); - intent.setData(Uri.fromFile(file)); // $ Alert + intent.setData(Uri.fromFile(file)); // $ Alert[java/android/arbitrary-apk-installation] startActivity(intent); } @@ -50,7 +50,7 @@ public class ApkInstallation extends Activity { Intent intent = new Intent(this, OtherActivity.class); intent.setAction(Intent.ACTION_VIEW); // BAD: the file is from unknown source - intent.setData(Uri.fromFile(file)); // $ Alert + intent.setData(Uri.fromFile(file)); // $ Alert[java/android/arbitrary-apk-installation] } } diff --git a/java/ql/test/query-tests/security/CWE-094/GroovyInjection/GroovyClassLoaderTest.java b/java/ql/test/query-tests/security/CWE-094/GroovyInjection/GroovyClassLoaderTest.java index ff7d73f16bd..9fd078b1ba9 100644 --- a/java/ql/test/query-tests/security/CWE-094/GroovyInjection/GroovyClassLoaderTest.java +++ b/java/ql/test/query-tests/security/CWE-094/GroovyInjection/GroovyClassLoaderTest.java @@ -14,41 +14,41 @@ public class GroovyClassLoaderTest extends HttpServlet { throws ServletException, IOException { // "groovy.lang;GroovyClassLoader;false;parseClass;(GroovyCodeSource);;Argument[0];groovy;manual", { - String script = request.getParameter("script"); // $ Source + String script = request.getParameter("script"); // $ Source[java/groovy-injection] final GroovyClassLoader classLoader = new GroovyClassLoader(); GroovyCodeSource gcs = new GroovyCodeSource(script, "test", "Test"); - classLoader.parseClass(gcs); // $ Alert + classLoader.parseClass(gcs); // $ Alert[java/groovy-injection] } // "groovy.lang;GroovyClassLoader;false;parseClass;(GroovyCodeSource,boolean);;Argument[0];groovy;manual", { - String script = request.getParameter("script"); // $ Source + String script = request.getParameter("script"); // $ Source[java/groovy-injection] final GroovyClassLoader classLoader = new GroovyClassLoader(); GroovyCodeSource gcs = new GroovyCodeSource(script, "test", "Test"); - classLoader.parseClass(gcs, true); // $ Alert + classLoader.parseClass(gcs, true); // $ Alert[java/groovy-injection] } // "groovy.lang;GroovyClassLoader;false;parseClass;(InputStream,String);;Argument[0];groovy;manual", { - String script = request.getParameter("script"); // $ Source + String script = request.getParameter("script"); // $ Source[java/groovy-injection] final GroovyClassLoader classLoader = new GroovyClassLoader(); - classLoader.parseClass(new ByteArrayInputStream(script.getBytes()), "test"); // $ Alert + classLoader.parseClass(new ByteArrayInputStream(script.getBytes()), "test"); // $ Alert[java/groovy-injection] } // "groovy.lang;GroovyClassLoader;false;parseClass;(Reader,String);;Argument[0];groovy;manual", { - String script = request.getParameter("script"); // $ Source + String script = request.getParameter("script"); // $ Source[java/groovy-injection] final GroovyClassLoader classLoader = new GroovyClassLoader(); - classLoader.parseClass(new StringReader(script), "test"); // $ Alert + classLoader.parseClass(new StringReader(script), "test"); // $ Alert[java/groovy-injection] } // "groovy.lang;GroovyClassLoader;false;parseClass;(String);;Argument[0];groovy;manual", { - String script = request.getParameter("script"); // $ Source + String script = request.getParameter("script"); // $ Source[java/groovy-injection] final GroovyClassLoader classLoader = new GroovyClassLoader(); - classLoader.parseClass(script); // $ Alert + classLoader.parseClass(script); // $ Alert[java/groovy-injection] } // "groovy.lang;GroovyClassLoader;false;parseClass;(String,String);;Argument[0];groovy;manual", { - String script = request.getParameter("script"); // $ Source + String script = request.getParameter("script"); // $ Source[java/groovy-injection] final GroovyClassLoader classLoader = new GroovyClassLoader(); - classLoader.parseClass(script, "test"); // $ Alert + classLoader.parseClass(script, "test"); // $ Alert[java/groovy-injection] } } } diff --git a/java/ql/test/query-tests/security/CWE-094/GroovyInjection/GroovyCompilationUnitTest.java b/java/ql/test/query-tests/security/CWE-094/GroovyInjection/GroovyCompilationUnitTest.java index a906d9fdc96..e5088d873af 100644 --- a/java/ql/test/query-tests/security/CWE-094/GroovyInjection/GroovyCompilationUnitTest.java +++ b/java/ql/test/query-tests/security/CWE-094/GroovyInjection/GroovyCompilationUnitTest.java @@ -18,8 +18,8 @@ public class GroovyCompilationUnitTest extends HttpServlet { // "org.codehaus.groovy.control;CompilationUnit;false;compile;;;Argument[this];groovy;manual" { CompilationUnit cu = new CompilationUnit(); - cu.addSource("test", request.getParameter("source")); // $ Source - cu.compile(); // $ Alert + cu.addSource("test", request.getParameter("source")); // $ Source[java/groovy-injection] + cu.compile(); // $ Alert[java/groovy-injection] } { CompilationUnit cu = new CompilationUnit(); @@ -29,20 +29,20 @@ public class GroovyCompilationUnitTest extends HttpServlet { { CompilationUnit cu = new CompilationUnit(); cu.addSource("test", - new ByteArrayInputStream(request.getParameter("source").getBytes())); // $ Source - cu.compile(); // $ Alert + new ByteArrayInputStream(request.getParameter("source").getBytes())); // $ Source[java/groovy-injection] + cu.compile(); // $ Alert[java/groovy-injection] } { CompilationUnit cu = new CompilationUnit(); - cu.addSource(new URL(request.getParameter("source"))); // $ Source - cu.compile(); // $ Alert + cu.addSource(new URL(request.getParameter("source"))); // $ Source[java/groovy-injection] + cu.compile(); // $ Alert[java/groovy-injection] } { CompilationUnit cu = new CompilationUnit(); SourceUnit su = - new SourceUnit("test", request.getParameter("source"), null, null, null); // $ Source + new SourceUnit("test", request.getParameter("source"), null, null, null); // $ Source[java/groovy-injection] cu.addSource(su); - cu.compile(); // $ Alert + cu.compile(); // $ Alert[java/groovy-injection] } { CompilationUnit cu = new CompilationUnit(); @@ -53,29 +53,29 @@ public class GroovyCompilationUnitTest extends HttpServlet { } { CompilationUnit cu = new CompilationUnit(); - StringReaderSource rs = new StringReaderSource(request.getParameter("source"), null); // $ Source + StringReaderSource rs = new StringReaderSource(request.getParameter("source"), null); // $ Source[java/groovy-injection] SourceUnit su = new SourceUnit("test", rs, null, null, null); cu.addSource(su); - cu.compile(); // $ Alert + cu.compile(); // $ Alert[java/groovy-injection] } { CompilationUnit cu = new CompilationUnit(); SourceUnit su = - new SourceUnit(new URL(request.getParameter("source")), null, null, null); // $ Source + new SourceUnit(new URL(request.getParameter("source")), null, null, null); // $ Source[java/groovy-injection] cu.addSource(su); - cu.compile(); // $ Alert + cu.compile(); // $ Alert[java/groovy-injection] } { CompilationUnit cu = new CompilationUnit(); - SourceUnit su = SourceUnit.create("test", request.getParameter("source")); // $ Source + SourceUnit su = SourceUnit.create("test", request.getParameter("source")); // $ Source[java/groovy-injection] cu.addSource(su); - cu.compile(); // $ Alert + cu.compile(); // $ Alert[java/groovy-injection] } { CompilationUnit cu = new CompilationUnit(); - SourceUnit su = SourceUnit.create("test", request.getParameter("source"), 0); // $ Source + SourceUnit su = SourceUnit.create("test", request.getParameter("source"), 0); // $ Source[java/groovy-injection] cu.addSource(su); - cu.compile(); // $ Alert + cu.compile(); // $ Alert[java/groovy-injection] } { CompilationUnit cu = new CompilationUnit(); @@ -85,8 +85,8 @@ public class GroovyCompilationUnitTest extends HttpServlet { } { JavaAwareCompilationUnit cu = new JavaAwareCompilationUnit(); - cu.addSource("test", request.getParameter("source")); // $ Source - cu.compile(); // $ Alert + cu.addSource("test", request.getParameter("source")); // $ Source[java/groovy-injection] + cu.compile(); // $ Alert[java/groovy-injection] } { JavaStubCompilationUnit cu = new JavaStubCompilationUnit(null, null); diff --git a/java/ql/test/query-tests/security/CWE-094/GroovyInjection/GroovyEvalTest.java b/java/ql/test/query-tests/security/CWE-094/GroovyInjection/GroovyEvalTest.java index 3756cd10bfa..704a225c670 100644 --- a/java/ql/test/query-tests/security/CWE-094/GroovyInjection/GroovyEvalTest.java +++ b/java/ql/test/query-tests/security/CWE-094/GroovyInjection/GroovyEvalTest.java @@ -11,29 +11,29 @@ public class GroovyEvalTest extends HttpServlet { throws ServletException, IOException { // "groovy.util;Eval;false;me;(String);;Argument[0];groovy;manual", { - String script = request.getParameter("script"); // $ Source - Eval.me(script); // $ Alert + String script = request.getParameter("script"); // $ Source[java/groovy-injection] + Eval.me(script); // $ Alert[java/groovy-injection] } // "groovy.util;Eval;false;me;(String,Object,String);;Argument[2];groovy;manual", { - String script = request.getParameter("script"); // $ Source - Eval.me("test", "result", script); // $ Alert + String script = request.getParameter("script"); // $ Source[java/groovy-injection] + Eval.me("test", "result", script); // $ Alert[java/groovy-injection] } // "groovy.util;Eval;false;x;(Object,String);;Argument[1];groovy;manual", { - String script = request.getParameter("script"); // $ Source - Eval.x("result2", script); // $ Alert + String script = request.getParameter("script"); // $ Source[java/groovy-injection] + Eval.x("result2", script); // $ Alert[java/groovy-injection] } // "groovy.util;Eval;false;xy;(Object,Object,String);;Argument[2];groovy;manual", { - String script = request.getParameter("script"); // $ Source - Eval.xy("result3", "result4", script); // $ Alert + String script = request.getParameter("script"); // $ Source[java/groovy-injection] + Eval.xy("result3", "result4", script); // $ Alert[java/groovy-injection] } // "groovy.util;Eval;false;xyz;(Object,Object,Object,String);;Argument[3];groovy;manual", { - String script = request.getParameter("script"); // $ Source - Eval.xyz("result3", "result4", "aaa", script); // $ Alert + String script = request.getParameter("script"); // $ Source[java/groovy-injection] + Eval.xyz("result3", "result4", "aaa", script); // $ Alert[java/groovy-injection] } } } diff --git a/java/ql/test/query-tests/security/CWE-094/GroovyInjection/GroovyShellTest.java b/java/ql/test/query-tests/security/CWE-094/GroovyInjection/GroovyShellTest.java index 6e2e773b03c..aa26691c019 100644 --- a/java/ql/test/query-tests/security/CWE-094/GroovyInjection/GroovyShellTest.java +++ b/java/ql/test/query-tests/security/CWE-094/GroovyInjection/GroovyShellTest.java @@ -19,134 +19,134 @@ public class GroovyShellTest extends HttpServlet { // "groovy.lang;GroovyShell;false;evaluate;(GroovyCodeSource);;Argument[0];groovy;manual", { GroovyShell shell = new GroovyShell(); - String script = request.getParameter("script"); // $ Source + String script = request.getParameter("script"); // $ Source[java/groovy-injection] GroovyCodeSource gcs = new GroovyCodeSource(script, "test", "Test"); - shell.evaluate(gcs); // $ Alert + shell.evaluate(gcs); // $ Alert[java/groovy-injection] } // "groovy.lang;GroovyShell;false;evaluate;(Reader);;Argument[0];groovy;manual", { GroovyShell shell = new GroovyShell(); - String script = request.getParameter("script"); // $ Source + String script = request.getParameter("script"); // $ Source[java/groovy-injection] Reader reader = new StringReader(script); - shell.evaluate(reader); // $ Alert + shell.evaluate(reader); // $ Alert[java/groovy-injection] } // "groovy.lang;GroovyShell;false;evaluate;(Reader,String);;Argument[0];groovy;manual", { GroovyShell shell = new GroovyShell(); - String script = request.getParameter("script"); // $ Source + String script = request.getParameter("script"); // $ Source[java/groovy-injection] Reader reader = new StringReader(script); - shell.evaluate(reader, "_"); // $ Alert + shell.evaluate(reader, "_"); // $ Alert[java/groovy-injection] } // "groovy.lang;GroovyShell;false;evaluate;(String);;Argument[0];groovy;manual", { GroovyShell shell = new GroovyShell(); - String script = request.getParameter("script"); // $ Source - shell.evaluate(script); // $ Alert + String script = request.getParameter("script"); // $ Source[java/groovy-injection] + shell.evaluate(script); // $ Alert[java/groovy-injection] } // "groovy.lang;GroovyShell;false;evaluate;(String,String);;Argument[0];groovy;manual", { GroovyShell shell = new GroovyShell(); - String script = request.getParameter("script"); // $ Source - shell.evaluate(script, "test"); // $ Alert + String script = request.getParameter("script"); // $ Source[java/groovy-injection] + shell.evaluate(script, "test"); // $ Alert[java/groovy-injection] } // "groovy.lang;GroovyShell;false;evaluate;(String,String,String);;Argument[0];groovy;manual", { GroovyShell shell = new GroovyShell(); - String script = request.getParameter("script"); // $ Source - shell.evaluate(script, "test", "test2"); // $ Alert + String script = request.getParameter("script"); // $ Source[java/groovy-injection] + shell.evaluate(script, "test", "test2"); // $ Alert[java/groovy-injection] } // "groovy.lang;GroovyShell;false;evaluate;(URI);;Argument[0];groovy;manual", try { GroovyShell shell = new GroovyShell(); - String script = request.getParameter("script"); // $ Source - shell.parse(new URI(script)); // $ Alert + String script = request.getParameter("script"); // $ Source[java/groovy-injection] + shell.parse(new URI(script)); // $ Alert[java/groovy-injection] } catch (URISyntaxException e) { } // "groovy.lang;GroovyShell;false;parse;(Reader);;Argument[0];groovy;manual", { GroovyShell shell = new GroovyShell(); - String script = request.getParameter("script"); // $ Source + String script = request.getParameter("script"); // $ Source[java/groovy-injection] Reader reader = new StringReader(script); - shell.parse(reader); // $ Alert + shell.parse(reader); // $ Alert[java/groovy-injection] } // "groovy.lang;GroovyShell;false;parse;(Reader,String);;Argument[0];groovy;manual", { GroovyShell shell = new GroovyShell(); - String script = request.getParameter("script"); // $ Source + String script = request.getParameter("script"); // $ Source[java/groovy-injection] Reader reader = new StringReader(script); - shell.parse(reader, "_"); // $ Alert + shell.parse(reader, "_"); // $ Alert[java/groovy-injection] } // "groovy.lang;GroovyShell;false;parse;(String);;Argument[0];groovy;manual", { GroovyShell shell = new GroovyShell(); - String script = request.getParameter("script"); // $ Source - shell.parse(script); // $ Alert + String script = request.getParameter("script"); // $ Source[java/groovy-injection] + shell.parse(script); // $ Alert[java/groovy-injection] } // "groovy.lang;GroovyShell;false;parse;(String,String);;Argument[0];groovy;manual", { GroovyShell shell = new GroovyShell(); - String script = request.getParameter("script"); // $ Source - shell.parse(script, "_"); // $ Alert + String script = request.getParameter("script"); // $ Source[java/groovy-injection] + shell.parse(script, "_"); // $ Alert[java/groovy-injection] } // "groovy.lang;GroovyShell;false;parse;(URI);;Argument[0];groovy;manual", try { GroovyShell shell = new GroovyShell(); - String script = request.getParameter("script"); // $ Source - shell.parse(new URI(script)); // $ Alert + String script = request.getParameter("script"); // $ Source[java/groovy-injection] + shell.parse(new URI(script)); // $ Alert[java/groovy-injection] } catch (URISyntaxException e) { } // "groovy.lang;GroovyShell;false;run;(GroovyCodeSource,String[]);;Argument[0];groovy;manual", { GroovyShell shell = new GroovyShell(); - String script = request.getParameter("script"); // $ Source + String script = request.getParameter("script"); // $ Source[java/groovy-injection] GroovyCodeSource gcs = new GroovyCodeSource(script, "test", "Test"); - shell.run(gcs, new String[] {}); // $ Alert + shell.run(gcs, new String[] {}); // $ Alert[java/groovy-injection] } // "groovy.lang;GroovyShell;false;run;(GroovyCodeSource,List);;Argument[0];groovy;manual", { GroovyShell shell = new GroovyShell(); - String script = request.getParameter("script"); // $ Source + String script = request.getParameter("script"); // $ Source[java/groovy-injection] GroovyCodeSource gcs = new GroovyCodeSource(script, "test", "Test"); - shell.run(gcs, new ArrayList()); // $ Alert + shell.run(gcs, new ArrayList()); // $ Alert[java/groovy-injection] } // "groovy.lang;GroovyShell;false;run;(Reader,String,String[]);;Argument[0];groovy;manual", { GroovyShell shell = new GroovyShell(); - String script = request.getParameter("script"); // $ Source + String script = request.getParameter("script"); // $ Source[java/groovy-injection] Reader reader = new StringReader(script); - shell.run(reader, "test", new String[] {}); // $ Alert + shell.run(reader, "test", new String[] {}); // $ Alert[java/groovy-injection] } // "groovy.lang;GroovyShell;false;run;(Reader,String,List);;Argument[0];groovy;manual", { GroovyShell shell = new GroovyShell(); - String script = request.getParameter("script"); // $ Source + String script = request.getParameter("script"); // $ Source[java/groovy-injection] Reader reader = new StringReader(script); - shell.run(reader, "test", new ArrayList()); // $ Alert + shell.run(reader, "test", new ArrayList()); // $ Alert[java/groovy-injection] } // "groovy.lang;GroovyShell;false;run;(String,String,String[]);;Argument[0];groovy;manual", { GroovyShell shell = new GroovyShell(); - String script = request.getParameter("script"); // $ Source - shell.run(script, "_", new String[] {}); // $ Alert + String script = request.getParameter("script"); // $ Source[java/groovy-injection] + shell.run(script, "_", new String[] {}); // $ Alert[java/groovy-injection] } // "groovy.lang;GroovyShell;false;run;(String,String,List);;Argument[0];groovy;manual", { GroovyShell shell = new GroovyShell(); - String script = request.getParameter("script"); // $ Source - shell.run(script, "_", new ArrayList()); // $ Alert + String script = request.getParameter("script"); // $ Source[java/groovy-injection] + shell.run(script, "_", new ArrayList()); // $ Alert[java/groovy-injection] } // "groovy.lang;GroovyShell;false;run;(URI,String[]);;Argument[0];groovy;manual", try { GroovyShell shell = new GroovyShell(); - String script = request.getParameter("script"); // $ Source - shell.run(new URI(script), new String[] {}); // $ Alert + String script = request.getParameter("script"); // $ Source[java/groovy-injection] + shell.run(new URI(script), new String[] {}); // $ Alert[java/groovy-injection] } catch (URISyntaxException e) { } // "groovy.lang;GroovyShell;false;run;(URI,List);;Argument[0];groovy;manual", try { GroovyShell shell = new GroovyShell(); - String script = request.getParameter("script"); // $ Source - shell.run(new URI(script), new ArrayList()); // $ Alert + String script = request.getParameter("script"); // $ Source[java/groovy-injection] + shell.run(new URI(script), new ArrayList()); // $ Alert[java/groovy-injection] } catch (URISyntaxException e) { } } diff --git a/java/ql/test/query-tests/security/CWE-094/GroovyInjection/TemplateEngineTest.java b/java/ql/test/query-tests/security/CWE-094/GroovyInjection/TemplateEngineTest.java index a046b9cd332..77519656614 100644 --- a/java/ql/test/query-tests/security/CWE-094/GroovyInjection/TemplateEngineTest.java +++ b/java/ql/test/query-tests/security/CWE-094/GroovyInjection/TemplateEngineTest.java @@ -11,7 +11,7 @@ import groovy.text.TemplateEngine; public class TemplateEngineTest extends HttpServlet { private Object source(HttpServletRequest request) { - return request.getParameter("script"); // $ Source + return request.getParameter("script"); // $ Source[java/groovy-injection] } protected void doGet(HttpServletRequest request, HttpServletResponse response) @@ -19,10 +19,10 @@ public class TemplateEngineTest extends HttpServlet { try { Object script = source(request); TemplateEngine engine = null; - engine.createTemplate(request.getParameter("script")); // $ Alert - engine.createTemplate((File) script); // $ Alert - engine.createTemplate((Reader) script); // $ Alert - engine.createTemplate((URL) script); // $ Alert + engine.createTemplate(request.getParameter("script")); // $ Alert[java/groovy-injection] + engine.createTemplate((File) script); // $ Alert[java/groovy-injection] + engine.createTemplate((Reader) script); // $ Alert[java/groovy-injection] + engine.createTemplate((URL) script); // $ Alert[java/groovy-injection] } catch (Exception e) { } diff --git a/java/ql/test/query-tests/security/CWE-094/InsecureBeanValidation.java b/java/ql/test/query-tests/security/CWE-094/InsecureBeanValidation.java index bfa94bbe3a8..fb840759b62 100644 --- a/java/ql/test/query-tests/security/CWE-094/InsecureBeanValidation.java +++ b/java/ql/test/query-tests/security/CWE-094/InsecureBeanValidation.java @@ -4,11 +4,11 @@ import javax.validation.ConstraintValidatorContext; public class InsecureBeanValidation implements ConstraintValidator { @Override - public boolean isValid(String object, ConstraintValidatorContext constraintContext) { // $ Source + public boolean isValid(String object, ConstraintValidatorContext constraintContext) { // $ Source[java/insecure-bean-validation] String value = object + " is invalid"; // Bad: Bean properties (normally user-controlled) are passed directly to `buildConstraintViolationWithTemplate` - constraintContext.buildConstraintViolationWithTemplate(value).addConstraintViolation().disableDefaultConstraintViolation(); // $ Alert + constraintContext.buildConstraintViolationWithTemplate(value).addConstraintViolation().disableDefaultConstraintViolation(); // $ Alert[java/insecure-bean-validation] // Good: Using message parameters constraintContext.buildConstraintViolationWithTemplate("literal {message_parameter}").addConstraintViolation().disableDefaultConstraintViolation(); diff --git a/java/ql/test/query-tests/security/CWE-094/JexlInjection/Jexl2Injection.java b/java/ql/test/query-tests/security/CWE-094/JexlInjection/Jexl2Injection.java index b306cf4e535..ab5a6b179a5 100644 --- a/java/ql/test/query-tests/security/CWE-094/JexlInjection/Jexl2Injection.java +++ b/java/ql/test/query-tests/security/CWE-094/JexlInjection/Jexl2Injection.java @@ -11,21 +11,21 @@ public class Jexl2Injection { JexlEngine jexl = new JexlEngine(); Expression e = jexl.createExpression(jexlExpr); JexlContext jc = new MapContext(); - e.evaluate(jc); // $ Alert + e.evaluate(jc); // $ Alert[java/jexl-expression-injection] } private static void runJexlExpressionWithJexlInfo(String jexlExpr) { JexlEngine jexl = new JexlEngine(); Expression e = jexl.createExpression(jexlExpr, new DebugInfo("unknown", 0, 0)); JexlContext jc = new MapContext(); - e.evaluate(jc); // $ Alert + e.evaluate(jc); // $ Alert[java/jexl-expression-injection] } private static void runJexlScript(String jexlExpr) { JexlEngine jexl = new JexlEngine(); Script script = jexl.createScript(jexlExpr); JexlContext jc = new MapContext(); - script.execute(jc); // $ Alert + script.execute(jc); // $ Alert[java/jexl-expression-injection] } private static void runJexlScriptViaCallable(String jexlExpr) { @@ -34,7 +34,7 @@ public class Jexl2Injection { JexlContext jc = new MapContext(); try { - script.callable(jc).call(); // $ Alert + script.callable(jc).call(); // $ Alert[java/jexl-expression-injection] } catch (Exception e) { throw new RuntimeException(e); } @@ -42,37 +42,37 @@ public class Jexl2Injection { private static void runJexlExpressionViaGetProperty(String jexlExpr) { JexlEngine jexl = new JexlEngine(); - jexl.getProperty(new Object(), jexlExpr); // $ Alert + jexl.getProperty(new Object(), jexlExpr); // $ Alert[java/jexl-expression-injection] } private static void runJexlExpressionViaSetProperty(String jexlExpr) { JexlEngine jexl = new JexlEngine(); - jexl.setProperty(new Object(), jexlExpr, new Object()); // $ Alert + jexl.setProperty(new Object(), jexlExpr, new Object()); // $ Alert[java/jexl-expression-injection] } private static void runJexlExpressionViaUnifiedJEXLParseAndEvaluate(String jexlExpr) { JexlEngine jexl = new JexlEngine(); UnifiedJEXL unifiedJEXL = new UnifiedJEXL(jexl); - unifiedJEXL.parse(jexlExpr).evaluate(new MapContext()); // $ Alert + unifiedJEXL.parse(jexlExpr).evaluate(new MapContext()); // $ Alert[java/jexl-expression-injection] } private static void runJexlExpressionViaUnifiedJEXLParseAndPrepare(String jexlExpr) { JexlEngine jexl = new JexlEngine(); UnifiedJEXL unifiedJEXL = new UnifiedJEXL(jexl); - unifiedJEXL.parse(jexlExpr).prepare(new MapContext()); // $ Alert + unifiedJEXL.parse(jexlExpr).prepare(new MapContext()); // $ Alert[java/jexl-expression-injection] } private static void runJexlExpressionViaUnifiedJEXLTemplateEvaluate(String jexlExpr) { JexlEngine jexl = new JexlEngine(); UnifiedJEXL unifiedJEXL = new UnifiedJEXL(jexl); - unifiedJEXL.createTemplate(jexlExpr).evaluate(new MapContext(), new StringWriter()); // $ Alert + unifiedJEXL.createTemplate(jexlExpr).evaluate(new MapContext(), new StringWriter()); // $ Alert[java/jexl-expression-injection] } private static void testWithSocket(Consumer action) throws Exception { try (ServerSocket serverSocket = new ServerSocket(0)) { try (Socket socket = serverSocket.accept()) { byte[] bytes = new byte[1024]; - int n = socket.getInputStream().read(bytes); // $ Source + int n = socket.getInputStream().read(bytes); // $ Source[java/jexl-expression-injection] String jexlExpr = new String(bytes, 0, n); action.accept(jexlExpr); } diff --git a/java/ql/test/query-tests/security/CWE-094/JexlInjection/Jexl3Injection.java b/java/ql/test/query-tests/security/CWE-094/JexlInjection/Jexl3Injection.java index c047bb5b315..04e0f9a5e53 100644 --- a/java/ql/test/query-tests/security/CWE-094/JexlInjection/Jexl3Injection.java +++ b/java/ql/test/query-tests/security/CWE-094/JexlInjection/Jexl3Injection.java @@ -18,21 +18,21 @@ public class Jexl3Injection { JexlEngine jexl = new JexlBuilder().create(); JexlExpression e = jexl.createExpression(jexlExpr); JexlContext jc = new MapContext(); - e.evaluate(jc); // $ Alert + e.evaluate(jc); // $ Alert[java/jexl-expression-injection] } private static void runJexlExpressionWithJexlInfo(String jexlExpr) { JexlEngine jexl = new JexlBuilder().create(); JexlExpression e = jexl.createExpression(new JexlInfo("unknown", 0, 0), jexlExpr); JexlContext jc = new MapContext(); - e.evaluate(jc); // $ Alert + e.evaluate(jc); // $ Alert[java/jexl-expression-injection] } private static void runJexlScript(String jexlExpr) { JexlEngine jexl = new JexlBuilder().create(); JexlScript script = jexl.createScript(jexlExpr); JexlContext jc = new MapContext(); - script.execute(jc); // $ Alert + script.execute(jc); // $ Alert[java/jexl-expression-injection] } private static void runJexlScriptViaCallable(String jexlExpr) { @@ -41,7 +41,7 @@ public class Jexl3Injection { JexlContext jc = new MapContext(); try { - script.callable(jc).call(); // $ Alert + script.callable(jc).call(); // $ Alert[java/jexl-expression-injection] } catch (Exception e) { throw new RuntimeException(e); } @@ -49,30 +49,30 @@ public class Jexl3Injection { private static void runJexlExpressionViaGetProperty(String jexlExpr) { JexlEngine jexl = new JexlBuilder().create(); - jexl.getProperty(new Object(), jexlExpr); // $ Alert + jexl.getProperty(new Object(), jexlExpr); // $ Alert[java/jexl-expression-injection] } private static void runJexlExpressionViaSetProperty(String jexlExpr) { JexlEngine jexl = new JexlBuilder().create(); - jexl.setProperty(new Object(), jexlExpr, new Object()); // $ Alert + jexl.setProperty(new Object(), jexlExpr, new Object()); // $ Alert[java/jexl-expression-injection] } private static void runJexlExpressionViaJxltEngineExpressionEvaluate(String jexlExpr) { JexlEngine jexl = new JexlBuilder().create(); JxltEngine jxlt = jexl.createJxltEngine(); - jxlt.createExpression(jexlExpr).evaluate(new MapContext()); // $ Alert + jxlt.createExpression(jexlExpr).evaluate(new MapContext()); // $ Alert[java/jexl-expression-injection] } private static void runJexlExpressionViaJxltEngineExpressionPrepare(String jexlExpr) { JexlEngine jexl = new JexlBuilder().create(); JxltEngine jxlt = jexl.createJxltEngine(); - jxlt.createExpression(jexlExpr).prepare(new MapContext()); // $ Alert + jxlt.createExpression(jexlExpr).prepare(new MapContext()); // $ Alert[java/jexl-expression-injection] } private static void runJexlExpressionViaJxltEngineTemplateEvaluate(String jexlExpr) { JexlEngine jexl = new JexlBuilder().create(); JxltEngine jxlt = jexl.createJxltEngine(); - jxlt.createTemplate(jexlExpr).evaluate(new MapContext(), new StringWriter()); // $ Alert + jxlt.createTemplate(jexlExpr).evaluate(new MapContext(), new StringWriter()); // $ Alert[java/jexl-expression-injection] } private static void runJexlExpressionViaCallable(String jexlExpr) { @@ -81,7 +81,7 @@ public class Jexl3Injection { JexlContext jc = new MapContext(); try { - e.callable(jc).call(); // $ Alert + e.callable(jc).call(); // $ Alert[java/jexl-expression-injection] } catch (Exception ex) { throw new RuntimeException(ex); } @@ -91,7 +91,7 @@ public class Jexl3Injection { try (ServerSocket serverSocket = new ServerSocket(0)) { try (Socket socket = serverSocket.accept()) { byte[] bytes = new byte[1024]; - int n = socket.getInputStream().read(bytes); // $ Source + int n = socket.getInputStream().read(bytes); // $ Source[java/jexl-expression-injection] String jexlExpr = new String(bytes, 0, n); action.accept(jexlExpr); } @@ -141,14 +141,14 @@ public class Jexl3Injection { } @PostMapping("/request") - public ResponseEntity testWithSpringControllerThatEvaluatesJexlFromPathVariable(@PathVariable String expr) { // $ Source + public ResponseEntity testWithSpringControllerThatEvaluatesJexlFromPathVariable(@PathVariable String expr) { // $ Source[java/jexl-expression-injection] runJexlExpression(expr); return ResponseEntity.ok(HttpStatus.OK); } @PostMapping("/request") - public ResponseEntity testWithSpringControllerThatEvaluatesJexlFromRequestBody(@RequestBody Data data) { // $ Source + public ResponseEntity testWithSpringControllerThatEvaluatesJexlFromRequestBody(@RequestBody Data data) { // $ Source[java/jexl-expression-injection] String expr = data.getExpr(); runJexlExpression(expr); @@ -158,7 +158,7 @@ public class Jexl3Injection { @PostMapping("/request") public ResponseEntity testWithSpringControllerThatEvaluatesJexlFromRequestBodyWithNestedObjects( - @RequestBody CustomRequest customRequest) { // $ Source + @RequestBody CustomRequest customRequest) { // $ Source[java/jexl-expression-injection] String expr = customRequest.getData().getExpr(); runJexlExpression(expr); diff --git a/java/ql/test/query-tests/security/CWE-094/MvelInjection/MvelInjectionTest.java b/java/ql/test/query-tests/security/CWE-094/MvelInjection/MvelInjectionTest.java index 4e6738dbfd9..b661732cc37 100644 --- a/java/ql/test/query-tests/security/CWE-094/MvelInjection/MvelInjectionTest.java +++ b/java/ql/test/query-tests/security/CWE-094/MvelInjection/MvelInjectionTest.java @@ -21,31 +21,31 @@ import org.mvel2.templates.TemplateRuntime; public class MvelInjectionTest { public static void testWithMvelEval(Socket socket) throws IOException { - MVEL.eval(read(socket)); // $ Alert + MVEL.eval(read(socket)); // $ Alert[java/mvel-expression-injection] } public static void testWithMvelCompileAndExecute(Socket socket) throws IOException { Serializable expression = MVEL.compileExpression(read(socket)); - MVEL.executeExpression(expression); // $ Alert + MVEL.executeExpression(expression); // $ Alert[java/mvel-expression-injection] } public static void testWithExpressionCompiler(Socket socket) throws IOException { ExpressionCompiler compiler = new ExpressionCompiler(read(socket)); ExecutableStatement statement = compiler.compile(); - statement.getValue(new Object(), new ImmutableDefaultFactory()); // $ Alert - statement.getValue(new Object(), new Object(), new ImmutableDefaultFactory()); // $ Alert + statement.getValue(new Object(), new ImmutableDefaultFactory()); // $ Alert[java/mvel-expression-injection] + statement.getValue(new Object(), new Object(), new ImmutableDefaultFactory()); // $ Alert[java/mvel-expression-injection] } public static void testWithCompiledExpressionGetDirectValue(Socket socket) throws IOException { ExpressionCompiler compiler = new ExpressionCompiler(read(socket)); CompiledExpression expression = compiler.compile(); - expression.getDirectValue(new Object(), new ImmutableDefaultFactory()); // $ Alert + expression.getDirectValue(new Object(), new ImmutableDefaultFactory()); // $ Alert[java/mvel-expression-injection] } public static void testCompiledAccExpressionGetValue(Socket socket) throws IOException { CompiledAccExpression expression = new CompiledAccExpression(read(socket).toCharArray(), Object.class, new ParserContext()); - expression.getValue(new Object(), new ImmutableDefaultFactory()); // $ Alert + expression.getValue(new Object(), new ImmutableDefaultFactory()); // $ Alert[java/mvel-expression-injection] } public static void testMvelScriptEngineCompileAndEvaluate(Socket socket) throws Exception { @@ -53,10 +53,10 @@ public class MvelInjectionTest { MvelScriptEngine engine = new MvelScriptEngine(); CompiledScript compiledScript = engine.compile(input); - compiledScript.eval(); // $ Alert + compiledScript.eval(); // $ Alert[java/mvel-expression-injection] Serializable script = engine.compiledScript(input); - engine.evaluate(script, new SimpleScriptContext()); // $ Alert + engine.evaluate(script, new SimpleScriptContext()); // $ Alert[java/mvel-expression-injection] } public static void testMvelCompiledScriptCompileAndEvaluate(Socket socket) throws Exception { @@ -64,30 +64,30 @@ public class MvelInjectionTest { ExpressionCompiler compiler = new ExpressionCompiler(read(socket)); ExecutableStatement statement = compiler.compile(); MvelCompiledScript script = new MvelCompiledScript(engine, statement); - script.eval(new SimpleScriptContext()); // $ Alert + script.eval(new SimpleScriptContext()); // $ Alert[java/mvel-expression-injection] } public static void testTemplateRuntimeEval(Socket socket) throws Exception { - TemplateRuntime.eval(read(socket), new HashMap()); // $ Alert + TemplateRuntime.eval(read(socket), new HashMap()); // $ Alert[java/mvel-expression-injection] } public static void testTemplateRuntimeCompileTemplateAndExecute(Socket socket) throws Exception { - TemplateRuntime.execute(TemplateCompiler.compileTemplate(read(socket)), new HashMap()); // $ Alert + TemplateRuntime.execute(TemplateCompiler.compileTemplate(read(socket)), new HashMap()); // $ Alert[java/mvel-expression-injection] } public static void testTemplateRuntimeCompileAndExecute(Socket socket) throws Exception { TemplateCompiler compiler = new TemplateCompiler(read(socket)); - TemplateRuntime.execute(compiler.compile(), new HashMap()); // $ Alert + TemplateRuntime.execute(compiler.compile(), new HashMap()); // $ Alert[java/mvel-expression-injection] } public static void testMvelRuntimeExecute(Socket socket) throws Exception { ExpressionCompiler compiler = new ExpressionCompiler(read(socket)); CompiledExpression expression = compiler.compile(); - MVELRuntime.execute(false, expression, new Object(), new ImmutableDefaultFactory()); // $ Alert + MVELRuntime.execute(false, expression, new Object(), new ImmutableDefaultFactory()); // $ Alert[java/mvel-expression-injection] } public static String read(Socket socket) throws IOException { - try (InputStream is = socket.getInputStream()) { // $ Source + try (InputStream is = socket.getInputStream()) { // $ Source[java/mvel-expression-injection] byte[] bytes = new byte[1024]; int n = is.read(bytes); return new String(bytes, 0, n); diff --git a/java/ql/test/query-tests/security/CWE-094/SpelInjection/SpelInjectionTest.java b/java/ql/test/query-tests/security/CWE-094/SpelInjection/SpelInjectionTest.java index 88c4e913d49..17bf732d547 100644 --- a/java/ql/test/query-tests/security/CWE-094/SpelInjection/SpelInjectionTest.java +++ b/java/ql/test/query-tests/security/CWE-094/SpelInjection/SpelInjectionTest.java @@ -13,7 +13,7 @@ public class SpelInjectionTest { private static final ExpressionParser PARSER = new SpelExpressionParser(); public void testGetValue(Socket socket) throws IOException { - InputStream in = socket.getInputStream(); // $ Source + InputStream in = socket.getInputStream(); // $ Source[java/spel-expression-injection] byte[] bytes = new byte[1024]; int n = in.read(bytes); @@ -21,33 +21,33 @@ public class SpelInjectionTest { ExpressionParser parser = new SpelExpressionParser(); Expression expression = parser.parseExpression(input); - expression.getValue(); // $ Alert + expression.getValue(); // $ Alert[java/spel-expression-injection] } public void testGetValueWithParseRaw(Socket socket) throws IOException { - InputStream in = socket.getInputStream(); // $ Source + InputStream in = socket.getInputStream(); // $ Source[java/spel-expression-injection] byte[] bytes = new byte[1024]; int n = in.read(bytes); String input = new String(bytes, 0, n); SpelExpressionParser parser = new SpelExpressionParser(); SpelExpression expression = parser.parseRaw(input); - expression.getValue(); // $ Alert + expression.getValue(); // $ Alert[java/spel-expression-injection] } public void testGetValueWithChainedCalls(Socket socket) throws IOException { - InputStream in = socket.getInputStream(); // $ Source + InputStream in = socket.getInputStream(); // $ Source[java/spel-expression-injection] byte[] bytes = new byte[1024]; int n = in.read(bytes); String input = new String(bytes, 0, n); Expression expression = new SpelExpressionParser().parseExpression(input); - expression.getValue(); // $ Alert + expression.getValue(); // $ Alert[java/spel-expression-injection] } public void testSetValueWithRootObject(Socket socket) throws IOException { - InputStream in = socket.getInputStream(); // $ Source + InputStream in = socket.getInputStream(); // $ Source[java/spel-expression-injection] byte[] bytes = new byte[1024]; int n = in.read(bytes); @@ -57,33 +57,33 @@ public class SpelInjectionTest { Object root = new Object(); Object value = new Object(); - expression.setValue(root, value); // $ Alert + expression.setValue(root, value); // $ Alert[java/spel-expression-injection] } public void testGetValueWithStaticParser(Socket socket) throws IOException { - InputStream in = socket.getInputStream(); // $ Source + InputStream in = socket.getInputStream(); // $ Source[java/spel-expression-injection] byte[] bytes = new byte[1024]; int n = in.read(bytes); String input = new String(bytes, 0, n); Expression expression = PARSER.parseExpression(input); - expression.getValue(); // $ Alert + expression.getValue(); // $ Alert[java/spel-expression-injection] } public void testGetValueType(Socket socket) throws IOException { - InputStream in = socket.getInputStream(); // $ Source + InputStream in = socket.getInputStream(); // $ Source[java/spel-expression-injection] byte[] bytes = new byte[1024]; int n = in.read(bytes); String input = new String(bytes, 0, n); Expression expression = PARSER.parseExpression(input); - expression.getValueType(); // $ Alert + expression.getValueType(); // $ Alert[java/spel-expression-injection] } public void testWithStandardEvaluationContext(Socket socket) throws IOException { - InputStream in = socket.getInputStream(); // $ Source + InputStream in = socket.getInputStream(); // $ Source[java/spel-expression-injection] byte[] bytes = new byte[1024]; int n = in.read(bytes); @@ -92,7 +92,7 @@ public class SpelInjectionTest { Expression expression = PARSER.parseExpression(input); StandardEvaluationContext context = new StandardEvaluationContext(); - expression.getValue(context); // $ Alert + expression.getValue(context); // $ Alert[java/spel-expression-injection] } public void testWithSimpleEvaluationContext(Socket socket) throws IOException { diff --git a/java/ql/test/query-tests/security/CWE-094/TemplateInjection/FreemarkerSSTI.java b/java/ql/test/query-tests/security/CWE-094/TemplateInjection/FreemarkerSSTI.java index a39ed8c5a4e..e1b87b3d2e5 100644 --- a/java/ql/test/query-tests/security/CWE-094/TemplateInjection/FreemarkerSSTI.java +++ b/java/ql/test/query-tests/security/CWE-094/TemplateInjection/FreemarkerSSTI.java @@ -20,88 +20,88 @@ public class FreemarkerSSTI { @GetMapping(value = "bad1") public void bad1(HttpServletRequest request) { String name = "ttemplate"; - String code = request.getParameter("code"); // $ Source + String code = request.getParameter("code"); // $ Source[java/server-side-template-injection] Reader reader = new StringReader(code); - Template t = new Template(name, reader); // $ Alert + Template t = new Template(name, reader); // $ Alert[java/server-side-template-injection] } @GetMapping(value = "bad2") public void bad2(HttpServletRequest request) { String name = "ttemplate"; - String code = request.getParameter("code"); // $ Source + String code = request.getParameter("code"); // $ Source[java/server-side-template-injection] Reader reader = new StringReader(code); Configuration cfg = new Configuration(); - Template t = new Template(name, reader, cfg); // $ Alert + Template t = new Template(name, reader, cfg); // $ Alert[java/server-side-template-injection] } @GetMapping(value = "bad3") public void bad3(HttpServletRequest request) { String name = "ttemplate"; - String code = request.getParameter("code"); // $ Source + String code = request.getParameter("code"); // $ Source[java/server-side-template-injection] Reader reader = new StringReader(code); Configuration cfg = new Configuration(); - Template t = new Template(name, reader, cfg, "UTF-8"); // $ Alert + Template t = new Template(name, reader, cfg, "UTF-8"); // $ Alert[java/server-side-template-injection] } @GetMapping(value = "bad4") public void bad4(HttpServletRequest request) { String name = "ttemplate"; - String sourceCode = request.getParameter("sourceCode"); // $ Source + String sourceCode = request.getParameter("sourceCode"); // $ Source[java/server-side-template-injection] Configuration cfg = new Configuration(); - Template t = new Template(name, sourceCode, cfg); // $ Alert + Template t = new Template(name, sourceCode, cfg); // $ Alert[java/server-side-template-injection] } @GetMapping(value = "bad5") public void bad5(HttpServletRequest request) { String name = "ttemplate"; - String code = request.getParameter("code"); // $ Source + String code = request.getParameter("code"); // $ Source[java/server-side-template-injection] Configuration cfg = new Configuration(); Reader reader = new StringReader(code); - Template t = new Template(name, sourceName, reader, cfg); // $ Alert + Template t = new Template(name, sourceName, reader, cfg); // $ Alert[java/server-side-template-injection] } @GetMapping(value = "bad6") public void bad6(HttpServletRequest request) { String name = "ttemplate"; - String code = request.getParameter("code"); // $ Source + String code = request.getParameter("code"); // $ Source[java/server-side-template-injection] Configuration cfg = new Configuration(); ParserConfiguration customParserConfiguration = new Configuration(); Reader reader = new StringReader(code); Template t = - new Template(name, sourceName, reader, cfg, customParserConfiguration, "UTF-8"); // $ Alert + new Template(name, sourceName, reader, cfg, customParserConfiguration, "UTF-8"); // $ Alert[java/server-side-template-injection] } @GetMapping(value = "bad7") public void bad7(HttpServletRequest request) { String name = "ttemplate"; - String code = request.getParameter("code"); // $ Source + String code = request.getParameter("code"); // $ Source[java/server-side-template-injection] Configuration cfg = new Configuration(); ParserConfiguration customParserConfiguration = new Configuration(); Reader reader = new StringReader(code); - Template t = new Template(name, sourceName, reader, cfg, "UTF-8"); // $ Alert + Template t = new Template(name, sourceName, reader, cfg, "UTF-8"); // $ Alert[java/server-side-template-injection] } @GetMapping(value = "bad8") public void bad8(HttpServletRequest request) { - String code = request.getParameter("code"); // $ Source + String code = request.getParameter("code"); // $ Source[java/server-side-template-injection] StringTemplateLoader stringLoader = new StringTemplateLoader(); - stringLoader.putTemplate("myTemplate", code); // $ Alert + stringLoader.putTemplate("myTemplate", code); // $ Alert[java/server-side-template-injection] } @GetMapping(value = "bad9") public void bad9(HttpServletRequest request) { - String code = request.getParameter("code"); // $ Source + String code = request.getParameter("code"); // $ Source[java/server-side-template-injection] StringTemplateLoader stringLoader = new StringTemplateLoader(); - stringLoader.putTemplate("myTemplate", code, 0); // $ Alert + stringLoader.putTemplate("myTemplate", code, 0); // $ Alert[java/server-side-template-injection] } @GetMapping(value = "good1") diff --git a/java/ql/test/query-tests/security/CWE-094/TemplateInjection/JinJavaSSTI.java b/java/ql/test/query-tests/security/CWE-094/TemplateInjection/JinJavaSSTI.java index 9bd9bad4ca8..ef931de1537 100644 --- a/java/ql/test/query-tests/security/CWE-094/TemplateInjection/JinJavaSSTI.java +++ b/java/ql/test/query-tests/security/CWE-094/TemplateInjection/JinJavaSSTI.java @@ -18,27 +18,27 @@ public class JinJavaSSTI { @GetMapping(value = "bad1") public void bad1(HttpServletRequest request) { - String template = request.getParameter("template"); // $ Source + String template = request.getParameter("template"); // $ Source[java/server-side-template-injection] Jinjava jinjava = new Jinjava(); Map context = new HashMap<>(); - String renderedTemplate = jinjava.render(template, context); // $ Alert + String renderedTemplate = jinjava.render(template, context); // $ Alert[java/server-side-template-injection] } @GetMapping(value = "bad2") public void bad2(HttpServletRequest request) { - String template = request.getParameter("template"); // $ Source + String template = request.getParameter("template"); // $ Source[java/server-side-template-injection] Jinjava jinjava = new Jinjava(); Map bindings = new HashMap<>(); - RenderResult renderResult = jinjava.renderForResult(template, bindings); // $ Alert + RenderResult renderResult = jinjava.renderForResult(template, bindings); // $ Alert[java/server-side-template-injection] } @GetMapping(value = "bad3") public void bad3(HttpServletRequest request) { - String template = request.getParameter("template"); // $ Source + String template = request.getParameter("template"); // $ Source[java/server-side-template-injection] Jinjava jinjava = new Jinjava(); Map bindings = new HashMap<>(); JinjavaConfig renderConfig = new JinjavaConfig(); - RenderResult renderResult = jinjava.renderForResult(template, bindings, renderConfig); // $ Alert + RenderResult renderResult = jinjava.renderForResult(template, bindings, renderConfig); // $ Alert[java/server-side-template-injection] } } diff --git a/java/ql/test/query-tests/security/CWE-094/TemplateInjection/PebbleSSTI.java b/java/ql/test/query-tests/security/CWE-094/TemplateInjection/PebbleSSTI.java index 45beaf46fa1..c2404a83172 100644 --- a/java/ql/test/query-tests/security/CWE-094/TemplateInjection/PebbleSSTI.java +++ b/java/ql/test/query-tests/security/CWE-094/TemplateInjection/PebbleSSTI.java @@ -15,15 +15,15 @@ public class PebbleSSTI { @GetMapping(value = "bad1") public void bad1(HttpServletRequest request) { - String templateName = request.getParameter("templateName"); // $ Source + String templateName = request.getParameter("templateName"); // $ Source[java/server-side-template-injection] PebbleEngine engine = new PebbleEngine.Builder().build(); - PebbleTemplate compiledTemplate = engine.getTemplate(templateName); // $ Alert + PebbleTemplate compiledTemplate = engine.getTemplate(templateName); // $ Alert[java/server-side-template-injection] } @GetMapping(value = "bad2") public void bad2(HttpServletRequest request) { - String templateName = request.getParameter("templateName"); // $ Source + String templateName = request.getParameter("templateName"); // $ Source[java/server-side-template-injection] PebbleEngine engine = new PebbleEngine.Builder().build(); - PebbleTemplate compiledTemplate = engine.getLiteralTemplate(templateName); // $ Alert + PebbleTemplate compiledTemplate = engine.getLiteralTemplate(templateName); // $ Alert[java/server-side-template-injection] } } diff --git a/java/ql/test/query-tests/security/CWE-094/TemplateInjection/ThymeleafSSTI.java b/java/ql/test/query-tests/security/CWE-094/TemplateInjection/ThymeleafSSTI.java index 669b287ea79..ce8813ab902 100644 --- a/java/ql/test/query-tests/security/CWE-094/TemplateInjection/ThymeleafSSTI.java +++ b/java/ql/test/query-tests/security/CWE-094/TemplateInjection/ThymeleafSSTI.java @@ -18,20 +18,20 @@ import org.thymeleaf.context.Context; public class ThymeleafSSTI { @GetMapping(value = "bad1") public void bad1(HttpServletRequest request) { - String code = request.getParameter("code"); // $ Source + String code = request.getParameter("code"); // $ Source[java/server-side-template-injection] try { TemplateEngine templateEngine = new TemplateEngine(); - templateEngine.process(code, (Set) null, (Context) null); // $ Alert - templateEngine.process(code, (Set) null, (Context) null, (Writer) null); // $ Alert - templateEngine.process(code, (Context) null); // $ Alert - templateEngine.process(code, (Context) null, (Writer) null); // $ Alert - templateEngine.processThrottled(code, (Set) null, (Context) null); // $ Alert - templateEngine.processThrottled(code, (Context) null); // $ Alert + templateEngine.process(code, (Set) null, (Context) null); // $ Alert[java/server-side-template-injection] + templateEngine.process(code, (Set) null, (Context) null, (Writer) null); // $ Alert[java/server-side-template-injection] + templateEngine.process(code, (Context) null); // $ Alert[java/server-side-template-injection] + templateEngine.process(code, (Context) null, (Writer) null); // $ Alert[java/server-side-template-injection] + templateEngine.processThrottled(code, (Set) null, (Context) null); // $ Alert[java/server-side-template-injection] + templateEngine.processThrottled(code, (Context) null); // $ Alert[java/server-side-template-injection] TemplateSpec spec = new TemplateSpec(code, ""); - templateEngine.process(spec, (Context) null); // $ Alert - templateEngine.process(spec, (Context) null, (Writer) null); // $ Alert - templateEngine.processThrottled(spec, (Context) null); // $ Alert + templateEngine.process(spec, (Context) null); // $ Alert[java/server-side-template-injection] + templateEngine.process(spec, (Context) null, (Writer) null); // $ Alert[java/server-side-template-injection] + templateEngine.processThrottled(spec, (Context) null); // $ Alert[java/server-side-template-injection] } catch (Exception e) { } } diff --git a/java/ql/test/query-tests/security/CWE-094/TemplateInjection/VelocitySSTI.java b/java/ql/test/query-tests/security/CWE-094/TemplateInjection/VelocitySSTI.java index 463a653525e..f175cae98e4 100644 --- a/java/ql/test/query-tests/security/CWE-094/TemplateInjection/VelocitySSTI.java +++ b/java/ql/test/query-tests/security/CWE-094/TemplateInjection/VelocitySSTI.java @@ -28,19 +28,19 @@ public class VelocitySSTI { @GetMapping(value = "bad1") public void bad1(HttpServletRequest request) { String name = "ttemplate"; - String code = request.getParameter("code"); // $ Source + String code = request.getParameter("code"); // $ Source[java/server-side-template-injection] VelocityContext context = null; String s = "We are using $project $name to render this."; StringWriter w = new StringWriter(); - Velocity.evaluate(context, w, "mystring", code); // $ Alert + Velocity.evaluate(context, w, "mystring", code); // $ Alert[java/server-side-template-injection] } @GetMapping(value = "bad2") public void bad2(HttpServletRequest request) { String name = "ttemplate"; - String code = request.getParameter("code"); // $ Source + String code = request.getParameter("code"); // $ Source[java/server-side-template-injection] VelocityContext context = null; @@ -48,17 +48,17 @@ public class VelocitySSTI { StringWriter w = new StringWriter(); StringReader reader = new StringReader(code); - Velocity.evaluate(context, w, "mystring", reader); // $ Alert + Velocity.evaluate(context, w, "mystring", reader); // $ Alert[java/server-side-template-injection] } @GetMapping(value = "bad3") public void bad3(HttpServletRequest request) { String name = "ttemplate"; - String code = request.getParameter("code"); // $ Source + String code = request.getParameter("code"); // $ Source[java/server-side-template-injection] RuntimeServices runtimeServices = null; StringReader reader = new StringReader(code); - runtimeServices.parse(reader, new Template()); // $ Alert + runtimeServices.parse(reader, new Template()); // $ Alert[java/server-side-template-injection] } @GetMapping(value = "good1") @@ -78,7 +78,7 @@ public class VelocitySSTI { @GetMapping(value = "bad5") public void bad5(HttpServletRequest request) { String name = "ttemplate"; - String code = request.getParameter("code"); // $ Source + String code = request.getParameter("code"); // $ Source[java/server-side-template-injection] VelocityContext context = new VelocityContext(); context.put("code", code); @@ -90,8 +90,8 @@ public class VelocitySSTI { ctx.put("key", code); engine.evaluate(ctx, null, null, (String) null); // Safe engine.evaluate(ctx, null, null, (Reader) null); // Safe - engine.evaluate(null, null, null, code); // $ Alert - engine.evaluate(null, null, null, new StringReader(code)); // $ Alert + engine.evaluate(null, null, null, code); // $ Alert[java/server-side-template-injection] + engine.evaluate(null, null, null, new StringReader(code)); // $ Alert[java/server-side-template-injection] } @GetMapping(value = "good2") @@ -111,10 +111,10 @@ public class VelocitySSTI { @GetMapping(value = "bad6") public void bad6(HttpServletRequest request) { - String code = request.getParameter("code"); // $ Source + String code = request.getParameter("code"); // $ Source[java/server-side-template-injection] StringResourceRepository repo = new StringResourceRepositoryImpl(); - repo.putStringResource("woogie2", code); // $ Alert + repo.putStringResource("woogie2", code); // $ Alert[java/server-side-template-injection] } } diff --git a/java/ql/test/query-tests/security/CWE-807/semmle/tests/ConditionalBypassTest.java b/java/ql/test/query-tests/security/CWE-807/semmle/tests/ConditionalBypassTest.java index 0085ce516cc..0de066c9872 100644 --- a/java/ql/test/query-tests/security/CWE-807/semmle/tests/ConditionalBypassTest.java +++ b/java/ql/test/query-tests/security/CWE-807/semmle/tests/ConditionalBypassTest.java @@ -16,18 +16,18 @@ class ConditionalBypassTest { String user = request.getParameter("user"); String password = request.getParameter("password"); - String isAdmin = request.getParameter("isAdmin"); // $ Source + String isAdmin = request.getParameter("isAdmin"); // $ Source[java/user-controlled-bypass] // BAD: login is only executed if isAdmin is false, but isAdmin // is controlled by the user - if (isAdmin == "false") // $ Sink - login(user, password); // $ Alert + if (isAdmin == "false") // $ Sink[java/user-controlled-bypass] + login(user, password); // $ Alert[java/user-controlled-bypass] Cookie adminCookie = getCookies()[0]; // BAD: login is only executed if the cookie value is false, but the cookie // is controlled by the user - if (adminCookie.getValue().equals("false")) // $ Source Sink - login(user, password); // $ Alert + if (adminCookie.getValue().equals("false")) // $ Source[java/user-controlled-bypass] Sink[java/user-controlled-bypass] + login(user, password); // $ Alert[java/user-controlled-bypass] // GOOD: both methods are conditionally executed, but they probably // both perform the security-critical action @@ -73,8 +73,8 @@ class ConditionalBypassTest { public static void test2(String user, String password) { Cookie adminCookie = getCookies()[0]; // BAD: login may happen once or twice - if (adminCookie.getValue() == "false") // $ Source Sink - login(user, password); // $ Alert + if (adminCookie.getValue() == "false") // $ Source[java/user-controlled-bypass] Sink[java/user-controlled-bypass] + login(user, password); // $ Alert[java/user-controlled-bypass] else { // do something else doIt(); @@ -85,8 +85,8 @@ class ConditionalBypassTest { public static void test3(String user, String password) { Cookie adminCookie = getCookies()[0]; // BAD: login may not happen - if (adminCookie.getValue() == "false") // $ Source Sink - login(user, password); // $ Alert + if (adminCookie.getValue() == "false") // $ Source[java/user-controlled-bypass] Sink[java/user-controlled-bypass] + login(user, password); // $ Alert[java/user-controlled-bypass] else { // do something else doIt(); @@ -130,8 +130,8 @@ class ConditionalBypassTest { public static void test7(String user, String password) { Cookie adminCookie = getCookies()[0]; // BAD: login is bypasseable - if (adminCookie.getValue() == "false") { // $ Source Sink - login(user, password); // $ Alert + if (adminCookie.getValue() == "false") { // $ Source[java/user-controlled-bypass] Sink[java/user-controlled-bypass] + login(user, password); // $ Alert[java/user-controlled-bypass] return; } else { doIt(); @@ -142,8 +142,8 @@ class ConditionalBypassTest { Cookie adminCookie = getCookies()[0]; { // BAD: login may not happen - if (adminCookie.getValue() == "false") // $ Source Sink - authorize(user, password); // $ Alert + if (adminCookie.getValue() == "false") // $ Source[java/user-controlled-bypass] Sink[java/user-controlled-bypass] + authorize(user, password); // $ Alert[java/user-controlled-bypass] else { // do something else doIt(); diff --git a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/Consume.java b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/Consume.java index 6bd0966ff28..70f5a0b2bee 100644 --- a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/Consume.java +++ b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/Consume.java @@ -38,7 +38,7 @@ public @interface Consume { /** * The uri to consume from */ - String value() default ""; // $ Alert[java/dead-function] + String value() default ""; /** * The uri to consume from @@ -46,12 +46,12 @@ public @interface Consume { * @deprecated use value instead */ @Deprecated - String uri() default ""; // $ Alert[java/dead-function] + String uri() default ""; /** * Use the field or getter on the bean to provide the uri to consume from */ - String property() default ""; // $ Alert[java/dead-function] + String property() default ""; /** * Optional predicate (using simple language) to only consume if the predicate matches . This can be used to filter @@ -60,5 +60,5 @@ public @interface Consume { * Notice that only the first method that matches the predicate will be used. And if no predicate matches then the * message is dropped. */ - String predicate() default ""; // $ Alert[java/dead-function] + String predicate() default ""; } diff --git a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/builder/ExpressionClause.java b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/builder/ExpressionClause.java index e90e607e50c..2dcc3ad5a7a 100644 --- a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/builder/ExpressionClause.java +++ b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/builder/ExpressionClause.java @@ -20,6 +20,6 @@ package org.apache.camel.builder; * Represents an expression clause within the DSL which when the expression is complete the clause continues to another * part of the DSL */ -public class ExpressionClause { // $ Alert[java/dead-class] +public class ExpressionClause { public T method(String ref) { return null; } } diff --git a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/builder/RouteBuilder.java b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/builder/RouteBuilder.java index 0cb300895bc..9c1b8c45d68 100644 --- a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/builder/RouteBuilder.java +++ b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/builder/RouteBuilder.java @@ -31,9 +31,9 @@ public abstract class RouteBuilder implements RoutesBuilder { * @param uri the from uri * @return the builder */ - public RouteDefinition from(String uri) { // $ Alert[java/dead-function] + public RouteDefinition from(String uri) { return null; } - public abstract void configure() throws Exception; // $ Alert[java/dead-function] + public abstract void configure() throws Exception; } diff --git a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/impl/DefaultCamelContext.java b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/impl/DefaultCamelContext.java index 22140d4b2f5..2180623054b 100644 --- a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/impl/DefaultCamelContext.java +++ b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/impl/DefaultCamelContext.java @@ -21,7 +21,7 @@ import org.apache.camel.RoutesBuilder; public class DefaultCamelContext implements ModelCamelContext { - public void configure() throws Exception {} // $ Alert[java/dead-function] + public void configure() throws Exception {} public void addRoutes(RoutesBuilder arg0) {} diff --git a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/FilterDefinition.java b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/FilterDefinition.java index d3bed4347b5..1138c8d3783 100644 --- a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/FilterDefinition.java +++ b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/FilterDefinition.java @@ -16,4 +16,4 @@ */ package org.apache.camel.model; -public class FilterDefinition { } // $ Alert[java/dead-class] +public class FilterDefinition { } diff --git a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/OutputDefinition.java b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/OutputDefinition.java index 5c4045cdc95..cfe55f5cc17 100644 --- a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/OutputDefinition.java +++ b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/OutputDefinition.java @@ -19,5 +19,5 @@ package org.apache.camel.model; /** * A useful base class for output types */ -public class OutputDefinition> extends ProcessorDefinition { // $ Alert[java/dead-class] +public class OutputDefinition> extends ProcessorDefinition { } diff --git a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/ProcessorDefinition.java b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/ProcessorDefinition.java index 37931b91796..2423e907b01 100644 --- a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/ProcessorDefinition.java +++ b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/ProcessorDefinition.java @@ -18,7 +18,7 @@ package org.apache.camel.model; import org.apache.camel.builder.ExpressionClause; -public abstract class ProcessorDefinition> { // $ Alert[java/dead-class] +public abstract class ProcessorDefinition> { public Type to(String uri) { return null; } public Type bean(Object bean) { return null; } diff --git a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/RouteDefinition.java b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/RouteDefinition.java index 2052e6a0cdd..2ab31d2126a 100644 --- a/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/RouteDefinition.java +++ b/java/ql/test/stubs/apache-camel-4.0.6/org/apache/camel/model/RouteDefinition.java @@ -16,7 +16,7 @@ */ package org.apache.camel.model; -public class RouteDefinition extends OutputDefinition { // $ Alert[java/dead-class] +public class RouteDefinition extends OutputDefinition { } From 98f147556a4a811c53dddb3d1f9103bc0dc89908 Mon Sep 17 00:00:00 2001 From: Jeroen Ketema Date: Wed, 10 Jun 2026 14:27:56 +0200 Subject: [PATCH 07/23] C++: Add namequalifier test with inconsistency While where the remove the file restriction in QL. --- .../library-tests/name_qualifiers/DB-CHECK.expected | 5 +++++ .../name_qualifiers/NameQualifiers1.expected | 4 ++++ .../library-tests/name_qualifiers/NameQualifiers1.ql | 4 +--- .../library-tests/name_qualifiers/inconsistency.cpp | 4 ++-- .../library-tests/name_qualifiers/inconsistency2.cpp | 12 ++++++++++++ 5 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 cpp/ql/test/library-tests/name_qualifiers/DB-CHECK.expected create mode 100644 cpp/ql/test/library-tests/name_qualifiers/inconsistency2.cpp diff --git a/cpp/ql/test/library-tests/name_qualifiers/DB-CHECK.expected b/cpp/ql/test/library-tests/name_qualifiers/DB-CHECK.expected new file mode 100644 index 00000000000..e27957d308d --- /dev/null +++ b/cpp/ql/test/library-tests/name_qualifiers/DB-CHECK.expected @@ -0,0 +1,5 @@ +[VALUE_NOT_IN_TYPE] predicate namequalifiers(@namequalifier id, @namequalifiableelement qualifiableelement, @namequalifyingelement qualifyingelement, @location_default location): Value 272 of field qualifyingelement is not in type @namequalifyingelement. The value is however in the following types: @type_with_specifiers. Appears in tuple (-16777185,-16777184,272,307) + Relevant element: qualifyingelement=272 + Full ID for 272: @"typeref_const(216)". The ID may expand to @"typeref_const{@"type_decl_s_nonproto[struct_complete]_{@"namespace_decl_(namespace line:1, {@"/Users/jketema/development/semmle-code/ql/cpp/ql/test/library-tests/name_qualifiers/inconsistency2.cpp;sourcefile"}){@"not_inline"}"}_321bfec50edc"}" + Relevant element: location=307 + Full ID for 307: @"loc,(212),3,3,3,11". The ID may expand to @"loc,{@"/Users/jketema/development/semmle-code/ql/cpp/ql/test/library-tests/name_qualifiers/inconsistency2.cpp;sourcefile"},3,3,3,11" diff --git a/cpp/ql/test/library-tests/name_qualifiers/NameQualifiers1.expected b/cpp/ql/test/library-tests/name_qualifiers/NameQualifiers1.expected index 72d7d615c81..d9419b833a1 100644 --- a/cpp/ql/test/library-tests/name_qualifiers/NameQualifiers1.expected +++ b/cpp/ql/test/library-tests/name_qualifiers/NameQualifiers1.expected @@ -1,3 +1,7 @@ +| inconsistency2.cpp:3:3:3:5 | T:: | inconsistency2.cpp:3:3:3:6 | x | inconsistency2.cpp:2:20:2:20 | T | +| inconsistency2.cpp:3:3:3:11 | (no string representation) | inconsistency2.cpp:3:3:3:6 | x | file://:0:0:0:0 | const s | +| inconsistency.cpp:7:20:7:22 | S:: | inconsistency.cpp:7:20:7:23 | (int)... | inconsistency.cpp:4:8:4:8 | S | +| inconsistency.cpp:7:20:7:22 | S:: | inconsistency.cpp:7:20:7:23 | A | inconsistency.cpp:4:8:4:8 | S | | name_qualifiers.cpp:29:7:29:8 | :: | name_qualifiers.cpp:29:7:29:9 | x | file://:0:0:0:0 | (global namespace) | | name_qualifiers.cpp:31:7:31:10 | N1:: | name_qualifiers.cpp:31:7:31:12 | nx | name_qualifiers.cpp:4:11:4:12 | N1 | | name_qualifiers.cpp:34:7:34:8 | :: | name_qualifiers.cpp:34:9:34:12 | N1:: | file://:0:0:0:0 | (global namespace) | diff --git a/cpp/ql/test/library-tests/name_qualifiers/NameQualifiers1.ql b/cpp/ql/test/library-tests/name_qualifiers/NameQualifiers1.ql index 77a8e195ebe..b5b40e35caa 100644 --- a/cpp/ql/test/library-tests/name_qualifiers/NameQualifiers1.ql +++ b/cpp/ql/test/library-tests/name_qualifiers/NameQualifiers1.ql @@ -1,7 +1,5 @@ import cpp from NameQualifier nq, Location l -where - l = nq.getQualifiedElement().getLocation() and - l.getFile().getShortName() = "name_qualifiers" +where l = nq.getQualifiedElement().getLocation() select nq, nq.getQualifiedElement(), nq.getQualifyingElement() diff --git a/cpp/ql/test/library-tests/name_qualifiers/inconsistency.cpp b/cpp/ql/test/library-tests/name_qualifiers/inconsistency.cpp index caa5a6817c1..94c61bf8e23 100644 --- a/cpp/ql/test/library-tests/name_qualifiers/inconsistency.cpp +++ b/cpp/ql/test/library-tests/name_qualifiers/inconsistency.cpp @@ -1,8 +1,8 @@ // This file is present to test whether name-qualifying an enum constant leads to a database inconsistency. -// As such, there is no QL part of the test. + struct S { enum E { A }; }; -static int f() { +static void f() { switch(0) { case S::A: break; } } diff --git a/cpp/ql/test/library-tests/name_qualifiers/inconsistency2.cpp b/cpp/ql/test/library-tests/name_qualifiers/inconsistency2.cpp new file mode 100644 index 00000000000..d1fec43cb84 --- /dev/null +++ b/cpp/ql/test/library-tests/name_qualifiers/inconsistency2.cpp @@ -0,0 +1,12 @@ +namespace { +template T f() { + T::x; + return {}; +} +struct s { + static int x; +}; +struct t { + s x = f(); +}; +} From 6d0968744b21998070623e3942baf204fb3365ed Mon Sep 17 00:00:00 2001 From: Jeroen Ketema Date: Wed, 10 Jun 2026 14:35:36 +0200 Subject: [PATCH 08/23] C++: Fix `NameQualifyingElement` db inconsistency --- cpp/ql/lib/semmle/code/cpp/Type.qll | 2 +- cpp/ql/lib/semmlecode.cpp.dbscheme | 3 ++- cpp/ql/test/library-tests/name_qualifiers/DB-CHECK.expected | 5 ----- .../library-tests/name_qualifiers/NameQualifiers1.expected | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-) delete mode 100644 cpp/ql/test/library-tests/name_qualifiers/DB-CHECK.expected diff --git a/cpp/ql/lib/semmle/code/cpp/Type.qll b/cpp/ql/lib/semmle/code/cpp/Type.qll index fa2d2d605d8..4069b58134b 100644 --- a/cpp/ql/lib/semmle/code/cpp/Type.qll +++ b/cpp/ql/lib/semmle/code/cpp/Type.qll @@ -1071,7 +1071,7 @@ class NullPointerType extends BuiltInType { * const float fa[40]; * ``` */ -class DerivedType extends Type, @derivedtype { +class DerivedType extends Type, NameQualifyingElement, @derivedtype { override string toString() { result = this.getName() } override string getName() { derivedtypes(underlyingElement(this), result, _, _) } diff --git a/cpp/ql/lib/semmlecode.cpp.dbscheme b/cpp/ql/lib/semmlecode.cpp.dbscheme index ef8d209a22e..0853f43dc8c 100644 --- a/cpp/ql/lib/semmlecode.cpp.dbscheme +++ b/cpp/ql/lib/semmlecode.cpp.dbscheme @@ -1430,7 +1430,8 @@ specialnamequalifyingelements( @namequalifyingelement = @namespace | @specialnamequalifyingelement | @usertype - | @decltype; + | @decltype + | @derivedtype; namequalifiers( unique int id: @namequalifier, diff --git a/cpp/ql/test/library-tests/name_qualifiers/DB-CHECK.expected b/cpp/ql/test/library-tests/name_qualifiers/DB-CHECK.expected deleted file mode 100644 index e27957d308d..00000000000 --- a/cpp/ql/test/library-tests/name_qualifiers/DB-CHECK.expected +++ /dev/null @@ -1,5 +0,0 @@ -[VALUE_NOT_IN_TYPE] predicate namequalifiers(@namequalifier id, @namequalifiableelement qualifiableelement, @namequalifyingelement qualifyingelement, @location_default location): Value 272 of field qualifyingelement is not in type @namequalifyingelement. The value is however in the following types: @type_with_specifiers. Appears in tuple (-16777185,-16777184,272,307) - Relevant element: qualifyingelement=272 - Full ID for 272: @"typeref_const(216)". The ID may expand to @"typeref_const{@"type_decl_s_nonproto[struct_complete]_{@"namespace_decl_(namespace line:1, {@"/Users/jketema/development/semmle-code/ql/cpp/ql/test/library-tests/name_qualifiers/inconsistency2.cpp;sourcefile"}){@"not_inline"}"}_321bfec50edc"}" - Relevant element: location=307 - Full ID for 307: @"loc,(212),3,3,3,11". The ID may expand to @"loc,{@"/Users/jketema/development/semmle-code/ql/cpp/ql/test/library-tests/name_qualifiers/inconsistency2.cpp;sourcefile"},3,3,3,11" diff --git a/cpp/ql/test/library-tests/name_qualifiers/NameQualifiers1.expected b/cpp/ql/test/library-tests/name_qualifiers/NameQualifiers1.expected index d9419b833a1..b5f2fe8dd74 100644 --- a/cpp/ql/test/library-tests/name_qualifiers/NameQualifiers1.expected +++ b/cpp/ql/test/library-tests/name_qualifiers/NameQualifiers1.expected @@ -1,5 +1,5 @@ | inconsistency2.cpp:3:3:3:5 | T:: | inconsistency2.cpp:3:3:3:6 | x | inconsistency2.cpp:2:20:2:20 | T | -| inconsistency2.cpp:3:3:3:11 | (no string representation) | inconsistency2.cpp:3:3:3:6 | x | file://:0:0:0:0 | const s | +| inconsistency2.cpp:3:3:3:11 | const s:: | inconsistency2.cpp:3:3:3:6 | x | file://:0:0:0:0 | const s | | inconsistency.cpp:7:20:7:22 | S:: | inconsistency.cpp:7:20:7:23 | (int)... | inconsistency.cpp:4:8:4:8 | S | | inconsistency.cpp:7:20:7:22 | S:: | inconsistency.cpp:7:20:7:23 | A | inconsistency.cpp:4:8:4:8 | S | | name_qualifiers.cpp:29:7:29:8 | :: | name_qualifiers.cpp:29:7:29:9 | x | file://:0:0:0:0 | (global namespace) | From ef00aa2567f55a90c3aaf041be4c85d7ee4ae388 Mon Sep 17 00:00:00 2001 From: Jeroen Ketema Date: Wed, 10 Jun 2026 14:38:15 +0200 Subject: [PATCH 09/23] C++: Add upgrade and downgrade scripts --- .../old.dbscheme | 2578 +++++++++++++++++ .../semmlecode.cpp.dbscheme | 2577 ++++++++++++++++ .../upgrade.properties | 2 + .../old.dbscheme | 2577 ++++++++++++++++ .../semmlecode.cpp.dbscheme | 2578 +++++++++++++++++ .../upgrade.properties | 2 + 6 files changed, 10314 insertions(+) create mode 100644 cpp/downgrades/0853f43dc8c08deecb473c54a2b70da8597f1ab5/old.dbscheme create mode 100644 cpp/downgrades/0853f43dc8c08deecb473c54a2b70da8597f1ab5/semmlecode.cpp.dbscheme create mode 100644 cpp/downgrades/0853f43dc8c08deecb473c54a2b70da8597f1ab5/upgrade.properties create mode 100644 cpp/ql/lib/upgrades/ef8d209a22e27413aaaeff4446f0ecb9fa2c227b/old.dbscheme create mode 100644 cpp/ql/lib/upgrades/ef8d209a22e27413aaaeff4446f0ecb9fa2c227b/semmlecode.cpp.dbscheme create mode 100644 cpp/ql/lib/upgrades/ef8d209a22e27413aaaeff4446f0ecb9fa2c227b/upgrade.properties diff --git a/cpp/downgrades/0853f43dc8c08deecb473c54a2b70da8597f1ab5/old.dbscheme b/cpp/downgrades/0853f43dc8c08deecb473c54a2b70da8597f1ab5/old.dbscheme new file mode 100644 index 00000000000..0853f43dc8c --- /dev/null +++ b/cpp/downgrades/0853f43dc8c08deecb473c54a2b70da8597f1ab5/old.dbscheme @@ -0,0 +1,2578 @@ + +/*- Compilations -*/ + +/** + * An invocation of the compiler. Note that more than one file may be + * compiled per invocation. For example, this command compiles three + * source files: + * + * gcc -c f1.c f2.c f3.c + * + * The `id` simply identifies the invocation, while `cwd` is the working + * directory from which the compiler was invoked. + */ +compilations( + /** + * An invocation of the compiler. Note that more than one file may + * be compiled per invocation. For example, this command compiles + * three source files: + * + * gcc -c f1.c f2.c f3.c + */ + unique int id : @compilation, + string cwd : string ref +); + +/** + * The arguments that were passed to the extractor for a compiler + * invocation. If `id` is for the compiler invocation + * + * gcc -c f1.c f2.c f3.c + * + * then typically there will be rows for + * + * num | arg + * --- | --- + * 0 | *path to extractor* + * 1 | `--mimic` + * 2 | `/usr/bin/gcc` + * 3 | `-c` + * 4 | f1.c + * 5 | f2.c + * 6 | f3.c + */ +#keyset[id, num] +compilation_args( + int id : @compilation ref, + int num : int ref, + string arg : string ref +); + +/** + * The expanded arguments that were passed to the extractor for a + * compiler invocation. This is similar to `compilation_args`, but + * for a `@someFile` argument, it includes the arguments from that + * file, rather than just taking the argument literally. + */ +#keyset[id, num] +compilation_expanded_args( + int id : @compilation ref, + int num : int ref, + string arg : string ref +); + +/** + * Optionally, record the build mode for each compilation. + */ +compilation_build_mode( + unique int id : @compilation ref, + int mode : int ref +); + +/* +case @compilation_build_mode.mode of + 0 = @build_mode_none +| 1 = @build_mode_manual +| 2 = @build_mode_auto +; +*/ + +/** + * The source files that are compiled by a compiler invocation. + * If `id` is for the compiler invocation + * + * gcc -c f1.c f2.c f3.c + * + * then there will be rows for + * + * num | arg + * --- | --- + * 0 | f1.c + * 1 | f2.c + * 2 | f3.c + * + * Note that even if those files `#include` headers, those headers + * do not appear as rows. + */ +#keyset[id, num] +compilation_compiling_files( + int id : @compilation ref, + int num : int ref, + int file : @file ref +); + +/** + * The time taken by the extractor for a compiler invocation. + * + * For each file `num`, there will be rows for + * + * kind | seconds + * ---- | --- + * 1 | CPU seconds used by the extractor frontend + * 2 | Elapsed seconds during the extractor frontend + * 3 | CPU seconds used by the extractor backend + * 4 | Elapsed seconds during the extractor backend + */ +#keyset[id, num, kind] +compilation_time( + int id : @compilation ref, + int num : int ref, + /* kind: + 1 = frontend_cpu_seconds + 2 = frontend_elapsed_seconds + 3 = extractor_cpu_seconds + 4 = extractor_elapsed_seconds + */ + int kind : int ref, + float seconds : float ref +); + +/** + * An error or warning generated by the extractor. + * The diagnostic message `diagnostic` was generated during compiler + * invocation `compilation`, and is the `file_number_diagnostic_number`th + * message generated while extracting the `file_number`th file of that + * invocation. + */ +#keyset[compilation, file_number, file_number_diagnostic_number] +diagnostic_for( + int diagnostic : @diagnostic ref, + int compilation : @compilation ref, + int file_number : int ref, + int file_number_diagnostic_number : int ref +); + +/** + * If extraction was successful, then `cpu_seconds` and + * `elapsed_seconds` are the CPU time and elapsed time (respectively) + * that extraction took for compiler invocation `id`. + */ +compilation_finished( + unique int id : @compilation ref, + float cpu_seconds : float ref, + float elapsed_seconds : float ref +); + +/*- External data -*/ + +/** + * External data, loaded from CSV files during snapshot creation. See + * [Tutorial: Incorporating external data](https://help.semmle.com/wiki/display/SD/Tutorial%3A+Incorporating+external+data) + * for more information. + */ +externalData( + int id : @externalDataElement, + string path : string ref, + int column: int ref, + string value : string ref +); + +/*- Source location prefix -*/ + +/** + * The source location of the snapshot. + */ +sourceLocationPrefix(string prefix : string ref); + +/*- Files and folders -*/ + +/** + * The location of an element. + * The location spans column `startcolumn` of line `startline` to + * column `endcolumn` of line `endline` in file `file`. + * For more information, see + * [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/). + */ +locations_default( + unique int id: @location_default, + int file: @file ref, + int beginLine: int ref, + int beginColumn: int ref, + int endLine: int ref, + int endColumn: int ref +); + +files( + unique int id: @file, + string name: string ref +); + +folders( + unique int id: @folder, + string name: string ref +); + +@container = @file | @folder + +containerparent( + int parent: @container ref, + unique int child: @container ref +); + +/*- Lines of code -*/ + +numlines( + int element_id: @sourceline ref, + int num_lines: int ref, + int num_code: int ref, + int num_comment: int ref +); + +/*- Diagnostic messages -*/ + +diagnostics( + unique int id: @diagnostic, + int severity: int ref, + string error_tag: string ref, + string error_message: string ref, + string full_error_message: string ref, + int location: @location_default ref +); + +/*- C++ dbscheme -*/ + +extractor_version( + string codeql_version: string ref, + string frontend_version: string ref +) + +/** + * Gives the TRAP filename that `trap` is associated with. + * For debugging only. + */ +trap_filename( + int trap: @trap, + string filename: string ref +); + +/** + * Gives the tag name for `tag`. + * For debugging only. + */ +tag_name( + int tag: @tag, + string name: string ref +); + +@trap_or_tag = @tag | @trap; + +/** + * Gives the name for the source file. + */ +source_file_name( + int sf: @source_file, + string name: string ref +); + +/** + * In `build-mode: none` overlay mode, indicates that `source_file` + * (`/path/to/foo.c`) uses the TRAP file `trap_file`; i.e. it is the + * TRAP file corresponding to `foo.c`, something it transitively + * includes, or a template instantiation it transitively uses. + */ +source_file_uses_trap( + int source_file: @source_file ref, + int trap_file: @trap ref +); + +/** + * In `build-mode: none` overlay mode, indicates that the TRAP file + * `trap_file` uses tag `tag`. + */ +trap_uses_tag( + int trap_file: @trap ref, + int tag: @tag ref +); + +/** + * Holds if there is a definition of `element` in TRAP file or tag `t`. + */ +in_trap_or_tag( + int element: @element ref, + int t: @trap_or_tag ref +); + +pch_uses( + int pch: @pch ref, + int compilation: @compilation ref, + int id: @file ref +) + +#keyset[pch, compilation] +pch_creations( + int pch: @pch, + int compilation: @compilation ref, + int from: @file ref +) + +/** An element for which line-count information is available. */ +@sourceline = @file | @function | @variable | @enumconstant | @xmllocatable; + +fileannotations( + int id: @file ref, + int kind: int ref, + string name: string ref, + string value: string ref +); + +inmacroexpansion( + int id: @element ref, + int inv: @macroinvocation ref +); + +affectedbymacroexpansion( + int id: @element ref, + int inv: @macroinvocation ref +); + +case @macroinvocation.kind of + 1 = @macro_expansion +| 2 = @other_macro_reference +; + +macroinvocations( + unique int id: @macroinvocation, + int macro_id: @ppd_define ref, + int location: @location_default ref, + int kind: int ref +); + +macroparent( + unique int id: @macroinvocation ref, + int parent_id: @macroinvocation ref +); + +// a macroinvocation may be part of another location +// the way to find a constant expression that uses a macro +// is thus to find a constant expression that has a location +// to which a macro invocation is bound +macrolocationbind( + int id: @macroinvocation ref, + int location: @location_default ref +); + +#keyset[invocation, argument_index] +macro_argument_unexpanded( + int invocation: @macroinvocation ref, + int argument_index: int ref, + string text: string ref +); + +#keyset[invocation, argument_index] +macro_argument_expanded( + int invocation: @macroinvocation ref, + int argument_index: int ref, + string text: string ref +); + +case @function.kind of + 0 = @unknown_function +| 1 = @normal_function +| 2 = @constructor +| 3 = @destructor +| 4 = @conversion_function +| 5 = @operator +// ... 6 = @builtin_function deprecated // GCC built-in functions, e.g. __builtin___memcpy_chk +| 7 = @user_defined_literal +| 8 = @deduction_guide +; + +functions( + unique int id: @function, + string name: string ref, + int kind: int ref +); + +builtin_functions( + int id: @function ref +) + +function_entry_point( + int id: @function ref, + unique int entry_point: @stmt ref +); + +function_return_type( + int id: @function ref, + int return_type: @type ref +); + +/** + * If `function` is a coroutine, then this gives the `std::experimental::resumable_traits` + * instance associated with it, and the variables representing the `handle` and `promise` + * for it. + */ +coroutine( + unique int function: @function ref, + int traits: @type ref +); + +/* +case @coroutine_placeholder_variable.kind of + 1 = @handle +| 2 = @promise +| 3 = @init_await_resume +; +*/ + +coroutine_placeholder_variable( + unique int placeholder_variable: @variable ref, + int kind: int ref, + int function: @function ref +) + +/** The `new` function used for allocating the coroutine state, if any. */ +coroutine_new( + unique int function: @function ref, + int new: @function ref +); + +/** The `delete` function used for deallocating the coroutine state, if any. */ +coroutine_delete( + unique int function: @function ref, + int delete: @function ref +); + +purefunctions(unique int id: @function ref); + +function_deleted(unique int id: @function ref); + +function_defaulted(unique int id: @function ref); + +function_prototyped(unique int id: @function ref) + +deduction_guide_for_class( + int id: @function ref, + int class_template: @usertype ref +) + +member_function_this_type( + unique int id: @function ref, + int this_type: @type ref +); + +#keyset[id, type_id] +fun_decls( + int id: @fun_decl, + int function: @function ref, + int type_id: @type ref, + string name: string ref, + int location: @location_default ref +); +fun_def(unique int id: @fun_decl ref); +fun_specialized(unique int id: @fun_decl ref); +fun_implicit(unique int id: @fun_decl ref); +fun_decl_specifiers( + int id: @fun_decl ref, + string name: string ref +) +#keyset[fun_decl, index] +fun_decl_throws( + int fun_decl: @fun_decl ref, + int index: int ref, + int type_id: @type ref +); +/* an empty throw specification is different from none */ +fun_decl_empty_throws(unique int fun_decl: @fun_decl ref); +fun_decl_noexcept( + int fun_decl: @fun_decl ref, + int constant: @expr ref +); +fun_decl_empty_noexcept(int fun_decl: @fun_decl ref); +fun_decl_typedef_type( + unique int fun_decl: @fun_decl ref, + int typedeftype_id: @usertype ref +); + +/* +case @fun_requires.kind of + 1 = @template_attached +| 2 = @function_attached +; +*/ + +fun_requires( + int id: @fun_decl ref, + int kind: int ref, + int constraint: @expr ref +); + +param_decl_bind( + unique int id: @var_decl ref, + int index: int ref, + int fun_decl: @fun_decl ref +); + +#keyset[id, type_id] +var_decls( + int id: @var_decl, + int variable: @variable ref, + int type_id: @type ref, + string name: string ref, + int location: @location_default ref +); +var_def(unique int id: @var_decl ref); +var_specialized(int id: @var_decl ref); +var_decl_specifiers( + int id: @var_decl ref, + string name: string ref +) +is_structured_binding(unique int id: @variable ref); +var_requires( + int id: @var_decl ref, + int constraint: @expr ref +); + +type_decls( + unique int id: @type_decl, + int type_id: @type ref, + int location: @location_default ref +); +type_def(unique int id: @type_decl ref); +type_decl_top( + unique int type_decl: @type_decl ref +); +type_requires( + int id: @type_decl ref, + int constraint: @expr ref +); + +namespace_decls( + unique int id: @namespace_decl, + int namespace_id: @namespace ref, + int location: @location_default ref, + int bodylocation: @location_default ref +); + +case @using.kind of + 1 = @using_declaration +| 2 = @using_directive +| 3 = @using_enum_declaration +; + +usings( + unique int id: @using, + int element_id: @element ref, + int location: @location_default ref, + int kind: int ref +); + +/** The element which contains the `using` declaration. */ +using_container( + int parent: @element ref, + int child: @using ref +); + +static_asserts( + unique int id: @static_assert, + int condition : @expr ref, + string message : string ref, + int location: @location_default ref, + int enclosing : @element ref +); + +// each function has an ordered list of parameters +#keyset[id, type_id] +#keyset[function, index, type_id] +params( + int id: @parameter, + int function: @parameterized_element ref, + int index: int ref, + int type_id: @type ref +); + +overrides( + int new: @function ref, + int old: @function ref +); + +#keyset[id, type_id] +membervariables( + int id: @membervariable, + int type_id: @type ref, + string name: string ref +); + +#keyset[id, type_id] +globalvariables( + int id: @globalvariable, + int type_id: @type ref, + string name: string ref +); + +#keyset[id, type_id] +localvariables( + int id: @localvariable, + int type_id: @type ref, + string name: string ref +); + +autoderivation( + unique int var: @variable ref, + int derivation_type: @type ref +); + +orphaned_variables( + int var: @localvariable ref, + int function: @function ref +) + +enumconstants( + unique int id: @enumconstant, + int parent: @usertype ref, + int index: int ref, + int type_id: @type ref, + string name: string ref, + int location: @location_default ref +); + +@variable = @localscopevariable | @globalvariable | @membervariable; + +@localscopevariable = @localvariable | @parameter; + +/** + * Built-in types are the fundamental types, e.g., integral, floating, and void. + */ +case @builtintype.kind of + 1 = @errortype +| 2 = @unknowntype +| 3 = @void +| 4 = @boolean +| 5 = @char +| 6 = @unsigned_char +| 7 = @signed_char +| 8 = @short +| 9 = @unsigned_short +| 10 = @signed_short +| 11 = @int +| 12 = @unsigned_int +| 13 = @signed_int +| 14 = @long +| 15 = @unsigned_long +| 16 = @signed_long +| 17 = @long_long +| 18 = @unsigned_long_long +| 19 = @signed_long_long +// ... 20 Microsoft-specific __int8 +// ... 21 Microsoft-specific __int16 +// ... 22 Microsoft-specific __int32 +// ... 23 Microsoft-specific __int64 +| 24 = @float +| 25 = @double +| 26 = @long_double +| 27 = @complex_float // C99-specific _Complex float +| 28 = @complex_double // C99-specific _Complex double +| 29 = @complex_long_double // C99-specific _Complex long double +| 30 = @imaginary_float // C99-specific _Imaginary float +| 31 = @imaginary_double // C99-specific _Imaginary double +| 32 = @imaginary_long_double // C99-specific _Imaginary long double +| 33 = @wchar_t // Microsoft-specific +| 34 = @decltype_nullptr // C++11 +| 35 = @int128 // __int128 +| 36 = @unsigned_int128 // unsigned __int128 +| 37 = @signed_int128 // signed __int128 +| 38 = @float128 // __float128 +| 39 = @complex_float128 // _Complex __float128 +// ... 40 _Decimal32 +// ... 41 _Decimal64 +// ... 42 _Decimal128 +| 43 = @char16_t +| 44 = @char32_t +| 45 = @std_float32 // _Float32 +| 46 = @float32x // _Float32x +| 47 = @std_float64 // _Float64 +| 48 = @float64x // _Float64x +| 49 = @std_float128 // _Float128 +// ... 50 _Float128x +| 51 = @char8_t +| 52 = @float16 // _Float16 +| 53 = @complex_float16 // _Complex _Float16 +| 54 = @fp16 // __fp16 +| 55 = @std_bfloat16 // __bf16 +| 56 = @std_float16 // std::float16_t +| 57 = @complex_std_float32 // _Complex _Float32 +| 58 = @complex_float32x // _Complex _Float32x +| 59 = @complex_std_float64 // _Complex _Float64 +| 60 = @complex_float64x // _Complex _Float64x +| 61 = @complex_std_float128 // _Complex _Float128 +| 62 = @mfp8 // __mfp8 +| 63 = @scalable_vector_count // __SVCount_t +| 64 = @complex_fp16 // _Complex __fp16 +| 65 = @complex_std_bfloat16 // _Complex __bf16 +| 66 = @complex_std_float16 // _Complex std::float16_t +; + +builtintypes( + unique int id: @builtintype, + string name: string ref, + int kind: int ref, + int size: int ref, + int sign: int ref, + int alignment: int ref +); + +/** + * Derived types are types that are directly derived from existing types and + * point to, refer to, transform type data to return a new type. + */ +case @derivedtype.kind of + 1 = @pointer +| 2 = @reference +| 3 = @type_with_specifiers +| 4 = @array +| 5 = @gnu_vector +| 6 = @routineptr +| 7 = @routinereference +| 8 = @rvalue_reference // C++11 +// ... 9 type_conforming_to_protocols deprecated +| 10 = @block +| 11 = @scalable_vector // Arm SVE +; + +derivedtypes( + unique int id: @derivedtype, + string name: string ref, + int kind: int ref, + int type_id: @type ref +); + +pointerishsize(unique int id: @derivedtype ref, + int size: int ref, + int alignment: int ref); + +arraysizes( + unique int id: @derivedtype ref, + int num_elements: int ref, + int bytesize: int ref, + int alignment: int ref +); + +tupleelements( + unique int id: @derivedtype ref, + int num_elements: int ref +); + +typedefbase( + unique int id: @usertype ref, + int type_id: @type ref +); + +/** + * An instance of the C++11 `decltype` operator or C23 `typeof`/`typeof_unqual` + * operator taking an expression as its argument. For example: + * ``` + * int a; + * decltype(1+a) b; + * typeof(1+a) c; + * ``` + * Here `expr` is `1+a`. + * + * Sometimes an additional pair of parentheses around the expression + * changes the semantics of the decltype, e.g. + * ``` + * struct A { double x; }; + * const A* a = new A(); + * decltype( a->x ); // type is double + * decltype((a->x)); // type is const double& + * ``` + * (Please consult the C++11 standard for more details). + * `parentheses_would_change_meaning` is `true` iff that is the case. + */ + +/* +case @decltype.kind of +| 0 = @decltype +| 1 = @typeof // The frontend does not differentiate between typeof and typeof_unqual +; +*/ + +#keyset[id, expr] +decltypes( + int id: @decltype, + int expr: @expr ref, + int kind: int ref, + int base_type: @type ref, + boolean parentheses_would_change_meaning: boolean ref +); + +case @type_operator.kind of + 0 = @typeof // The frontend does not differentiate between typeof and typeof_unqual +| 1 = @underlying_type +| 2 = @bases +| 3 = @direct_bases +| 4 = @add_lvalue_reference +| 5 = @add_pointer +| 6 = @add_rvalue_reference +| 7 = @decay +| 8 = @make_signed +| 9 = @make_unsigned +| 10 = @remove_all_extents +| 11 = @remove_const +| 12 = @remove_cv +| 13 = @remove_cvref +| 14 = @remove_extent +| 15 = @remove_pointer +| 16 = @remove_reference_t +| 17 = @remove_restrict +| 18 = @remove_volatile +| 19 = @remove_reference +; + +type_operators( + unique int id: @type_operator, + int arg_type: @type ref, + int kind: int ref, + int base_type: @type ref +) + +case @usertype.kind of + 0 = @unknown_usertype +| 1 = @struct +| 2 = @class +| 3 = @union +| 4 = @enum +// ... 5 = @typedef deprecated // classic C: typedef typedef type name +// ... 6 = @template deprecated +| 7 = @template_parameter +| 8 = @template_template_parameter +| 9 = @proxy_class // a proxy class associated with a template parameter +// ... 10 objc_class deprecated +// ... 11 objc_protocol deprecated +// ... 12 objc_category deprecated +| 13 = @scoped_enum +// ... 14 = @using_alias deprecated // a using name = type style typedef +| 15 = @template_struct +| 16 = @template_class +| 17 = @template_union +| 18 = @alias +; + +usertypes( + unique int id: @usertype, + string name: string ref, + int kind: int ref +); + +usertypesize( + unique int id: @usertype ref, + int size: int ref, + int alignment: int ref +); + +usertype_final(unique int id: @usertype ref); + +usertype_uuid( + unique int id: @usertype ref, + string uuid: string ref +); + +/* +case @usertype.alias_kind of +| 0 = @typedef +| 1 = @alias +*/ + +usertype_alias_kind( + int id: @usertype ref, + int alias_kind: int ref +) + +nontype_template_parameters( + int id: @expr ref +); + +type_template_type_constraint( + int id: @usertype ref, + int constraint: @expr ref +); + +mangled_name( + unique int id: @declaration ref, + int mangled_name : @mangledname, + boolean is_complete: boolean ref +); + +is_pod_class(unique int id: @usertype ref); +is_standard_layout_class(unique int id: @usertype ref); + +is_complete(unique int id: @usertype ref); + +is_class_template(unique int id: @usertype ref); +class_instantiation( + int to: @usertype ref, + int from: @usertype ref +); +class_template_argument( + int type_id: @usertype ref, + int index: int ref, + int arg_type: @type ref +); +class_template_argument_value( + int type_id: @usertype ref, + int index: int ref, + int arg_value: @expr ref +); +class_template_generated_from( + unique int template: @usertype ref, + int from: @usertype ref +) + +@user_or_decltype = @usertype | @decltype; + +is_proxy_class_for( + unique int id: @usertype ref, + int templ_param_id: @user_or_decltype ref +); + +type_mentions( + unique int id: @type_mention, + int type_id: @type ref, + int location: @location_default ref, + // a_symbol_reference_kind from the frontend. + int kind: int ref +); + +is_function_template(unique int id: @function ref); +function_instantiation( + unique int to: @function ref, + int from: @function ref +); +function_template_argument( + int function_id: @function ref, + int index: int ref, + int arg_type: @type ref +); +function_template_argument_value( + int function_id: @function ref, + int index: int ref, + int arg_value: @expr ref +); +function_template_generated_from( + unique int template: @function ref, + int from: @function ref +); + +is_variable_template(unique int id: @variable ref); +variable_instantiation( + unique int to: @variable ref, + int from: @variable ref +); +variable_template_argument( + int variable_id: @variable ref, + int index: int ref, + int arg_type: @type ref +); +variable_template_argument_value( + int variable_id: @variable ref, + int index: int ref, + int arg_value: @expr ref +); +variable_template_generated_from( + unique int template: @variable ref, + int from: @variable ref +); + +is_alias_template(unique int id: @usertype ref); +alias_instantiation( + unique int to: @usertype ref, + int from: @usertype ref +); +alias_template_argument( + int type_id: @usertype ref, + int index: int ref, + int arg_type: @type ref +); +alias_template_argument_value( + int type_id: @usertype ref, + int index: int ref, + int arg_value: @expr ref +); +alias_template_generated_from( + unique int template: @usertype ref, + int from: @usertype ref +); + +template_template_instantiation( + int to: @usertype ref, + int from: @usertype ref +); +template_template_argument( + int type_id: @usertype ref, + int index: int ref, + int arg_type: @type ref +); +template_template_argument_value( + int type_id: @usertype ref, + int index: int ref, + int arg_value: @expr ref +); + +@concept = @concept_template | @concept_id; + +concept_templates( + unique int concept_id: @concept_template, + string name: string ref, + int location: @location_default ref +); +concept_instantiation( + unique int to: @concept_id ref, + int from: @concept_template ref +); +is_type_constraint(int concept_id: @concept_id ref); +concept_template_argument( + int concept_id: @concept ref, + int index: int ref, + int arg_type: @type ref +); +concept_template_argument_value( + int concept_id: @concept ref, + int index: int ref, + int arg_value: @expr ref +); + +routinetypes( + unique int id: @routinetype, + int return_type: @type ref +); + +routinetypeargs( + int routine: @routinetype ref, + int index: int ref, + int type_id: @type ref +); + +ptrtomembers( + unique int id: @ptrtomember, + int type_id: @type ref, + int class_id: @type ref +); + +/* + specifiers for types, functions, and variables + + "public", + "protected", + "private", + + "const", + "volatile", + "static", + + "pure", + "virtual", + "sealed", // Microsoft + "__interface", // Microsoft + "inline", + "explicit", + + "near", // near far extension + "far", // near far extension + "__ptr32", // Microsoft + "__ptr64", // Microsoft + "__sptr", // Microsoft + "__uptr", // Microsoft + "dllimport", // Microsoft + "dllexport", // Microsoft + "thread", // Microsoft + "naked", // Microsoft + "microsoft_inline", // Microsoft + "forceinline", // Microsoft + "selectany", // Microsoft + "nothrow", // Microsoft + "novtable", // Microsoft + "noreturn", // Microsoft + "noinline", // Microsoft + "noalias", // Microsoft + "restrict", // Microsoft +*/ + +specifiers( + unique int id: @specifier, + unique string str: string ref +); + +typespecifiers( + int type_id: @type ref, + int spec_id: @specifier ref +); + +funspecifiers( + int func_id: @function ref, + int spec_id: @specifier ref +); + +varspecifiers( + int var_id: @accessible ref, + int spec_id: @specifier ref +); + +explicit_specifier_exprs( + unique int func_id: @function ref, + int constant: @expr ref +) + +attributes( + unique int id: @attribute, + int kind: int ref, + string name: string ref, + string name_space: string ref, + int location: @location_default ref +); + +case @attribute.kind of + 0 = @gnuattribute +| 1 = @stdattribute +| 2 = @declspec +| 3 = @msattribute +| 4 = @alignas +// ... 5 @objc_propertyattribute deprecated +; + +attribute_args( + unique int id: @attribute_arg, + int kind: int ref, + int attribute: @attribute ref, + int index: int ref, + int location: @location_default ref +); + +case @attribute_arg.kind of + 0 = @attribute_arg_empty +| 1 = @attribute_arg_token +| 2 = @attribute_arg_constant +| 3 = @attribute_arg_type +| 4 = @attribute_arg_constant_expr +| 5 = @attribute_arg_expr +; + +attribute_arg_value( + unique int arg: @attribute_arg ref, + string value: string ref +); +attribute_arg_type( + unique int arg: @attribute_arg ref, + int type_id: @type ref +); +attribute_arg_constant( + unique int arg: @attribute_arg ref, + int constant: @expr ref +) +attribute_arg_expr( + unique int arg: @attribute_arg ref, + int expr: @expr ref +) +attribute_arg_name( + unique int arg: @attribute_arg ref, + string name: string ref +); + +typeattributes( + int type_id: @type ref, + int spec_id: @attribute ref +); + +funcattributes( + int func_id: @function ref, + int spec_id: @attribute ref +); + +varattributes( + int var_id: @accessible ref, + int spec_id: @attribute ref +); + +namespaceattributes( + int namespace_id: @namespace ref, + int spec_id: @attribute ref +); + +stmtattributes( + int stmt_id: @stmt ref, + int spec_id: @attribute ref +); + +@type = @builtintype + | @derivedtype + | @usertype + | @routinetype + | @ptrtomember + | @decltype + | @type_operator; + +unspecifiedtype( + unique int type_id: @type ref, + int unspecified_type_id: @type ref +); + +member( + int parent: @type ref, + int index: int ref, + int child: @member ref +); + +@enclosingfunction_child = @usertype | @variable | @namespace + +enclosingfunction( + unique int child: @enclosingfunction_child ref, + int parent: @function ref +); + +derivations( + unique int derivation: @derivation, + int sub: @type ref, + int index: int ref, + int super: @type ref, + int location: @location_default ref +); + +derspecifiers( + int der_id: @derivation ref, + int spec_id: @specifier ref +); + +/** + * Contains the byte offset of the base class subobject within the derived + * class. Only holds for non-virtual base classes, but see table + * `virtual_base_offsets` for offsets of virtual base class subobjects. + */ +direct_base_offsets( + unique int der_id: @derivation ref, + int offset: int ref +); + +/** + * Contains the byte offset of the virtual base class subobject for class + * `super` within a most-derived object of class `sub`. `super` can be either a + * direct or indirect base class. + */ +#keyset[sub, super] +virtual_base_offsets( + int sub: @usertype ref, + int super: @usertype ref, + int offset: int ref +); + +frienddecls( + unique int id: @frienddecl, + int type_id: @type ref, + int decl_id: @declaration ref, + int location: @location_default ref +); + +@declaredtype = @usertype ; + +@declaration = @function + | @declaredtype + | @variable + | @enumconstant + | @frienddecl + | @concept_template; + +@member = @membervariable + | @function + | @declaredtype + | @enumconstant; + +@locatable = @diagnostic + | @declaration + | @ppd_include + | @ppd_define + | @macroinvocation + /*| @funcall*/ + | @xmllocatable + | @attribute + | @attribute_arg; + +@namedscope = @namespace | @usertype; + +@element = @locatable + | @file + | @folder + | @specifier + | @type + | @expr + | @namespace + | @initialiser + | @stmt + | @derivation + | @comment + | @preprocdirect + | @fun_decl + | @var_decl + | @type_decl + | @namespace_decl + | @using + | @namequalifier + | @specialnamequalifyingelement + | @static_assert + | @type_mention + | @lambdacapture; + +@exprparent = @element; + +comments( + unique int id: @comment, + string contents: string ref, + int location: @location_default ref +); + +commentbinding( + int id: @comment ref, + int element: @element ref +); + +exprconv( + int converted: @expr ref, + unique int conversion: @expr ref +); + +compgenerated(unique int id: @element ref); + +/** + * `destructor_call` destructs the `i`'th entity that should be + * destructed following `element`. Note that entities should be + * destructed in reverse construction order, so for a given `element` + * these should be called from highest to lowest `i`. + */ +#keyset[element, destructor_call] +#keyset[element, i] +synthetic_destructor_call( + int element: @element ref, + int i: int ref, + int destructor_call: @routineexpr ref +); + +namespaces( + unique int id: @namespace, + string name: string ref +); + +namespace_inline( + unique int id: @namespace ref +); + +namespacembrs( + int parentid: @namespace ref, + unique int memberid: @namespacembr ref +); + +@namespacembr = @declaration | @namespace; + +exprparents( + int expr_id: @expr ref, + int child_index: int ref, + int parent_id: @exprparent ref +); + +expr_isload(unique int expr_id: @expr ref); + +@cast = @c_style_cast + | @const_cast + | @dynamic_cast + | @reinterpret_cast + | @static_cast + ; + +/* +case @conversion.kind of + 0 = @simple_conversion // a numeric conversion, qualification conversion, or a reinterpret_cast +| 1 = @bool_conversion // conversion to 'bool' +| 2 = @base_class_conversion // a derived-to-base conversion +| 3 = @derived_class_conversion // a base-to-derived conversion +| 4 = @pm_base_class_conversion // a derived-to-base conversion of a pointer to member +| 5 = @pm_derived_class_conversion // a base-to-derived conversion of a pointer to member +| 6 = @glvalue_adjust // an adjustment of the type of a glvalue +| 7 = @prvalue_adjust // an adjustment of the type of a prvalue +; +*/ +/** + * Describes the semantics represented by a cast expression. This is largely + * independent of the source syntax of the cast, so it is separate from the + * regular expression kind. + */ +conversionkinds( + unique int expr_id: @cast ref, + int kind: int ref +); + +@conversion = @cast + | @array_to_pointer + | @parexpr + | @reference_to + | @ref_indirect + | @temp_init + | @c11_generic + ; + +/* +case @funbindexpr.kind of + 0 = @normal_call // a normal call +| 1 = @virtual_call // a virtual call +| 2 = @adl_call // a call whose target is only found by ADL +; +*/ +iscall( + unique int caller: @funbindexpr ref, + int kind: int ref +); + +numtemplatearguments( + unique int expr_id: @expr ref, + int num: int ref +); + +specialnamequalifyingelements( + unique int id: @specialnamequalifyingelement, + unique string name: string ref +); + +@namequalifiableelement = @expr | @namequalifier; +@namequalifyingelement = @namespace + | @specialnamequalifyingelement + | @usertype + | @decltype + | @derivedtype; + +namequalifiers( + unique int id: @namequalifier, + unique int qualifiableelement: @namequalifiableelement ref, + int qualifyingelement: @namequalifyingelement ref, + int location: @location_default ref +); + +varbind( + int expr: @varbindexpr ref, + int var: @accessible ref +); + +funbind( + int expr: @funbindexpr ref, + int fun: @function ref +); + +@any_new_expr = @new_expr + | @new_array_expr; + +@new_or_delete_expr = @any_new_expr + | @delete_expr + | @delete_array_expr; + +@prefix_crement_expr = @preincrexpr | @predecrexpr; + +@postfix_crement_expr = @postincrexpr | @postdecrexpr; + +@increment_expr = @preincrexpr | @postincrexpr; + +@decrement_expr = @predecrexpr | @postdecrexpr; + +@crement_expr = @increment_expr | @decrement_expr; + +@un_arith_op_expr = @arithnegexpr + | @unaryplusexpr + | @conjugation + | @realpartexpr + | @imagpartexpr + | @crement_expr + ; + +@un_bitwise_op_expr = @complementexpr; + +@un_log_op_expr = @notexpr; + +@un_op_expr = @address_of + | @indirect + | @un_arith_op_expr + | @un_bitwise_op_expr + | @builtinaddressof + | @vec_fill + | @un_log_op_expr + | @co_await + | @co_yield + ; + +@bin_log_op_expr = @andlogicalexpr | @orlogicalexpr; + +@cmp_op_expr = @eq_op_expr | @rel_op_expr; + +@eq_op_expr = @eqexpr | @neexpr; + +@rel_op_expr = @gtexpr + | @ltexpr + | @geexpr + | @leexpr + | @spaceshipexpr + ; + +@bin_bitwise_op_expr = @lshiftexpr + | @rshiftexpr + | @andexpr + | @orexpr + | @xorexpr + ; + +@p_arith_op_expr = @paddexpr + | @psubexpr + | @pdiffexpr + ; + +@bin_arith_op_expr = @addexpr + | @subexpr + | @mulexpr + | @divexpr + | @remexpr + | @jmulexpr + | @jdivexpr + | @fjaddexpr + | @jfaddexpr + | @fjsubexpr + | @jfsubexpr + | @minexpr + | @maxexpr + | @p_arith_op_expr + ; + +@bin_op_expr = @bin_arith_op_expr + | @bin_bitwise_op_expr + | @cmp_op_expr + | @bin_log_op_expr + ; + +@op_expr = @un_op_expr + | @bin_op_expr + | @assign_expr + | @conditionalexpr + ; + +@assign_arith_expr = @assignaddexpr + | @assignsubexpr + | @assignmulexpr + | @assigndivexpr + | @assignremexpr + ; + +@assign_bitwise_expr = @assignandexpr + | @assignorexpr + | @assignxorexpr + | @assignlshiftexpr + | @assignrshiftexpr + ; + +@assign_pointer_expr = @assignpaddexpr + | @assignpsubexpr + ; + +@assign_op_expr = @assign_arith_expr + | @assign_bitwise_expr + | @assign_pointer_expr + ; + +@assign_expr = @assignexpr | @assign_op_expr | @blockassignexpr + +/* + Binary encoding of the allocator form. + + case @allocator.form of + 0 = plain + | 1 = alignment + ; +*/ + +/** + * The allocator function associated with a `new` or `new[]` expression. + * The `form` column specified whether the allocation call contains an alignment + * argument. + */ +expr_allocator( + unique int expr: @any_new_expr ref, + int func: @function ref, + int form: int ref +); + +/* + Binary encoding of the deallocator form. + + case @deallocator.form of + 0 = plain + | 1 = size + | 2 = alignment + | 4 = destroying_delete + ; +*/ + +/** + * The deallocator function associated with a `delete`, `delete[]`, `new`, or + * `new[]` expression. For a `new` or `new[]` expression, the deallocator is the + * one used to free memory if the initialization throws an exception. + * The `form` column specifies whether the deallocation call contains a size + * argument, and alignment argument, or both. + */ +expr_deallocator( + unique int expr: @new_or_delete_expr ref, + int func: @function ref, + int form: int ref +); + +/** + * Holds if the `@conditionalexpr` is of the two operand form + * `guard ? : false`. + */ +expr_cond_two_operand( + unique int cond: @conditionalexpr ref +); + +/** + * The guard of `@conditionalexpr` `guard ? true : false` + */ +expr_cond_guard( + unique int cond: @conditionalexpr ref, + int guard: @expr ref +); + +/** + * The expression used when the guard of `@conditionalexpr` + * `guard ? true : false` holds. For the two operand form + * `guard ?: false` consider using `expr_cond_guard` instead. + */ +expr_cond_true( + unique int cond: @conditionalexpr ref, + int true: @expr ref +); + +/** + * The expression used when the guard of `@conditionalexpr` + * `guard ? true : false` does not hold. + */ +expr_cond_false( + unique int cond: @conditionalexpr ref, + int false: @expr ref +); + +/** A string representation of the value. */ +values( + unique int id: @value, + string str: string ref +); + +/** The actual text in the source code for the value, if any. */ +valuetext( + unique int id: @value ref, + string text: string ref +); + +valuebind( + int val: @value ref, + unique int expr: @expr ref +); + +fieldoffsets( + unique int id: @variable ref, + int byteoffset: int ref, + int bitoffset: int ref +); + +bitfield( + unique int id: @variable ref, + int bits: int ref, + int declared_bits: int ref +); + +/* TODO +memberprefix( + int member: @expr ref, + int prefix: @expr ref +); +*/ + +/* + kind(1) = mbrcallexpr + kind(2) = mbrptrcallexpr + kind(3) = mbrptrmbrcallexpr + kind(4) = ptrmbrptrmbrcallexpr + kind(5) = mbrreadexpr // x.y + kind(6) = mbrptrreadexpr // p->y + kind(7) = mbrptrmbrreadexpr // x.*pm + kind(8) = mbrptrmbrptrreadexpr // x->*pm + kind(9) = staticmbrreadexpr // static x.y + kind(10) = staticmbrptrreadexpr // static p->y +*/ +/* TODO +memberaccess( + int member: @expr ref, + int kind: int ref +); +*/ + +initialisers( + unique int init: @initialiser, + int var: @accessible ref, + unique int expr: @expr ref, + int location: @location_default ref +); + +braced_initialisers( + int init: @initialiser ref +); + +/** + * An ancestor for the expression, for cases in which we cannot + * otherwise find the expression's parent. + */ +expr_ancestor( + int exp: @expr ref, + int ancestor: @element ref +); + +exprs( + unique int id: @expr, + int kind: int ref, + int location: @location_default ref +); + +expr_reuse( + int reuse: @expr ref, + int original: @expr ref, + int value_category: int ref +) + +/* + case @value.category of + 1 = prval + | 2 = xval + | 3 = lval + ; +*/ +expr_types( + int id: @expr ref, + int typeid: @type ref, + int value_category: int ref +); + +case @expr.kind of + 1 = @errorexpr +| 2 = @address_of // & AddressOfExpr +| 3 = @reference_to // ReferenceToExpr (implicit?) +| 4 = @indirect // * PointerDereferenceExpr +| 5 = @ref_indirect // ReferenceDereferenceExpr (implicit?) +// ... +| 8 = @array_to_pointer // (???) +| 9 = @vacuous_destructor_call // VacuousDestructorCall +// ... +| 11 = @assume // Microsoft +| 12 = @parexpr +| 13 = @arithnegexpr +| 14 = @unaryplusexpr +| 15 = @complementexpr +| 16 = @notexpr +| 17 = @conjugation // GNU ~ operator +| 18 = @realpartexpr // GNU __real +| 19 = @imagpartexpr // GNU __imag +| 20 = @postincrexpr +| 21 = @postdecrexpr +| 22 = @preincrexpr +| 23 = @predecrexpr +| 24 = @conditionalexpr +| 25 = @addexpr +| 26 = @subexpr +| 27 = @mulexpr +| 28 = @divexpr +| 29 = @remexpr +| 30 = @jmulexpr // C99 mul imaginary +| 31 = @jdivexpr // C99 div imaginary +| 32 = @fjaddexpr // C99 add real + imaginary +| 33 = @jfaddexpr // C99 add imaginary + real +| 34 = @fjsubexpr // C99 sub real - imaginary +| 35 = @jfsubexpr // C99 sub imaginary - real +| 36 = @paddexpr // pointer add (pointer + int or int + pointer) +| 37 = @psubexpr // pointer sub (pointer - integer) +| 38 = @pdiffexpr // difference between two pointers +| 39 = @lshiftexpr +| 40 = @rshiftexpr +| 41 = @andexpr +| 42 = @orexpr +| 43 = @xorexpr +| 44 = @eqexpr +| 45 = @neexpr +| 46 = @gtexpr +| 47 = @ltexpr +| 48 = @geexpr +| 49 = @leexpr +| 50 = @minexpr // GNU minimum +| 51 = @maxexpr // GNU maximum +| 52 = @assignexpr +| 53 = @assignaddexpr +| 54 = @assignsubexpr +| 55 = @assignmulexpr +| 56 = @assigndivexpr +| 57 = @assignremexpr +| 58 = @assignlshiftexpr +| 59 = @assignrshiftexpr +| 60 = @assignandexpr +| 61 = @assignorexpr +| 62 = @assignxorexpr +| 63 = @assignpaddexpr // assign pointer add +| 64 = @assignpsubexpr // assign pointer sub +| 65 = @andlogicalexpr +| 66 = @orlogicalexpr +| 67 = @commaexpr +| 68 = @subscriptexpr // access to member of an array, e.g., a[5] +// ... 69 @objc_subscriptexpr deprecated +// ... 70 @cmdaccess deprecated +// ... +| 73 = @virtfunptrexpr +| 74 = @callexpr +// ... 75 @msgexpr_normal deprecated +// ... 76 @msgexpr_super deprecated +// ... 77 @atselectorexpr deprecated +// ... 78 @atprotocolexpr deprecated +| 79 = @vastartexpr +| 80 = @vaargexpr +| 81 = @vaendexpr +| 82 = @vacopyexpr +// ... 83 @atencodeexpr deprecated +| 84 = @varaccess +| 85 = @thisaccess +// ... 86 @objc_box_expr deprecated +| 87 = @new_expr +| 88 = @delete_expr +| 89 = @throw_expr +| 90 = @condition_decl // a variable declared in a condition, e.g., if(int x = y > 2) +| 91 = @braced_init_list +| 92 = @type_id +| 93 = @runtime_sizeof +| 94 = @runtime_alignof +| 95 = @sizeof_pack +| 96 = @expr_stmt // GNU extension +| 97 = @routineexpr +| 98 = @type_operand // used to access a type in certain contexts (haven't found any examples yet....) +| 99 = @offsetofexpr // offsetof ::= type and field +| 100 = @hasassignexpr // __has_assign ::= type +| 101 = @hascopyexpr // __has_copy ::= type +| 102 = @hasnothrowassign // __has_nothrow_assign ::= type +| 103 = @hasnothrowconstr // __has_nothrow_constructor ::= type +| 104 = @hasnothrowcopy // __has_nothrow_copy ::= type +| 105 = @hastrivialassign // __has_trivial_assign ::= type +| 106 = @hastrivialconstr // __has_trivial_constructor ::= type +| 107 = @hastrivialcopy // __has_trivial_copy ::= type +| 108 = @hasuserdestr // __has_user_destructor ::= type +| 109 = @hasvirtualdestr // __has_virtual_destructor ::= type +| 110 = @isabstractexpr // __is_abstract ::= type +| 111 = @isbaseofexpr // __is_base_of ::= type type +| 112 = @isclassexpr // __is_class ::= type +| 113 = @isconvtoexpr // __is_convertible_to ::= type type +| 114 = @isemptyexpr // __is_empty ::= type +| 115 = @isenumexpr // __is_enum ::= type +| 116 = @ispodexpr // __is_pod ::= type +| 117 = @ispolyexpr // __is_polymorphic ::= type +| 118 = @isunionexpr // __is_union ::= type +| 119 = @typescompexpr // GNU __builtin_types_compatible ::= type type +| 120 = @intaddrexpr // frontend internal builtin, used to implement offsetof +// ... +| 122 = @hastrivialdestructor // __has_trivial_destructor ::= type +| 123 = @literal +| 124 = @uuidof +| 127 = @aggregateliteral +| 128 = @delete_array_expr +| 129 = @new_array_expr +// ... 130 @objc_array_literal deprecated +// ... 131 @objc_dictionary_literal deprecated +| 132 = @foldexpr +// ... +| 200 = @ctordirectinit +| 201 = @ctorvirtualinit +| 202 = @ctorfieldinit +| 203 = @ctordelegatinginit +| 204 = @dtordirectdestruct +| 205 = @dtorvirtualdestruct +| 206 = @dtorfielddestruct +// ... +| 210 = @static_cast +| 211 = @reinterpret_cast +| 212 = @const_cast +| 213 = @dynamic_cast +| 214 = @c_style_cast +| 215 = @lambdaexpr +| 216 = @param_ref +| 217 = @noopexpr +// ... +| 294 = @istriviallyconstructibleexpr +| 295 = @isdestructibleexpr +| 296 = @isnothrowdestructibleexpr +| 297 = @istriviallydestructibleexpr +| 298 = @istriviallyassignableexpr +| 299 = @isnothrowassignableexpr +| 300 = @istrivialexpr +| 301 = @isstandardlayoutexpr +| 302 = @istriviallycopyableexpr +| 303 = @isliteraltypeexpr +| 304 = @hastrivialmoveconstructorexpr +| 305 = @hastrivialmoveassignexpr +| 306 = @hasnothrowmoveassignexpr +| 307 = @isconstructibleexpr +| 308 = @isnothrowconstructibleexpr +| 309 = @hasfinalizerexpr +| 310 = @isdelegateexpr +| 311 = @isinterfaceclassexpr +| 312 = @isrefarrayexpr +| 313 = @isrefclassexpr +| 314 = @issealedexpr +| 315 = @issimplevalueclassexpr +| 316 = @isvalueclassexpr +| 317 = @isfinalexpr +| 319 = @noexceptexpr +| 320 = @builtinshufflevector +| 321 = @builtinchooseexpr +| 322 = @builtinaddressof +| 323 = @vec_fill +| 324 = @builtinconvertvector +| 325 = @builtincomplex +| 326 = @spaceshipexpr +| 327 = @co_await +| 328 = @co_yield +| 329 = @temp_init +| 330 = @isassignable +| 331 = @isaggregate +| 332 = @hasuniqueobjectrepresentations +| 333 = @builtinbitcast +| 334 = @builtinshuffle +| 335 = @blockassignexpr +| 336 = @issame +| 337 = @isfunction +| 338 = @islayoutcompatible +| 339 = @ispointerinterconvertiblebaseof +| 340 = @isarray +| 341 = @arrayrank +| 342 = @arrayextent +| 343 = @isarithmetic +| 344 = @iscompletetype +| 345 = @iscompound +| 346 = @isconst +| 347 = @isfloatingpoint +| 348 = @isfundamental +| 349 = @isintegral +| 350 = @islvaluereference +| 351 = @ismemberfunctionpointer +| 352 = @ismemberobjectpointer +| 353 = @ismemberpointer +| 354 = @isobject +| 355 = @ispointer +| 356 = @isreference +| 357 = @isrvaluereference +| 358 = @isscalar +| 359 = @issigned +| 360 = @isunsigned +| 361 = @isvoid +| 362 = @isvolatile +| 363 = @reuseexpr +| 364 = @istriviallycopyassignable +| 365 = @isassignablenopreconditioncheck +| 366 = @referencebindstotemporary +| 367 = @issameas +| 368 = @builtinhasattribute +| 369 = @ispointerinterconvertiblewithclass +| 370 = @builtinispointerinterconvertiblewithclass +| 371 = @iscorrespondingmember +| 372 = @builtiniscorrespondingmember +| 373 = @isboundedarray +| 374 = @isunboundedarray +| 375 = @isreferenceable +| 378 = @isnothrowconvertible +| 379 = @referenceconstructsfromtemporary +| 380 = @referenceconvertsfromtemporary +| 381 = @isconvertible +| 382 = @isvalidwinrttype +| 383 = @iswinclass +| 384 = @iswininterface +| 385 = @istriviallyequalitycomparable +| 386 = @isscopedenum +| 387 = @istriviallyrelocatable +| 388 = @datasizeof +| 389 = @c11_generic +| 390 = @requires_expr +| 391 = @nested_requirement +| 392 = @compound_requirement +| 393 = @concept_id +| 394 = @isinvocable +| 395 = @isnothrowinvocable +| 396 = @isbitwisecloneable +; + +@var_args_expr = @vastartexpr + | @vaendexpr + | @vaargexpr + | @vacopyexpr + ; + +@builtin_op = @var_args_expr + | @noopexpr + | @offsetofexpr + | @intaddrexpr + | @hasassignexpr + | @hascopyexpr + | @hasnothrowassign + | @hasnothrowconstr + | @hasnothrowcopy + | @hastrivialassign + | @hastrivialconstr + | @hastrivialcopy + | @hastrivialdestructor + | @hasuserdestr + | @hasvirtualdestr + | @isabstractexpr + | @isbaseofexpr + | @isclassexpr + | @isconvtoexpr + | @isemptyexpr + | @isenumexpr + | @ispodexpr + | @ispolyexpr + | @isunionexpr + | @typescompexpr + | @builtinshufflevector + | @builtinconvertvector + | @builtinaddressof + | @istriviallyconstructibleexpr + | @isdestructibleexpr + | @isnothrowdestructibleexpr + | @istriviallydestructibleexpr + | @istriviallyassignableexpr + | @isnothrowassignableexpr + | @istrivialexpr + | @isstandardlayoutexpr + | @istriviallycopyableexpr + | @isliteraltypeexpr + | @hastrivialmoveconstructorexpr + | @hastrivialmoveassignexpr + | @hasnothrowmoveassignexpr + | @isconstructibleexpr + | @isnothrowconstructibleexpr + | @hasfinalizerexpr + | @isdelegateexpr + | @isinterfaceclassexpr + | @isrefarrayexpr + | @isrefclassexpr + | @issealedexpr + | @issimplevalueclassexpr + | @isvalueclassexpr + | @isfinalexpr + | @builtinchooseexpr + | @builtincomplex + | @isassignable + | @isaggregate + | @hasuniqueobjectrepresentations + | @builtinbitcast + | @builtinshuffle + | @issame + | @isfunction + | @islayoutcompatible + | @ispointerinterconvertiblebaseof + | @isarray + | @arrayrank + | @arrayextent + | @isarithmetic + | @iscompletetype + | @iscompound + | @isconst + | @isfloatingpoint + | @isfundamental + | @isintegral + | @islvaluereference + | @ismemberfunctionpointer + | @ismemberobjectpointer + | @ismemberpointer + | @isobject + | @ispointer + | @isreference + | @isrvaluereference + | @isscalar + | @issigned + | @isunsigned + | @isvoid + | @isvolatile + | @istriviallycopyassignable + | @isassignablenopreconditioncheck + | @referencebindstotemporary + | @issameas + | @builtinhasattribute + | @ispointerinterconvertiblewithclass + | @builtinispointerinterconvertiblewithclass + | @iscorrespondingmember + | @builtiniscorrespondingmember + | @isboundedarray + | @isunboundedarray + | @isreferenceable + | @isnothrowconvertible + | @referenceconstructsfromtemporary + | @referenceconvertsfromtemporary + | @isconvertible + | @isvalidwinrttype + | @iswinclass + | @iswininterface + | @istriviallyequalitycomparable + | @isscopedenum + | @istriviallyrelocatable + | @isinvocable + | @isnothrowinvocable + | @isbitwisecloneable + ; + +compound_requirement_is_noexcept( + int expr: @compound_requirement ref +); + +new_allocated_type( + unique int expr: @new_expr ref, + int type_id: @type ref +); + +new_array_allocated_type( + unique int expr: @new_array_expr ref, + int type_id: @type ref +); + +param_ref_to_this( + int expr: @param_ref ref +) + +/** + * The field being initialized by an initializer expression within an aggregate + * initializer for a class/struct/union. Position is used to sort repeated initializers. + */ +#keyset[aggregate, position] +aggregate_field_init( + int aggregate: @aggregateliteral ref, + int initializer: @expr ref, + int field: @membervariable ref, + int position: int ref, + boolean is_designated: boolean ref +); + +/** + * The index of the element being initialized by an initializer expression + * within an aggregate initializer for an array. Position is used to sort repeated initializers. + */ +#keyset[aggregate, position] +aggregate_array_init( + int aggregate: @aggregateliteral ref, + int initializer: @expr ref, + int element_index: int ref, + int position: int ref, + boolean is_designated: boolean ref +); + +@ctorinit = @ctordirectinit + | @ctorvirtualinit + | @ctorfieldinit + | @ctordelegatinginit; +@dtordestruct = @dtordirectdestruct + | @dtorvirtualdestruct + | @dtorfielddestruct; + + +condition_decl_bind( + unique int expr: @condition_decl ref, + unique int decl: @declaration ref +); + +typeid_bind( + unique int expr: @type_id ref, + int type_id: @type ref +); + +uuidof_bind( + unique int expr: @uuidof ref, + int type_id: @type ref +); + +@sizeof_or_alignof = @runtime_sizeof | @runtime_alignof | @datasizeof | @sizeof_pack; + +sizeof_bind( + unique int expr: @sizeof_or_alignof ref, + int type_id: @type ref +); + +code_block( + unique int block: @literal ref, + unique int routine: @function ref +); + +lambdas( + unique int expr: @lambdaexpr ref, + string default_capture: string ref, + boolean has_explicit_return_type: boolean ref, + boolean has_explicit_parameter_list: boolean ref +); + +lambda_capture( + unique int id: @lambdacapture, + int lambda: @lambdaexpr ref, + int index: int ref, + int field: @membervariable ref, + boolean captured_by_reference: boolean ref, + boolean is_implicit: boolean ref, + int location: @location_default ref +); + +@funbindexpr = @routineexpr + | @new_expr + | @delete_expr + | @delete_array_expr + | @ctordirectinit + | @ctorvirtualinit + | @ctordelegatinginit + | @dtordirectdestruct + | @dtorvirtualdestruct; + +@varbindexpr = @varaccess | @ctorfieldinit | @dtorfielddestruct; +@addressable = @function | @variable ; +@accessible = @addressable | @enumconstant ; + +@access = @varaccess | @routineexpr ; + +fold( + int expr: @foldexpr ref, + string operator: string ref, + boolean is_left_fold: boolean ref +); + +stmts( + unique int id: @stmt, + int kind: int ref, + int location: @location_default ref +); + +case @stmt.kind of + 1 = @stmt_expr +| 2 = @stmt_if +| 3 = @stmt_while +| 4 = @stmt_goto +| 5 = @stmt_label +| 6 = @stmt_return +| 7 = @stmt_block +| 8 = @stmt_end_test_while // do { ... } while ( ... ) +| 9 = @stmt_for +| 10 = @stmt_switch_case +| 11 = @stmt_switch +| 13 = @stmt_asm // "asm" statement or the body of an asm function +| 15 = @stmt_try_block +| 16 = @stmt_microsoft_try // Microsoft +| 17 = @stmt_decl +| 18 = @stmt_set_vla_size // C99 +| 19 = @stmt_vla_decl // C99 +| 25 = @stmt_assigned_goto // GNU +| 26 = @stmt_empty +| 27 = @stmt_continue +| 28 = @stmt_break +| 29 = @stmt_range_based_for // C++11 +// ... 30 @stmt_at_autoreleasepool_block deprecated +// ... 31 @stmt_objc_for_in deprecated +// ... 32 @stmt_at_synchronized deprecated +| 33 = @stmt_handler +// ... 34 @stmt_finally_end deprecated +| 35 = @stmt_constexpr_if +| 37 = @stmt_co_return +| 38 = @stmt_consteval_if +| 39 = @stmt_not_consteval_if +| 40 = @stmt_leave +; + +type_vla( + int type_id: @type ref, + int decl: @stmt_vla_decl ref +); + +variable_vla( + int var: @variable ref, + int decl: @stmt_vla_decl ref +); + +type_is_vla(unique int type_id: @derivedtype ref) + +if_initialization( + unique int if_stmt: @stmt_if ref, + int init_id: @stmt ref +); + +if_then( + unique int if_stmt: @stmt_if ref, + int then_id: @stmt ref +); + +if_else( + unique int if_stmt: @stmt_if ref, + int else_id: @stmt ref +); + +constexpr_if_initialization( + unique int constexpr_if_stmt: @stmt_constexpr_if ref, + int init_id: @stmt ref +); + +constexpr_if_then( + unique int constexpr_if_stmt: @stmt_constexpr_if ref, + int then_id: @stmt ref +); + +constexpr_if_else( + unique int constexpr_if_stmt: @stmt_constexpr_if ref, + int else_id: @stmt ref +); + +@stmt_consteval_or_not_consteval_if = @stmt_consteval_if | @stmt_not_consteval_if; + +consteval_if_then( + unique int constexpr_if_stmt: @stmt_consteval_or_not_consteval_if ref, + int then_id: @stmt ref +); + +consteval_if_else( + unique int constexpr_if_stmt: @stmt_consteval_or_not_consteval_if ref, + int else_id: @stmt ref +); + +while_body( + unique int while_stmt: @stmt_while ref, + int body_id: @stmt ref +); + +do_body( + unique int do_stmt: @stmt_end_test_while ref, + int body_id: @stmt ref +); + +switch_initialization( + unique int switch_stmt: @stmt_switch ref, + int init_id: @stmt ref +); + +#keyset[switch_stmt, index] +switch_case( + int switch_stmt: @stmt_switch ref, + int index: int ref, + int case_id: @stmt_switch_case ref +); + +switch_body( + unique int switch_stmt: @stmt_switch ref, + int body_id: @stmt ref +); + +@stmt_for_or_range_based_for = @stmt_for + | @stmt_range_based_for; + +for_initialization( + unique int for_stmt: @stmt_for_or_range_based_for ref, + int init_id: @stmt ref +); + +for_condition( + unique int for_stmt: @stmt_for ref, + int condition_id: @expr ref +); + +for_update( + unique int for_stmt: @stmt_for ref, + int update_id: @expr ref +); + +for_body( + unique int for_stmt: @stmt_for ref, + int body_id: @stmt ref +); + +@stmtparent = @stmt | @expr_stmt ; +stmtparents( + unique int id: @stmt ref, + int index: int ref, + int parent: @stmtparent ref +); + +ishandler(unique int block: @stmt_block ref); + +@cfgnode = @stmt | @expr | @function | @initialiser ; + +stmt_decl_bind( + int stmt: @stmt_decl ref, + int num: int ref, + int decl: @declaration ref +); + +stmt_decl_entry_bind( + int stmt: @stmt_decl ref, + int num: int ref, + int decl_entry: @element ref +); + +@parameterized_element = @function | @stmt_block | @requires_expr; + +blockscope( + unique int block: @stmt_block ref, + int enclosing: @parameterized_element ref +); + +@jump = @stmt_goto | @stmt_break | @stmt_continue | @stmt_leave; + +@jumporlabel = @jump | @stmt_label | @literal; + +jumpinfo( + unique int id: @jumporlabel ref, + string str: string ref, + int target: @stmt ref +); + +preprocdirects( + unique int id: @preprocdirect, + int kind: int ref, + int location: @location_default ref +); +case @preprocdirect.kind of + 0 = @ppd_if +| 1 = @ppd_ifdef +| 2 = @ppd_ifndef +| 3 = @ppd_elif +| 4 = @ppd_else +| 5 = @ppd_endif +| 6 = @ppd_plain_include +| 7 = @ppd_define +| 8 = @ppd_undef +| 9 = @ppd_line +| 10 = @ppd_error +| 11 = @ppd_pragma +| 12 = @ppd_objc_import +| 13 = @ppd_include_next +| 14 = @ppd_ms_import +| 15 = @ppd_elifdef +| 16 = @ppd_elifndef +| 17 = @ppd_embed +| 18 = @ppd_warning +; + +@ppd_include = @ppd_plain_include | @ppd_objc_import | @ppd_include_next | @ppd_ms_import; + +@ppd_branch = @ppd_if | @ppd_ifdef | @ppd_ifndef | @ppd_elif | @ppd_elifdef | @ppd_elifndef; + +preprocpair( + int begin : @ppd_branch ref, + int elseelifend : @preprocdirect ref +); + +preproctrue(int branch : @ppd_branch ref); +preprocfalse(int branch : @ppd_branch ref); + +preproctext( + unique int id: @preprocdirect ref, + string head: string ref, + string body: string ref +); + +includes( + unique int id: @ppd_include ref, + int included: @file ref +); + +embeds( + unique int id: @ppd_embed ref, + int included: @file ref +); + +link_targets( + int id: @link_target, + int binary: @file ref +); + +link_parent( + int element : @element ref, + int link_target : @link_target ref +); + +/*- Database metadata -*/ + +/** + * The CLI will automatically emit applicable tuples for this table, + * such as `databaseMetadata("isOverlay", "true")` when building an + * overlay database. + */ +databaseMetadata( + string metadataKey: string ref, + string value: string ref +); + +/*- Overlay support -*/ + +/** + * The CLI will automatically emit tuples for each new/modified/deleted file + * when building an overlay database. + */ +overlayChangedFiles( + string path: string ref +); + +/*- XML Files -*/ + +xmlEncoding( + unique int id: @file ref, + string encoding: string ref +); + +xmlDTDs( + unique int id: @xmldtd, + string root: string ref, + string publicId: string ref, + string systemId: string ref, + int fileid: @file ref +); + +xmlElements( + unique int id: @xmlelement, + string name: string ref, + int parentid: @xmlparent ref, + int idx: int ref, + int fileid: @file ref +); + +xmlAttrs( + unique int id: @xmlattribute, + int elementid: @xmlelement ref, + string name: string ref, + string value: string ref, + int idx: int ref, + int fileid: @file ref +); + +xmlNs( + int id: @xmlnamespace, + string prefixName: string ref, + string URI: string ref, + int fileid: @file ref +); + +xmlHasNs( + int elementId: @xmlnamespaceable ref, + int nsId: @xmlnamespace ref, + int fileid: @file ref +); + +xmlComments( + unique int id: @xmlcomment, + string text: string ref, + int parentid: @xmlparent ref, + int fileid: @file ref +); + +xmlChars( + unique int id: @xmlcharacters, + string text: string ref, + int parentid: @xmlparent ref, + int idx: int ref, + int isCDATA: int ref, + int fileid: @file ref +); + +@xmlparent = @file | @xmlelement; +@xmlnamespaceable = @xmlelement | @xmlattribute; + +xmllocations( + int xmlElement: @xmllocatable ref, + int location: @location_default ref +); + +@xmllocatable = @xmlcharacters | @xmlelement | @xmlcomment | @xmlattribute | @xmldtd | @file | @xmlnamespace; diff --git a/cpp/downgrades/0853f43dc8c08deecb473c54a2b70da8597f1ab5/semmlecode.cpp.dbscheme b/cpp/downgrades/0853f43dc8c08deecb473c54a2b70da8597f1ab5/semmlecode.cpp.dbscheme new file mode 100644 index 00000000000..ef8d209a22e --- /dev/null +++ b/cpp/downgrades/0853f43dc8c08deecb473c54a2b70da8597f1ab5/semmlecode.cpp.dbscheme @@ -0,0 +1,2577 @@ + +/*- Compilations -*/ + +/** + * An invocation of the compiler. Note that more than one file may be + * compiled per invocation. For example, this command compiles three + * source files: + * + * gcc -c f1.c f2.c f3.c + * + * The `id` simply identifies the invocation, while `cwd` is the working + * directory from which the compiler was invoked. + */ +compilations( + /** + * An invocation of the compiler. Note that more than one file may + * be compiled per invocation. For example, this command compiles + * three source files: + * + * gcc -c f1.c f2.c f3.c + */ + unique int id : @compilation, + string cwd : string ref +); + +/** + * The arguments that were passed to the extractor for a compiler + * invocation. If `id` is for the compiler invocation + * + * gcc -c f1.c f2.c f3.c + * + * then typically there will be rows for + * + * num | arg + * --- | --- + * 0 | *path to extractor* + * 1 | `--mimic` + * 2 | `/usr/bin/gcc` + * 3 | `-c` + * 4 | f1.c + * 5 | f2.c + * 6 | f3.c + */ +#keyset[id, num] +compilation_args( + int id : @compilation ref, + int num : int ref, + string arg : string ref +); + +/** + * The expanded arguments that were passed to the extractor for a + * compiler invocation. This is similar to `compilation_args`, but + * for a `@someFile` argument, it includes the arguments from that + * file, rather than just taking the argument literally. + */ +#keyset[id, num] +compilation_expanded_args( + int id : @compilation ref, + int num : int ref, + string arg : string ref +); + +/** + * Optionally, record the build mode for each compilation. + */ +compilation_build_mode( + unique int id : @compilation ref, + int mode : int ref +); + +/* +case @compilation_build_mode.mode of + 0 = @build_mode_none +| 1 = @build_mode_manual +| 2 = @build_mode_auto +; +*/ + +/** + * The source files that are compiled by a compiler invocation. + * If `id` is for the compiler invocation + * + * gcc -c f1.c f2.c f3.c + * + * then there will be rows for + * + * num | arg + * --- | --- + * 0 | f1.c + * 1 | f2.c + * 2 | f3.c + * + * Note that even if those files `#include` headers, those headers + * do not appear as rows. + */ +#keyset[id, num] +compilation_compiling_files( + int id : @compilation ref, + int num : int ref, + int file : @file ref +); + +/** + * The time taken by the extractor for a compiler invocation. + * + * For each file `num`, there will be rows for + * + * kind | seconds + * ---- | --- + * 1 | CPU seconds used by the extractor frontend + * 2 | Elapsed seconds during the extractor frontend + * 3 | CPU seconds used by the extractor backend + * 4 | Elapsed seconds during the extractor backend + */ +#keyset[id, num, kind] +compilation_time( + int id : @compilation ref, + int num : int ref, + /* kind: + 1 = frontend_cpu_seconds + 2 = frontend_elapsed_seconds + 3 = extractor_cpu_seconds + 4 = extractor_elapsed_seconds + */ + int kind : int ref, + float seconds : float ref +); + +/** + * An error or warning generated by the extractor. + * The diagnostic message `diagnostic` was generated during compiler + * invocation `compilation`, and is the `file_number_diagnostic_number`th + * message generated while extracting the `file_number`th file of that + * invocation. + */ +#keyset[compilation, file_number, file_number_diagnostic_number] +diagnostic_for( + int diagnostic : @diagnostic ref, + int compilation : @compilation ref, + int file_number : int ref, + int file_number_diagnostic_number : int ref +); + +/** + * If extraction was successful, then `cpu_seconds` and + * `elapsed_seconds` are the CPU time and elapsed time (respectively) + * that extraction took for compiler invocation `id`. + */ +compilation_finished( + unique int id : @compilation ref, + float cpu_seconds : float ref, + float elapsed_seconds : float ref +); + +/*- External data -*/ + +/** + * External data, loaded from CSV files during snapshot creation. See + * [Tutorial: Incorporating external data](https://help.semmle.com/wiki/display/SD/Tutorial%3A+Incorporating+external+data) + * for more information. + */ +externalData( + int id : @externalDataElement, + string path : string ref, + int column: int ref, + string value : string ref +); + +/*- Source location prefix -*/ + +/** + * The source location of the snapshot. + */ +sourceLocationPrefix(string prefix : string ref); + +/*- Files and folders -*/ + +/** + * The location of an element. + * The location spans column `startcolumn` of line `startline` to + * column `endcolumn` of line `endline` in file `file`. + * For more information, see + * [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/). + */ +locations_default( + unique int id: @location_default, + int file: @file ref, + int beginLine: int ref, + int beginColumn: int ref, + int endLine: int ref, + int endColumn: int ref +); + +files( + unique int id: @file, + string name: string ref +); + +folders( + unique int id: @folder, + string name: string ref +); + +@container = @file | @folder + +containerparent( + int parent: @container ref, + unique int child: @container ref +); + +/*- Lines of code -*/ + +numlines( + int element_id: @sourceline ref, + int num_lines: int ref, + int num_code: int ref, + int num_comment: int ref +); + +/*- Diagnostic messages -*/ + +diagnostics( + unique int id: @diagnostic, + int severity: int ref, + string error_tag: string ref, + string error_message: string ref, + string full_error_message: string ref, + int location: @location_default ref +); + +/*- C++ dbscheme -*/ + +extractor_version( + string codeql_version: string ref, + string frontend_version: string ref +) + +/** + * Gives the TRAP filename that `trap` is associated with. + * For debugging only. + */ +trap_filename( + int trap: @trap, + string filename: string ref +); + +/** + * Gives the tag name for `tag`. + * For debugging only. + */ +tag_name( + int tag: @tag, + string name: string ref +); + +@trap_or_tag = @tag | @trap; + +/** + * Gives the name for the source file. + */ +source_file_name( + int sf: @source_file, + string name: string ref +); + +/** + * In `build-mode: none` overlay mode, indicates that `source_file` + * (`/path/to/foo.c`) uses the TRAP file `trap_file`; i.e. it is the + * TRAP file corresponding to `foo.c`, something it transitively + * includes, or a template instantiation it transitively uses. + */ +source_file_uses_trap( + int source_file: @source_file ref, + int trap_file: @trap ref +); + +/** + * In `build-mode: none` overlay mode, indicates that the TRAP file + * `trap_file` uses tag `tag`. + */ +trap_uses_tag( + int trap_file: @trap ref, + int tag: @tag ref +); + +/** + * Holds if there is a definition of `element` in TRAP file or tag `t`. + */ +in_trap_or_tag( + int element: @element ref, + int t: @trap_or_tag ref +); + +pch_uses( + int pch: @pch ref, + int compilation: @compilation ref, + int id: @file ref +) + +#keyset[pch, compilation] +pch_creations( + int pch: @pch, + int compilation: @compilation ref, + int from: @file ref +) + +/** An element for which line-count information is available. */ +@sourceline = @file | @function | @variable | @enumconstant | @xmllocatable; + +fileannotations( + int id: @file ref, + int kind: int ref, + string name: string ref, + string value: string ref +); + +inmacroexpansion( + int id: @element ref, + int inv: @macroinvocation ref +); + +affectedbymacroexpansion( + int id: @element ref, + int inv: @macroinvocation ref +); + +case @macroinvocation.kind of + 1 = @macro_expansion +| 2 = @other_macro_reference +; + +macroinvocations( + unique int id: @macroinvocation, + int macro_id: @ppd_define ref, + int location: @location_default ref, + int kind: int ref +); + +macroparent( + unique int id: @macroinvocation ref, + int parent_id: @macroinvocation ref +); + +// a macroinvocation may be part of another location +// the way to find a constant expression that uses a macro +// is thus to find a constant expression that has a location +// to which a macro invocation is bound +macrolocationbind( + int id: @macroinvocation ref, + int location: @location_default ref +); + +#keyset[invocation, argument_index] +macro_argument_unexpanded( + int invocation: @macroinvocation ref, + int argument_index: int ref, + string text: string ref +); + +#keyset[invocation, argument_index] +macro_argument_expanded( + int invocation: @macroinvocation ref, + int argument_index: int ref, + string text: string ref +); + +case @function.kind of + 0 = @unknown_function +| 1 = @normal_function +| 2 = @constructor +| 3 = @destructor +| 4 = @conversion_function +| 5 = @operator +// ... 6 = @builtin_function deprecated // GCC built-in functions, e.g. __builtin___memcpy_chk +| 7 = @user_defined_literal +| 8 = @deduction_guide +; + +functions( + unique int id: @function, + string name: string ref, + int kind: int ref +); + +builtin_functions( + int id: @function ref +) + +function_entry_point( + int id: @function ref, + unique int entry_point: @stmt ref +); + +function_return_type( + int id: @function ref, + int return_type: @type ref +); + +/** + * If `function` is a coroutine, then this gives the `std::experimental::resumable_traits` + * instance associated with it, and the variables representing the `handle` and `promise` + * for it. + */ +coroutine( + unique int function: @function ref, + int traits: @type ref +); + +/* +case @coroutine_placeholder_variable.kind of + 1 = @handle +| 2 = @promise +| 3 = @init_await_resume +; +*/ + +coroutine_placeholder_variable( + unique int placeholder_variable: @variable ref, + int kind: int ref, + int function: @function ref +) + +/** The `new` function used for allocating the coroutine state, if any. */ +coroutine_new( + unique int function: @function ref, + int new: @function ref +); + +/** The `delete` function used for deallocating the coroutine state, if any. */ +coroutine_delete( + unique int function: @function ref, + int delete: @function ref +); + +purefunctions(unique int id: @function ref); + +function_deleted(unique int id: @function ref); + +function_defaulted(unique int id: @function ref); + +function_prototyped(unique int id: @function ref) + +deduction_guide_for_class( + int id: @function ref, + int class_template: @usertype ref +) + +member_function_this_type( + unique int id: @function ref, + int this_type: @type ref +); + +#keyset[id, type_id] +fun_decls( + int id: @fun_decl, + int function: @function ref, + int type_id: @type ref, + string name: string ref, + int location: @location_default ref +); +fun_def(unique int id: @fun_decl ref); +fun_specialized(unique int id: @fun_decl ref); +fun_implicit(unique int id: @fun_decl ref); +fun_decl_specifiers( + int id: @fun_decl ref, + string name: string ref +) +#keyset[fun_decl, index] +fun_decl_throws( + int fun_decl: @fun_decl ref, + int index: int ref, + int type_id: @type ref +); +/* an empty throw specification is different from none */ +fun_decl_empty_throws(unique int fun_decl: @fun_decl ref); +fun_decl_noexcept( + int fun_decl: @fun_decl ref, + int constant: @expr ref +); +fun_decl_empty_noexcept(int fun_decl: @fun_decl ref); +fun_decl_typedef_type( + unique int fun_decl: @fun_decl ref, + int typedeftype_id: @usertype ref +); + +/* +case @fun_requires.kind of + 1 = @template_attached +| 2 = @function_attached +; +*/ + +fun_requires( + int id: @fun_decl ref, + int kind: int ref, + int constraint: @expr ref +); + +param_decl_bind( + unique int id: @var_decl ref, + int index: int ref, + int fun_decl: @fun_decl ref +); + +#keyset[id, type_id] +var_decls( + int id: @var_decl, + int variable: @variable ref, + int type_id: @type ref, + string name: string ref, + int location: @location_default ref +); +var_def(unique int id: @var_decl ref); +var_specialized(int id: @var_decl ref); +var_decl_specifiers( + int id: @var_decl ref, + string name: string ref +) +is_structured_binding(unique int id: @variable ref); +var_requires( + int id: @var_decl ref, + int constraint: @expr ref +); + +type_decls( + unique int id: @type_decl, + int type_id: @type ref, + int location: @location_default ref +); +type_def(unique int id: @type_decl ref); +type_decl_top( + unique int type_decl: @type_decl ref +); +type_requires( + int id: @type_decl ref, + int constraint: @expr ref +); + +namespace_decls( + unique int id: @namespace_decl, + int namespace_id: @namespace ref, + int location: @location_default ref, + int bodylocation: @location_default ref +); + +case @using.kind of + 1 = @using_declaration +| 2 = @using_directive +| 3 = @using_enum_declaration +; + +usings( + unique int id: @using, + int element_id: @element ref, + int location: @location_default ref, + int kind: int ref +); + +/** The element which contains the `using` declaration. */ +using_container( + int parent: @element ref, + int child: @using ref +); + +static_asserts( + unique int id: @static_assert, + int condition : @expr ref, + string message : string ref, + int location: @location_default ref, + int enclosing : @element ref +); + +// each function has an ordered list of parameters +#keyset[id, type_id] +#keyset[function, index, type_id] +params( + int id: @parameter, + int function: @parameterized_element ref, + int index: int ref, + int type_id: @type ref +); + +overrides( + int new: @function ref, + int old: @function ref +); + +#keyset[id, type_id] +membervariables( + int id: @membervariable, + int type_id: @type ref, + string name: string ref +); + +#keyset[id, type_id] +globalvariables( + int id: @globalvariable, + int type_id: @type ref, + string name: string ref +); + +#keyset[id, type_id] +localvariables( + int id: @localvariable, + int type_id: @type ref, + string name: string ref +); + +autoderivation( + unique int var: @variable ref, + int derivation_type: @type ref +); + +orphaned_variables( + int var: @localvariable ref, + int function: @function ref +) + +enumconstants( + unique int id: @enumconstant, + int parent: @usertype ref, + int index: int ref, + int type_id: @type ref, + string name: string ref, + int location: @location_default ref +); + +@variable = @localscopevariable | @globalvariable | @membervariable; + +@localscopevariable = @localvariable | @parameter; + +/** + * Built-in types are the fundamental types, e.g., integral, floating, and void. + */ +case @builtintype.kind of + 1 = @errortype +| 2 = @unknowntype +| 3 = @void +| 4 = @boolean +| 5 = @char +| 6 = @unsigned_char +| 7 = @signed_char +| 8 = @short +| 9 = @unsigned_short +| 10 = @signed_short +| 11 = @int +| 12 = @unsigned_int +| 13 = @signed_int +| 14 = @long +| 15 = @unsigned_long +| 16 = @signed_long +| 17 = @long_long +| 18 = @unsigned_long_long +| 19 = @signed_long_long +// ... 20 Microsoft-specific __int8 +// ... 21 Microsoft-specific __int16 +// ... 22 Microsoft-specific __int32 +// ... 23 Microsoft-specific __int64 +| 24 = @float +| 25 = @double +| 26 = @long_double +| 27 = @complex_float // C99-specific _Complex float +| 28 = @complex_double // C99-specific _Complex double +| 29 = @complex_long_double // C99-specific _Complex long double +| 30 = @imaginary_float // C99-specific _Imaginary float +| 31 = @imaginary_double // C99-specific _Imaginary double +| 32 = @imaginary_long_double // C99-specific _Imaginary long double +| 33 = @wchar_t // Microsoft-specific +| 34 = @decltype_nullptr // C++11 +| 35 = @int128 // __int128 +| 36 = @unsigned_int128 // unsigned __int128 +| 37 = @signed_int128 // signed __int128 +| 38 = @float128 // __float128 +| 39 = @complex_float128 // _Complex __float128 +// ... 40 _Decimal32 +// ... 41 _Decimal64 +// ... 42 _Decimal128 +| 43 = @char16_t +| 44 = @char32_t +| 45 = @std_float32 // _Float32 +| 46 = @float32x // _Float32x +| 47 = @std_float64 // _Float64 +| 48 = @float64x // _Float64x +| 49 = @std_float128 // _Float128 +// ... 50 _Float128x +| 51 = @char8_t +| 52 = @float16 // _Float16 +| 53 = @complex_float16 // _Complex _Float16 +| 54 = @fp16 // __fp16 +| 55 = @std_bfloat16 // __bf16 +| 56 = @std_float16 // std::float16_t +| 57 = @complex_std_float32 // _Complex _Float32 +| 58 = @complex_float32x // _Complex _Float32x +| 59 = @complex_std_float64 // _Complex _Float64 +| 60 = @complex_float64x // _Complex _Float64x +| 61 = @complex_std_float128 // _Complex _Float128 +| 62 = @mfp8 // __mfp8 +| 63 = @scalable_vector_count // __SVCount_t +| 64 = @complex_fp16 // _Complex __fp16 +| 65 = @complex_std_bfloat16 // _Complex __bf16 +| 66 = @complex_std_float16 // _Complex std::float16_t +; + +builtintypes( + unique int id: @builtintype, + string name: string ref, + int kind: int ref, + int size: int ref, + int sign: int ref, + int alignment: int ref +); + +/** + * Derived types are types that are directly derived from existing types and + * point to, refer to, transform type data to return a new type. + */ +case @derivedtype.kind of + 1 = @pointer +| 2 = @reference +| 3 = @type_with_specifiers +| 4 = @array +| 5 = @gnu_vector +| 6 = @routineptr +| 7 = @routinereference +| 8 = @rvalue_reference // C++11 +// ... 9 type_conforming_to_protocols deprecated +| 10 = @block +| 11 = @scalable_vector // Arm SVE +; + +derivedtypes( + unique int id: @derivedtype, + string name: string ref, + int kind: int ref, + int type_id: @type ref +); + +pointerishsize(unique int id: @derivedtype ref, + int size: int ref, + int alignment: int ref); + +arraysizes( + unique int id: @derivedtype ref, + int num_elements: int ref, + int bytesize: int ref, + int alignment: int ref +); + +tupleelements( + unique int id: @derivedtype ref, + int num_elements: int ref +); + +typedefbase( + unique int id: @usertype ref, + int type_id: @type ref +); + +/** + * An instance of the C++11 `decltype` operator or C23 `typeof`/`typeof_unqual` + * operator taking an expression as its argument. For example: + * ``` + * int a; + * decltype(1+a) b; + * typeof(1+a) c; + * ``` + * Here `expr` is `1+a`. + * + * Sometimes an additional pair of parentheses around the expression + * changes the semantics of the decltype, e.g. + * ``` + * struct A { double x; }; + * const A* a = new A(); + * decltype( a->x ); // type is double + * decltype((a->x)); // type is const double& + * ``` + * (Please consult the C++11 standard for more details). + * `parentheses_would_change_meaning` is `true` iff that is the case. + */ + +/* +case @decltype.kind of +| 0 = @decltype +| 1 = @typeof // The frontend does not differentiate between typeof and typeof_unqual +; +*/ + +#keyset[id, expr] +decltypes( + int id: @decltype, + int expr: @expr ref, + int kind: int ref, + int base_type: @type ref, + boolean parentheses_would_change_meaning: boolean ref +); + +case @type_operator.kind of + 0 = @typeof // The frontend does not differentiate between typeof and typeof_unqual +| 1 = @underlying_type +| 2 = @bases +| 3 = @direct_bases +| 4 = @add_lvalue_reference +| 5 = @add_pointer +| 6 = @add_rvalue_reference +| 7 = @decay +| 8 = @make_signed +| 9 = @make_unsigned +| 10 = @remove_all_extents +| 11 = @remove_const +| 12 = @remove_cv +| 13 = @remove_cvref +| 14 = @remove_extent +| 15 = @remove_pointer +| 16 = @remove_reference_t +| 17 = @remove_restrict +| 18 = @remove_volatile +| 19 = @remove_reference +; + +type_operators( + unique int id: @type_operator, + int arg_type: @type ref, + int kind: int ref, + int base_type: @type ref +) + +case @usertype.kind of + 0 = @unknown_usertype +| 1 = @struct +| 2 = @class +| 3 = @union +| 4 = @enum +// ... 5 = @typedef deprecated // classic C: typedef typedef type name +// ... 6 = @template deprecated +| 7 = @template_parameter +| 8 = @template_template_parameter +| 9 = @proxy_class // a proxy class associated with a template parameter +// ... 10 objc_class deprecated +// ... 11 objc_protocol deprecated +// ... 12 objc_category deprecated +| 13 = @scoped_enum +// ... 14 = @using_alias deprecated // a using name = type style typedef +| 15 = @template_struct +| 16 = @template_class +| 17 = @template_union +| 18 = @alias +; + +usertypes( + unique int id: @usertype, + string name: string ref, + int kind: int ref +); + +usertypesize( + unique int id: @usertype ref, + int size: int ref, + int alignment: int ref +); + +usertype_final(unique int id: @usertype ref); + +usertype_uuid( + unique int id: @usertype ref, + string uuid: string ref +); + +/* +case @usertype.alias_kind of +| 0 = @typedef +| 1 = @alias +*/ + +usertype_alias_kind( + int id: @usertype ref, + int alias_kind: int ref +) + +nontype_template_parameters( + int id: @expr ref +); + +type_template_type_constraint( + int id: @usertype ref, + int constraint: @expr ref +); + +mangled_name( + unique int id: @declaration ref, + int mangled_name : @mangledname, + boolean is_complete: boolean ref +); + +is_pod_class(unique int id: @usertype ref); +is_standard_layout_class(unique int id: @usertype ref); + +is_complete(unique int id: @usertype ref); + +is_class_template(unique int id: @usertype ref); +class_instantiation( + int to: @usertype ref, + int from: @usertype ref +); +class_template_argument( + int type_id: @usertype ref, + int index: int ref, + int arg_type: @type ref +); +class_template_argument_value( + int type_id: @usertype ref, + int index: int ref, + int arg_value: @expr ref +); +class_template_generated_from( + unique int template: @usertype ref, + int from: @usertype ref +) + +@user_or_decltype = @usertype | @decltype; + +is_proxy_class_for( + unique int id: @usertype ref, + int templ_param_id: @user_or_decltype ref +); + +type_mentions( + unique int id: @type_mention, + int type_id: @type ref, + int location: @location_default ref, + // a_symbol_reference_kind from the frontend. + int kind: int ref +); + +is_function_template(unique int id: @function ref); +function_instantiation( + unique int to: @function ref, + int from: @function ref +); +function_template_argument( + int function_id: @function ref, + int index: int ref, + int arg_type: @type ref +); +function_template_argument_value( + int function_id: @function ref, + int index: int ref, + int arg_value: @expr ref +); +function_template_generated_from( + unique int template: @function ref, + int from: @function ref +); + +is_variable_template(unique int id: @variable ref); +variable_instantiation( + unique int to: @variable ref, + int from: @variable ref +); +variable_template_argument( + int variable_id: @variable ref, + int index: int ref, + int arg_type: @type ref +); +variable_template_argument_value( + int variable_id: @variable ref, + int index: int ref, + int arg_value: @expr ref +); +variable_template_generated_from( + unique int template: @variable ref, + int from: @variable ref +); + +is_alias_template(unique int id: @usertype ref); +alias_instantiation( + unique int to: @usertype ref, + int from: @usertype ref +); +alias_template_argument( + int type_id: @usertype ref, + int index: int ref, + int arg_type: @type ref +); +alias_template_argument_value( + int type_id: @usertype ref, + int index: int ref, + int arg_value: @expr ref +); +alias_template_generated_from( + unique int template: @usertype ref, + int from: @usertype ref +); + +template_template_instantiation( + int to: @usertype ref, + int from: @usertype ref +); +template_template_argument( + int type_id: @usertype ref, + int index: int ref, + int arg_type: @type ref +); +template_template_argument_value( + int type_id: @usertype ref, + int index: int ref, + int arg_value: @expr ref +); + +@concept = @concept_template | @concept_id; + +concept_templates( + unique int concept_id: @concept_template, + string name: string ref, + int location: @location_default ref +); +concept_instantiation( + unique int to: @concept_id ref, + int from: @concept_template ref +); +is_type_constraint(int concept_id: @concept_id ref); +concept_template_argument( + int concept_id: @concept ref, + int index: int ref, + int arg_type: @type ref +); +concept_template_argument_value( + int concept_id: @concept ref, + int index: int ref, + int arg_value: @expr ref +); + +routinetypes( + unique int id: @routinetype, + int return_type: @type ref +); + +routinetypeargs( + int routine: @routinetype ref, + int index: int ref, + int type_id: @type ref +); + +ptrtomembers( + unique int id: @ptrtomember, + int type_id: @type ref, + int class_id: @type ref +); + +/* + specifiers for types, functions, and variables + + "public", + "protected", + "private", + + "const", + "volatile", + "static", + + "pure", + "virtual", + "sealed", // Microsoft + "__interface", // Microsoft + "inline", + "explicit", + + "near", // near far extension + "far", // near far extension + "__ptr32", // Microsoft + "__ptr64", // Microsoft + "__sptr", // Microsoft + "__uptr", // Microsoft + "dllimport", // Microsoft + "dllexport", // Microsoft + "thread", // Microsoft + "naked", // Microsoft + "microsoft_inline", // Microsoft + "forceinline", // Microsoft + "selectany", // Microsoft + "nothrow", // Microsoft + "novtable", // Microsoft + "noreturn", // Microsoft + "noinline", // Microsoft + "noalias", // Microsoft + "restrict", // Microsoft +*/ + +specifiers( + unique int id: @specifier, + unique string str: string ref +); + +typespecifiers( + int type_id: @type ref, + int spec_id: @specifier ref +); + +funspecifiers( + int func_id: @function ref, + int spec_id: @specifier ref +); + +varspecifiers( + int var_id: @accessible ref, + int spec_id: @specifier ref +); + +explicit_specifier_exprs( + unique int func_id: @function ref, + int constant: @expr ref +) + +attributes( + unique int id: @attribute, + int kind: int ref, + string name: string ref, + string name_space: string ref, + int location: @location_default ref +); + +case @attribute.kind of + 0 = @gnuattribute +| 1 = @stdattribute +| 2 = @declspec +| 3 = @msattribute +| 4 = @alignas +// ... 5 @objc_propertyattribute deprecated +; + +attribute_args( + unique int id: @attribute_arg, + int kind: int ref, + int attribute: @attribute ref, + int index: int ref, + int location: @location_default ref +); + +case @attribute_arg.kind of + 0 = @attribute_arg_empty +| 1 = @attribute_arg_token +| 2 = @attribute_arg_constant +| 3 = @attribute_arg_type +| 4 = @attribute_arg_constant_expr +| 5 = @attribute_arg_expr +; + +attribute_arg_value( + unique int arg: @attribute_arg ref, + string value: string ref +); +attribute_arg_type( + unique int arg: @attribute_arg ref, + int type_id: @type ref +); +attribute_arg_constant( + unique int arg: @attribute_arg ref, + int constant: @expr ref +) +attribute_arg_expr( + unique int arg: @attribute_arg ref, + int expr: @expr ref +) +attribute_arg_name( + unique int arg: @attribute_arg ref, + string name: string ref +); + +typeattributes( + int type_id: @type ref, + int spec_id: @attribute ref +); + +funcattributes( + int func_id: @function ref, + int spec_id: @attribute ref +); + +varattributes( + int var_id: @accessible ref, + int spec_id: @attribute ref +); + +namespaceattributes( + int namespace_id: @namespace ref, + int spec_id: @attribute ref +); + +stmtattributes( + int stmt_id: @stmt ref, + int spec_id: @attribute ref +); + +@type = @builtintype + | @derivedtype + | @usertype + | @routinetype + | @ptrtomember + | @decltype + | @type_operator; + +unspecifiedtype( + unique int type_id: @type ref, + int unspecified_type_id: @type ref +); + +member( + int parent: @type ref, + int index: int ref, + int child: @member ref +); + +@enclosingfunction_child = @usertype | @variable | @namespace + +enclosingfunction( + unique int child: @enclosingfunction_child ref, + int parent: @function ref +); + +derivations( + unique int derivation: @derivation, + int sub: @type ref, + int index: int ref, + int super: @type ref, + int location: @location_default ref +); + +derspecifiers( + int der_id: @derivation ref, + int spec_id: @specifier ref +); + +/** + * Contains the byte offset of the base class subobject within the derived + * class. Only holds for non-virtual base classes, but see table + * `virtual_base_offsets` for offsets of virtual base class subobjects. + */ +direct_base_offsets( + unique int der_id: @derivation ref, + int offset: int ref +); + +/** + * Contains the byte offset of the virtual base class subobject for class + * `super` within a most-derived object of class `sub`. `super` can be either a + * direct or indirect base class. + */ +#keyset[sub, super] +virtual_base_offsets( + int sub: @usertype ref, + int super: @usertype ref, + int offset: int ref +); + +frienddecls( + unique int id: @frienddecl, + int type_id: @type ref, + int decl_id: @declaration ref, + int location: @location_default ref +); + +@declaredtype = @usertype ; + +@declaration = @function + | @declaredtype + | @variable + | @enumconstant + | @frienddecl + | @concept_template; + +@member = @membervariable + | @function + | @declaredtype + | @enumconstant; + +@locatable = @diagnostic + | @declaration + | @ppd_include + | @ppd_define + | @macroinvocation + /*| @funcall*/ + | @xmllocatable + | @attribute + | @attribute_arg; + +@namedscope = @namespace | @usertype; + +@element = @locatable + | @file + | @folder + | @specifier + | @type + | @expr + | @namespace + | @initialiser + | @stmt + | @derivation + | @comment + | @preprocdirect + | @fun_decl + | @var_decl + | @type_decl + | @namespace_decl + | @using + | @namequalifier + | @specialnamequalifyingelement + | @static_assert + | @type_mention + | @lambdacapture; + +@exprparent = @element; + +comments( + unique int id: @comment, + string contents: string ref, + int location: @location_default ref +); + +commentbinding( + int id: @comment ref, + int element: @element ref +); + +exprconv( + int converted: @expr ref, + unique int conversion: @expr ref +); + +compgenerated(unique int id: @element ref); + +/** + * `destructor_call` destructs the `i`'th entity that should be + * destructed following `element`. Note that entities should be + * destructed in reverse construction order, so for a given `element` + * these should be called from highest to lowest `i`. + */ +#keyset[element, destructor_call] +#keyset[element, i] +synthetic_destructor_call( + int element: @element ref, + int i: int ref, + int destructor_call: @routineexpr ref +); + +namespaces( + unique int id: @namespace, + string name: string ref +); + +namespace_inline( + unique int id: @namespace ref +); + +namespacembrs( + int parentid: @namespace ref, + unique int memberid: @namespacembr ref +); + +@namespacembr = @declaration | @namespace; + +exprparents( + int expr_id: @expr ref, + int child_index: int ref, + int parent_id: @exprparent ref +); + +expr_isload(unique int expr_id: @expr ref); + +@cast = @c_style_cast + | @const_cast + | @dynamic_cast + | @reinterpret_cast + | @static_cast + ; + +/* +case @conversion.kind of + 0 = @simple_conversion // a numeric conversion, qualification conversion, or a reinterpret_cast +| 1 = @bool_conversion // conversion to 'bool' +| 2 = @base_class_conversion // a derived-to-base conversion +| 3 = @derived_class_conversion // a base-to-derived conversion +| 4 = @pm_base_class_conversion // a derived-to-base conversion of a pointer to member +| 5 = @pm_derived_class_conversion // a base-to-derived conversion of a pointer to member +| 6 = @glvalue_adjust // an adjustment of the type of a glvalue +| 7 = @prvalue_adjust // an adjustment of the type of a prvalue +; +*/ +/** + * Describes the semantics represented by a cast expression. This is largely + * independent of the source syntax of the cast, so it is separate from the + * regular expression kind. + */ +conversionkinds( + unique int expr_id: @cast ref, + int kind: int ref +); + +@conversion = @cast + | @array_to_pointer + | @parexpr + | @reference_to + | @ref_indirect + | @temp_init + | @c11_generic + ; + +/* +case @funbindexpr.kind of + 0 = @normal_call // a normal call +| 1 = @virtual_call // a virtual call +| 2 = @adl_call // a call whose target is only found by ADL +; +*/ +iscall( + unique int caller: @funbindexpr ref, + int kind: int ref +); + +numtemplatearguments( + unique int expr_id: @expr ref, + int num: int ref +); + +specialnamequalifyingelements( + unique int id: @specialnamequalifyingelement, + unique string name: string ref +); + +@namequalifiableelement = @expr | @namequalifier; +@namequalifyingelement = @namespace + | @specialnamequalifyingelement + | @usertype + | @decltype; + +namequalifiers( + unique int id: @namequalifier, + unique int qualifiableelement: @namequalifiableelement ref, + int qualifyingelement: @namequalifyingelement ref, + int location: @location_default ref +); + +varbind( + int expr: @varbindexpr ref, + int var: @accessible ref +); + +funbind( + int expr: @funbindexpr ref, + int fun: @function ref +); + +@any_new_expr = @new_expr + | @new_array_expr; + +@new_or_delete_expr = @any_new_expr + | @delete_expr + | @delete_array_expr; + +@prefix_crement_expr = @preincrexpr | @predecrexpr; + +@postfix_crement_expr = @postincrexpr | @postdecrexpr; + +@increment_expr = @preincrexpr | @postincrexpr; + +@decrement_expr = @predecrexpr | @postdecrexpr; + +@crement_expr = @increment_expr | @decrement_expr; + +@un_arith_op_expr = @arithnegexpr + | @unaryplusexpr + | @conjugation + | @realpartexpr + | @imagpartexpr + | @crement_expr + ; + +@un_bitwise_op_expr = @complementexpr; + +@un_log_op_expr = @notexpr; + +@un_op_expr = @address_of + | @indirect + | @un_arith_op_expr + | @un_bitwise_op_expr + | @builtinaddressof + | @vec_fill + | @un_log_op_expr + | @co_await + | @co_yield + ; + +@bin_log_op_expr = @andlogicalexpr | @orlogicalexpr; + +@cmp_op_expr = @eq_op_expr | @rel_op_expr; + +@eq_op_expr = @eqexpr | @neexpr; + +@rel_op_expr = @gtexpr + | @ltexpr + | @geexpr + | @leexpr + | @spaceshipexpr + ; + +@bin_bitwise_op_expr = @lshiftexpr + | @rshiftexpr + | @andexpr + | @orexpr + | @xorexpr + ; + +@p_arith_op_expr = @paddexpr + | @psubexpr + | @pdiffexpr + ; + +@bin_arith_op_expr = @addexpr + | @subexpr + | @mulexpr + | @divexpr + | @remexpr + | @jmulexpr + | @jdivexpr + | @fjaddexpr + | @jfaddexpr + | @fjsubexpr + | @jfsubexpr + | @minexpr + | @maxexpr + | @p_arith_op_expr + ; + +@bin_op_expr = @bin_arith_op_expr + | @bin_bitwise_op_expr + | @cmp_op_expr + | @bin_log_op_expr + ; + +@op_expr = @un_op_expr + | @bin_op_expr + | @assign_expr + | @conditionalexpr + ; + +@assign_arith_expr = @assignaddexpr + | @assignsubexpr + | @assignmulexpr + | @assigndivexpr + | @assignremexpr + ; + +@assign_bitwise_expr = @assignandexpr + | @assignorexpr + | @assignxorexpr + | @assignlshiftexpr + | @assignrshiftexpr + ; + +@assign_pointer_expr = @assignpaddexpr + | @assignpsubexpr + ; + +@assign_op_expr = @assign_arith_expr + | @assign_bitwise_expr + | @assign_pointer_expr + ; + +@assign_expr = @assignexpr | @assign_op_expr | @blockassignexpr + +/* + Binary encoding of the allocator form. + + case @allocator.form of + 0 = plain + | 1 = alignment + ; +*/ + +/** + * The allocator function associated with a `new` or `new[]` expression. + * The `form` column specified whether the allocation call contains an alignment + * argument. + */ +expr_allocator( + unique int expr: @any_new_expr ref, + int func: @function ref, + int form: int ref +); + +/* + Binary encoding of the deallocator form. + + case @deallocator.form of + 0 = plain + | 1 = size + | 2 = alignment + | 4 = destroying_delete + ; +*/ + +/** + * The deallocator function associated with a `delete`, `delete[]`, `new`, or + * `new[]` expression. For a `new` or `new[]` expression, the deallocator is the + * one used to free memory if the initialization throws an exception. + * The `form` column specifies whether the deallocation call contains a size + * argument, and alignment argument, or both. + */ +expr_deallocator( + unique int expr: @new_or_delete_expr ref, + int func: @function ref, + int form: int ref +); + +/** + * Holds if the `@conditionalexpr` is of the two operand form + * `guard ? : false`. + */ +expr_cond_two_operand( + unique int cond: @conditionalexpr ref +); + +/** + * The guard of `@conditionalexpr` `guard ? true : false` + */ +expr_cond_guard( + unique int cond: @conditionalexpr ref, + int guard: @expr ref +); + +/** + * The expression used when the guard of `@conditionalexpr` + * `guard ? true : false` holds. For the two operand form + * `guard ?: false` consider using `expr_cond_guard` instead. + */ +expr_cond_true( + unique int cond: @conditionalexpr ref, + int true: @expr ref +); + +/** + * The expression used when the guard of `@conditionalexpr` + * `guard ? true : false` does not hold. + */ +expr_cond_false( + unique int cond: @conditionalexpr ref, + int false: @expr ref +); + +/** A string representation of the value. */ +values( + unique int id: @value, + string str: string ref +); + +/** The actual text in the source code for the value, if any. */ +valuetext( + unique int id: @value ref, + string text: string ref +); + +valuebind( + int val: @value ref, + unique int expr: @expr ref +); + +fieldoffsets( + unique int id: @variable ref, + int byteoffset: int ref, + int bitoffset: int ref +); + +bitfield( + unique int id: @variable ref, + int bits: int ref, + int declared_bits: int ref +); + +/* TODO +memberprefix( + int member: @expr ref, + int prefix: @expr ref +); +*/ + +/* + kind(1) = mbrcallexpr + kind(2) = mbrptrcallexpr + kind(3) = mbrptrmbrcallexpr + kind(4) = ptrmbrptrmbrcallexpr + kind(5) = mbrreadexpr // x.y + kind(6) = mbrptrreadexpr // p->y + kind(7) = mbrptrmbrreadexpr // x.*pm + kind(8) = mbrptrmbrptrreadexpr // x->*pm + kind(9) = staticmbrreadexpr // static x.y + kind(10) = staticmbrptrreadexpr // static p->y +*/ +/* TODO +memberaccess( + int member: @expr ref, + int kind: int ref +); +*/ + +initialisers( + unique int init: @initialiser, + int var: @accessible ref, + unique int expr: @expr ref, + int location: @location_default ref +); + +braced_initialisers( + int init: @initialiser ref +); + +/** + * An ancestor for the expression, for cases in which we cannot + * otherwise find the expression's parent. + */ +expr_ancestor( + int exp: @expr ref, + int ancestor: @element ref +); + +exprs( + unique int id: @expr, + int kind: int ref, + int location: @location_default ref +); + +expr_reuse( + int reuse: @expr ref, + int original: @expr ref, + int value_category: int ref +) + +/* + case @value.category of + 1 = prval + | 2 = xval + | 3 = lval + ; +*/ +expr_types( + int id: @expr ref, + int typeid: @type ref, + int value_category: int ref +); + +case @expr.kind of + 1 = @errorexpr +| 2 = @address_of // & AddressOfExpr +| 3 = @reference_to // ReferenceToExpr (implicit?) +| 4 = @indirect // * PointerDereferenceExpr +| 5 = @ref_indirect // ReferenceDereferenceExpr (implicit?) +// ... +| 8 = @array_to_pointer // (???) +| 9 = @vacuous_destructor_call // VacuousDestructorCall +// ... +| 11 = @assume // Microsoft +| 12 = @parexpr +| 13 = @arithnegexpr +| 14 = @unaryplusexpr +| 15 = @complementexpr +| 16 = @notexpr +| 17 = @conjugation // GNU ~ operator +| 18 = @realpartexpr // GNU __real +| 19 = @imagpartexpr // GNU __imag +| 20 = @postincrexpr +| 21 = @postdecrexpr +| 22 = @preincrexpr +| 23 = @predecrexpr +| 24 = @conditionalexpr +| 25 = @addexpr +| 26 = @subexpr +| 27 = @mulexpr +| 28 = @divexpr +| 29 = @remexpr +| 30 = @jmulexpr // C99 mul imaginary +| 31 = @jdivexpr // C99 div imaginary +| 32 = @fjaddexpr // C99 add real + imaginary +| 33 = @jfaddexpr // C99 add imaginary + real +| 34 = @fjsubexpr // C99 sub real - imaginary +| 35 = @jfsubexpr // C99 sub imaginary - real +| 36 = @paddexpr // pointer add (pointer + int or int + pointer) +| 37 = @psubexpr // pointer sub (pointer - integer) +| 38 = @pdiffexpr // difference between two pointers +| 39 = @lshiftexpr +| 40 = @rshiftexpr +| 41 = @andexpr +| 42 = @orexpr +| 43 = @xorexpr +| 44 = @eqexpr +| 45 = @neexpr +| 46 = @gtexpr +| 47 = @ltexpr +| 48 = @geexpr +| 49 = @leexpr +| 50 = @minexpr // GNU minimum +| 51 = @maxexpr // GNU maximum +| 52 = @assignexpr +| 53 = @assignaddexpr +| 54 = @assignsubexpr +| 55 = @assignmulexpr +| 56 = @assigndivexpr +| 57 = @assignremexpr +| 58 = @assignlshiftexpr +| 59 = @assignrshiftexpr +| 60 = @assignandexpr +| 61 = @assignorexpr +| 62 = @assignxorexpr +| 63 = @assignpaddexpr // assign pointer add +| 64 = @assignpsubexpr // assign pointer sub +| 65 = @andlogicalexpr +| 66 = @orlogicalexpr +| 67 = @commaexpr +| 68 = @subscriptexpr // access to member of an array, e.g., a[5] +// ... 69 @objc_subscriptexpr deprecated +// ... 70 @cmdaccess deprecated +// ... +| 73 = @virtfunptrexpr +| 74 = @callexpr +// ... 75 @msgexpr_normal deprecated +// ... 76 @msgexpr_super deprecated +// ... 77 @atselectorexpr deprecated +// ... 78 @atprotocolexpr deprecated +| 79 = @vastartexpr +| 80 = @vaargexpr +| 81 = @vaendexpr +| 82 = @vacopyexpr +// ... 83 @atencodeexpr deprecated +| 84 = @varaccess +| 85 = @thisaccess +// ... 86 @objc_box_expr deprecated +| 87 = @new_expr +| 88 = @delete_expr +| 89 = @throw_expr +| 90 = @condition_decl // a variable declared in a condition, e.g., if(int x = y > 2) +| 91 = @braced_init_list +| 92 = @type_id +| 93 = @runtime_sizeof +| 94 = @runtime_alignof +| 95 = @sizeof_pack +| 96 = @expr_stmt // GNU extension +| 97 = @routineexpr +| 98 = @type_operand // used to access a type in certain contexts (haven't found any examples yet....) +| 99 = @offsetofexpr // offsetof ::= type and field +| 100 = @hasassignexpr // __has_assign ::= type +| 101 = @hascopyexpr // __has_copy ::= type +| 102 = @hasnothrowassign // __has_nothrow_assign ::= type +| 103 = @hasnothrowconstr // __has_nothrow_constructor ::= type +| 104 = @hasnothrowcopy // __has_nothrow_copy ::= type +| 105 = @hastrivialassign // __has_trivial_assign ::= type +| 106 = @hastrivialconstr // __has_trivial_constructor ::= type +| 107 = @hastrivialcopy // __has_trivial_copy ::= type +| 108 = @hasuserdestr // __has_user_destructor ::= type +| 109 = @hasvirtualdestr // __has_virtual_destructor ::= type +| 110 = @isabstractexpr // __is_abstract ::= type +| 111 = @isbaseofexpr // __is_base_of ::= type type +| 112 = @isclassexpr // __is_class ::= type +| 113 = @isconvtoexpr // __is_convertible_to ::= type type +| 114 = @isemptyexpr // __is_empty ::= type +| 115 = @isenumexpr // __is_enum ::= type +| 116 = @ispodexpr // __is_pod ::= type +| 117 = @ispolyexpr // __is_polymorphic ::= type +| 118 = @isunionexpr // __is_union ::= type +| 119 = @typescompexpr // GNU __builtin_types_compatible ::= type type +| 120 = @intaddrexpr // frontend internal builtin, used to implement offsetof +// ... +| 122 = @hastrivialdestructor // __has_trivial_destructor ::= type +| 123 = @literal +| 124 = @uuidof +| 127 = @aggregateliteral +| 128 = @delete_array_expr +| 129 = @new_array_expr +// ... 130 @objc_array_literal deprecated +// ... 131 @objc_dictionary_literal deprecated +| 132 = @foldexpr +// ... +| 200 = @ctordirectinit +| 201 = @ctorvirtualinit +| 202 = @ctorfieldinit +| 203 = @ctordelegatinginit +| 204 = @dtordirectdestruct +| 205 = @dtorvirtualdestruct +| 206 = @dtorfielddestruct +// ... +| 210 = @static_cast +| 211 = @reinterpret_cast +| 212 = @const_cast +| 213 = @dynamic_cast +| 214 = @c_style_cast +| 215 = @lambdaexpr +| 216 = @param_ref +| 217 = @noopexpr +// ... +| 294 = @istriviallyconstructibleexpr +| 295 = @isdestructibleexpr +| 296 = @isnothrowdestructibleexpr +| 297 = @istriviallydestructibleexpr +| 298 = @istriviallyassignableexpr +| 299 = @isnothrowassignableexpr +| 300 = @istrivialexpr +| 301 = @isstandardlayoutexpr +| 302 = @istriviallycopyableexpr +| 303 = @isliteraltypeexpr +| 304 = @hastrivialmoveconstructorexpr +| 305 = @hastrivialmoveassignexpr +| 306 = @hasnothrowmoveassignexpr +| 307 = @isconstructibleexpr +| 308 = @isnothrowconstructibleexpr +| 309 = @hasfinalizerexpr +| 310 = @isdelegateexpr +| 311 = @isinterfaceclassexpr +| 312 = @isrefarrayexpr +| 313 = @isrefclassexpr +| 314 = @issealedexpr +| 315 = @issimplevalueclassexpr +| 316 = @isvalueclassexpr +| 317 = @isfinalexpr +| 319 = @noexceptexpr +| 320 = @builtinshufflevector +| 321 = @builtinchooseexpr +| 322 = @builtinaddressof +| 323 = @vec_fill +| 324 = @builtinconvertvector +| 325 = @builtincomplex +| 326 = @spaceshipexpr +| 327 = @co_await +| 328 = @co_yield +| 329 = @temp_init +| 330 = @isassignable +| 331 = @isaggregate +| 332 = @hasuniqueobjectrepresentations +| 333 = @builtinbitcast +| 334 = @builtinshuffle +| 335 = @blockassignexpr +| 336 = @issame +| 337 = @isfunction +| 338 = @islayoutcompatible +| 339 = @ispointerinterconvertiblebaseof +| 340 = @isarray +| 341 = @arrayrank +| 342 = @arrayextent +| 343 = @isarithmetic +| 344 = @iscompletetype +| 345 = @iscompound +| 346 = @isconst +| 347 = @isfloatingpoint +| 348 = @isfundamental +| 349 = @isintegral +| 350 = @islvaluereference +| 351 = @ismemberfunctionpointer +| 352 = @ismemberobjectpointer +| 353 = @ismemberpointer +| 354 = @isobject +| 355 = @ispointer +| 356 = @isreference +| 357 = @isrvaluereference +| 358 = @isscalar +| 359 = @issigned +| 360 = @isunsigned +| 361 = @isvoid +| 362 = @isvolatile +| 363 = @reuseexpr +| 364 = @istriviallycopyassignable +| 365 = @isassignablenopreconditioncheck +| 366 = @referencebindstotemporary +| 367 = @issameas +| 368 = @builtinhasattribute +| 369 = @ispointerinterconvertiblewithclass +| 370 = @builtinispointerinterconvertiblewithclass +| 371 = @iscorrespondingmember +| 372 = @builtiniscorrespondingmember +| 373 = @isboundedarray +| 374 = @isunboundedarray +| 375 = @isreferenceable +| 378 = @isnothrowconvertible +| 379 = @referenceconstructsfromtemporary +| 380 = @referenceconvertsfromtemporary +| 381 = @isconvertible +| 382 = @isvalidwinrttype +| 383 = @iswinclass +| 384 = @iswininterface +| 385 = @istriviallyequalitycomparable +| 386 = @isscopedenum +| 387 = @istriviallyrelocatable +| 388 = @datasizeof +| 389 = @c11_generic +| 390 = @requires_expr +| 391 = @nested_requirement +| 392 = @compound_requirement +| 393 = @concept_id +| 394 = @isinvocable +| 395 = @isnothrowinvocable +| 396 = @isbitwisecloneable +; + +@var_args_expr = @vastartexpr + | @vaendexpr + | @vaargexpr + | @vacopyexpr + ; + +@builtin_op = @var_args_expr + | @noopexpr + | @offsetofexpr + | @intaddrexpr + | @hasassignexpr + | @hascopyexpr + | @hasnothrowassign + | @hasnothrowconstr + | @hasnothrowcopy + | @hastrivialassign + | @hastrivialconstr + | @hastrivialcopy + | @hastrivialdestructor + | @hasuserdestr + | @hasvirtualdestr + | @isabstractexpr + | @isbaseofexpr + | @isclassexpr + | @isconvtoexpr + | @isemptyexpr + | @isenumexpr + | @ispodexpr + | @ispolyexpr + | @isunionexpr + | @typescompexpr + | @builtinshufflevector + | @builtinconvertvector + | @builtinaddressof + | @istriviallyconstructibleexpr + | @isdestructibleexpr + | @isnothrowdestructibleexpr + | @istriviallydestructibleexpr + | @istriviallyassignableexpr + | @isnothrowassignableexpr + | @istrivialexpr + | @isstandardlayoutexpr + | @istriviallycopyableexpr + | @isliteraltypeexpr + | @hastrivialmoveconstructorexpr + | @hastrivialmoveassignexpr + | @hasnothrowmoveassignexpr + | @isconstructibleexpr + | @isnothrowconstructibleexpr + | @hasfinalizerexpr + | @isdelegateexpr + | @isinterfaceclassexpr + | @isrefarrayexpr + | @isrefclassexpr + | @issealedexpr + | @issimplevalueclassexpr + | @isvalueclassexpr + | @isfinalexpr + | @builtinchooseexpr + | @builtincomplex + | @isassignable + | @isaggregate + | @hasuniqueobjectrepresentations + | @builtinbitcast + | @builtinshuffle + | @issame + | @isfunction + | @islayoutcompatible + | @ispointerinterconvertiblebaseof + | @isarray + | @arrayrank + | @arrayextent + | @isarithmetic + | @iscompletetype + | @iscompound + | @isconst + | @isfloatingpoint + | @isfundamental + | @isintegral + | @islvaluereference + | @ismemberfunctionpointer + | @ismemberobjectpointer + | @ismemberpointer + | @isobject + | @ispointer + | @isreference + | @isrvaluereference + | @isscalar + | @issigned + | @isunsigned + | @isvoid + | @isvolatile + | @istriviallycopyassignable + | @isassignablenopreconditioncheck + | @referencebindstotemporary + | @issameas + | @builtinhasattribute + | @ispointerinterconvertiblewithclass + | @builtinispointerinterconvertiblewithclass + | @iscorrespondingmember + | @builtiniscorrespondingmember + | @isboundedarray + | @isunboundedarray + | @isreferenceable + | @isnothrowconvertible + | @referenceconstructsfromtemporary + | @referenceconvertsfromtemporary + | @isconvertible + | @isvalidwinrttype + | @iswinclass + | @iswininterface + | @istriviallyequalitycomparable + | @isscopedenum + | @istriviallyrelocatable + | @isinvocable + | @isnothrowinvocable + | @isbitwisecloneable + ; + +compound_requirement_is_noexcept( + int expr: @compound_requirement ref +); + +new_allocated_type( + unique int expr: @new_expr ref, + int type_id: @type ref +); + +new_array_allocated_type( + unique int expr: @new_array_expr ref, + int type_id: @type ref +); + +param_ref_to_this( + int expr: @param_ref ref +) + +/** + * The field being initialized by an initializer expression within an aggregate + * initializer for a class/struct/union. Position is used to sort repeated initializers. + */ +#keyset[aggregate, position] +aggregate_field_init( + int aggregate: @aggregateliteral ref, + int initializer: @expr ref, + int field: @membervariable ref, + int position: int ref, + boolean is_designated: boolean ref +); + +/** + * The index of the element being initialized by an initializer expression + * within an aggregate initializer for an array. Position is used to sort repeated initializers. + */ +#keyset[aggregate, position] +aggregate_array_init( + int aggregate: @aggregateliteral ref, + int initializer: @expr ref, + int element_index: int ref, + int position: int ref, + boolean is_designated: boolean ref +); + +@ctorinit = @ctordirectinit + | @ctorvirtualinit + | @ctorfieldinit + | @ctordelegatinginit; +@dtordestruct = @dtordirectdestruct + | @dtorvirtualdestruct + | @dtorfielddestruct; + + +condition_decl_bind( + unique int expr: @condition_decl ref, + unique int decl: @declaration ref +); + +typeid_bind( + unique int expr: @type_id ref, + int type_id: @type ref +); + +uuidof_bind( + unique int expr: @uuidof ref, + int type_id: @type ref +); + +@sizeof_or_alignof = @runtime_sizeof | @runtime_alignof | @datasizeof | @sizeof_pack; + +sizeof_bind( + unique int expr: @sizeof_or_alignof ref, + int type_id: @type ref +); + +code_block( + unique int block: @literal ref, + unique int routine: @function ref +); + +lambdas( + unique int expr: @lambdaexpr ref, + string default_capture: string ref, + boolean has_explicit_return_type: boolean ref, + boolean has_explicit_parameter_list: boolean ref +); + +lambda_capture( + unique int id: @lambdacapture, + int lambda: @lambdaexpr ref, + int index: int ref, + int field: @membervariable ref, + boolean captured_by_reference: boolean ref, + boolean is_implicit: boolean ref, + int location: @location_default ref +); + +@funbindexpr = @routineexpr + | @new_expr + | @delete_expr + | @delete_array_expr + | @ctordirectinit + | @ctorvirtualinit + | @ctordelegatinginit + | @dtordirectdestruct + | @dtorvirtualdestruct; + +@varbindexpr = @varaccess | @ctorfieldinit | @dtorfielddestruct; +@addressable = @function | @variable ; +@accessible = @addressable | @enumconstant ; + +@access = @varaccess | @routineexpr ; + +fold( + int expr: @foldexpr ref, + string operator: string ref, + boolean is_left_fold: boolean ref +); + +stmts( + unique int id: @stmt, + int kind: int ref, + int location: @location_default ref +); + +case @stmt.kind of + 1 = @stmt_expr +| 2 = @stmt_if +| 3 = @stmt_while +| 4 = @stmt_goto +| 5 = @stmt_label +| 6 = @stmt_return +| 7 = @stmt_block +| 8 = @stmt_end_test_while // do { ... } while ( ... ) +| 9 = @stmt_for +| 10 = @stmt_switch_case +| 11 = @stmt_switch +| 13 = @stmt_asm // "asm" statement or the body of an asm function +| 15 = @stmt_try_block +| 16 = @stmt_microsoft_try // Microsoft +| 17 = @stmt_decl +| 18 = @stmt_set_vla_size // C99 +| 19 = @stmt_vla_decl // C99 +| 25 = @stmt_assigned_goto // GNU +| 26 = @stmt_empty +| 27 = @stmt_continue +| 28 = @stmt_break +| 29 = @stmt_range_based_for // C++11 +// ... 30 @stmt_at_autoreleasepool_block deprecated +// ... 31 @stmt_objc_for_in deprecated +// ... 32 @stmt_at_synchronized deprecated +| 33 = @stmt_handler +// ... 34 @stmt_finally_end deprecated +| 35 = @stmt_constexpr_if +| 37 = @stmt_co_return +| 38 = @stmt_consteval_if +| 39 = @stmt_not_consteval_if +| 40 = @stmt_leave +; + +type_vla( + int type_id: @type ref, + int decl: @stmt_vla_decl ref +); + +variable_vla( + int var: @variable ref, + int decl: @stmt_vla_decl ref +); + +type_is_vla(unique int type_id: @derivedtype ref) + +if_initialization( + unique int if_stmt: @stmt_if ref, + int init_id: @stmt ref +); + +if_then( + unique int if_stmt: @stmt_if ref, + int then_id: @stmt ref +); + +if_else( + unique int if_stmt: @stmt_if ref, + int else_id: @stmt ref +); + +constexpr_if_initialization( + unique int constexpr_if_stmt: @stmt_constexpr_if ref, + int init_id: @stmt ref +); + +constexpr_if_then( + unique int constexpr_if_stmt: @stmt_constexpr_if ref, + int then_id: @stmt ref +); + +constexpr_if_else( + unique int constexpr_if_stmt: @stmt_constexpr_if ref, + int else_id: @stmt ref +); + +@stmt_consteval_or_not_consteval_if = @stmt_consteval_if | @stmt_not_consteval_if; + +consteval_if_then( + unique int constexpr_if_stmt: @stmt_consteval_or_not_consteval_if ref, + int then_id: @stmt ref +); + +consteval_if_else( + unique int constexpr_if_stmt: @stmt_consteval_or_not_consteval_if ref, + int else_id: @stmt ref +); + +while_body( + unique int while_stmt: @stmt_while ref, + int body_id: @stmt ref +); + +do_body( + unique int do_stmt: @stmt_end_test_while ref, + int body_id: @stmt ref +); + +switch_initialization( + unique int switch_stmt: @stmt_switch ref, + int init_id: @stmt ref +); + +#keyset[switch_stmt, index] +switch_case( + int switch_stmt: @stmt_switch ref, + int index: int ref, + int case_id: @stmt_switch_case ref +); + +switch_body( + unique int switch_stmt: @stmt_switch ref, + int body_id: @stmt ref +); + +@stmt_for_or_range_based_for = @stmt_for + | @stmt_range_based_for; + +for_initialization( + unique int for_stmt: @stmt_for_or_range_based_for ref, + int init_id: @stmt ref +); + +for_condition( + unique int for_stmt: @stmt_for ref, + int condition_id: @expr ref +); + +for_update( + unique int for_stmt: @stmt_for ref, + int update_id: @expr ref +); + +for_body( + unique int for_stmt: @stmt_for ref, + int body_id: @stmt ref +); + +@stmtparent = @stmt | @expr_stmt ; +stmtparents( + unique int id: @stmt ref, + int index: int ref, + int parent: @stmtparent ref +); + +ishandler(unique int block: @stmt_block ref); + +@cfgnode = @stmt | @expr | @function | @initialiser ; + +stmt_decl_bind( + int stmt: @stmt_decl ref, + int num: int ref, + int decl: @declaration ref +); + +stmt_decl_entry_bind( + int stmt: @stmt_decl ref, + int num: int ref, + int decl_entry: @element ref +); + +@parameterized_element = @function | @stmt_block | @requires_expr; + +blockscope( + unique int block: @stmt_block ref, + int enclosing: @parameterized_element ref +); + +@jump = @stmt_goto | @stmt_break | @stmt_continue | @stmt_leave; + +@jumporlabel = @jump | @stmt_label | @literal; + +jumpinfo( + unique int id: @jumporlabel ref, + string str: string ref, + int target: @stmt ref +); + +preprocdirects( + unique int id: @preprocdirect, + int kind: int ref, + int location: @location_default ref +); +case @preprocdirect.kind of + 0 = @ppd_if +| 1 = @ppd_ifdef +| 2 = @ppd_ifndef +| 3 = @ppd_elif +| 4 = @ppd_else +| 5 = @ppd_endif +| 6 = @ppd_plain_include +| 7 = @ppd_define +| 8 = @ppd_undef +| 9 = @ppd_line +| 10 = @ppd_error +| 11 = @ppd_pragma +| 12 = @ppd_objc_import +| 13 = @ppd_include_next +| 14 = @ppd_ms_import +| 15 = @ppd_elifdef +| 16 = @ppd_elifndef +| 17 = @ppd_embed +| 18 = @ppd_warning +; + +@ppd_include = @ppd_plain_include | @ppd_objc_import | @ppd_include_next | @ppd_ms_import; + +@ppd_branch = @ppd_if | @ppd_ifdef | @ppd_ifndef | @ppd_elif | @ppd_elifdef | @ppd_elifndef; + +preprocpair( + int begin : @ppd_branch ref, + int elseelifend : @preprocdirect ref +); + +preproctrue(int branch : @ppd_branch ref); +preprocfalse(int branch : @ppd_branch ref); + +preproctext( + unique int id: @preprocdirect ref, + string head: string ref, + string body: string ref +); + +includes( + unique int id: @ppd_include ref, + int included: @file ref +); + +embeds( + unique int id: @ppd_embed ref, + int included: @file ref +); + +link_targets( + int id: @link_target, + int binary: @file ref +); + +link_parent( + int element : @element ref, + int link_target : @link_target ref +); + +/*- Database metadata -*/ + +/** + * The CLI will automatically emit applicable tuples for this table, + * such as `databaseMetadata("isOverlay", "true")` when building an + * overlay database. + */ +databaseMetadata( + string metadataKey: string ref, + string value: string ref +); + +/*- Overlay support -*/ + +/** + * The CLI will automatically emit tuples for each new/modified/deleted file + * when building an overlay database. + */ +overlayChangedFiles( + string path: string ref +); + +/*- XML Files -*/ + +xmlEncoding( + unique int id: @file ref, + string encoding: string ref +); + +xmlDTDs( + unique int id: @xmldtd, + string root: string ref, + string publicId: string ref, + string systemId: string ref, + int fileid: @file ref +); + +xmlElements( + unique int id: @xmlelement, + string name: string ref, + int parentid: @xmlparent ref, + int idx: int ref, + int fileid: @file ref +); + +xmlAttrs( + unique int id: @xmlattribute, + int elementid: @xmlelement ref, + string name: string ref, + string value: string ref, + int idx: int ref, + int fileid: @file ref +); + +xmlNs( + int id: @xmlnamespace, + string prefixName: string ref, + string URI: string ref, + int fileid: @file ref +); + +xmlHasNs( + int elementId: @xmlnamespaceable ref, + int nsId: @xmlnamespace ref, + int fileid: @file ref +); + +xmlComments( + unique int id: @xmlcomment, + string text: string ref, + int parentid: @xmlparent ref, + int fileid: @file ref +); + +xmlChars( + unique int id: @xmlcharacters, + string text: string ref, + int parentid: @xmlparent ref, + int idx: int ref, + int isCDATA: int ref, + int fileid: @file ref +); + +@xmlparent = @file | @xmlelement; +@xmlnamespaceable = @xmlelement | @xmlattribute; + +xmllocations( + int xmlElement: @xmllocatable ref, + int location: @location_default ref +); + +@xmllocatable = @xmlcharacters | @xmlelement | @xmlcomment | @xmlattribute | @xmldtd | @file | @xmlnamespace; diff --git a/cpp/downgrades/0853f43dc8c08deecb473c54a2b70da8597f1ab5/upgrade.properties b/cpp/downgrades/0853f43dc8c08deecb473c54a2b70da8597f1ab5/upgrade.properties new file mode 100644 index 00000000000..d3a842d2cbb --- /dev/null +++ b/cpp/downgrades/0853f43dc8c08deecb473c54a2b70da8597f1ab5/upgrade.properties @@ -0,0 +1,2 @@ +description: Fix NameQualifier inconsistency +compatibility: full diff --git a/cpp/ql/lib/upgrades/ef8d209a22e27413aaaeff4446f0ecb9fa2c227b/old.dbscheme b/cpp/ql/lib/upgrades/ef8d209a22e27413aaaeff4446f0ecb9fa2c227b/old.dbscheme new file mode 100644 index 00000000000..ef8d209a22e --- /dev/null +++ b/cpp/ql/lib/upgrades/ef8d209a22e27413aaaeff4446f0ecb9fa2c227b/old.dbscheme @@ -0,0 +1,2577 @@ + +/*- Compilations -*/ + +/** + * An invocation of the compiler. Note that more than one file may be + * compiled per invocation. For example, this command compiles three + * source files: + * + * gcc -c f1.c f2.c f3.c + * + * The `id` simply identifies the invocation, while `cwd` is the working + * directory from which the compiler was invoked. + */ +compilations( + /** + * An invocation of the compiler. Note that more than one file may + * be compiled per invocation. For example, this command compiles + * three source files: + * + * gcc -c f1.c f2.c f3.c + */ + unique int id : @compilation, + string cwd : string ref +); + +/** + * The arguments that were passed to the extractor for a compiler + * invocation. If `id` is for the compiler invocation + * + * gcc -c f1.c f2.c f3.c + * + * then typically there will be rows for + * + * num | arg + * --- | --- + * 0 | *path to extractor* + * 1 | `--mimic` + * 2 | `/usr/bin/gcc` + * 3 | `-c` + * 4 | f1.c + * 5 | f2.c + * 6 | f3.c + */ +#keyset[id, num] +compilation_args( + int id : @compilation ref, + int num : int ref, + string arg : string ref +); + +/** + * The expanded arguments that were passed to the extractor for a + * compiler invocation. This is similar to `compilation_args`, but + * for a `@someFile` argument, it includes the arguments from that + * file, rather than just taking the argument literally. + */ +#keyset[id, num] +compilation_expanded_args( + int id : @compilation ref, + int num : int ref, + string arg : string ref +); + +/** + * Optionally, record the build mode for each compilation. + */ +compilation_build_mode( + unique int id : @compilation ref, + int mode : int ref +); + +/* +case @compilation_build_mode.mode of + 0 = @build_mode_none +| 1 = @build_mode_manual +| 2 = @build_mode_auto +; +*/ + +/** + * The source files that are compiled by a compiler invocation. + * If `id` is for the compiler invocation + * + * gcc -c f1.c f2.c f3.c + * + * then there will be rows for + * + * num | arg + * --- | --- + * 0 | f1.c + * 1 | f2.c + * 2 | f3.c + * + * Note that even if those files `#include` headers, those headers + * do not appear as rows. + */ +#keyset[id, num] +compilation_compiling_files( + int id : @compilation ref, + int num : int ref, + int file : @file ref +); + +/** + * The time taken by the extractor for a compiler invocation. + * + * For each file `num`, there will be rows for + * + * kind | seconds + * ---- | --- + * 1 | CPU seconds used by the extractor frontend + * 2 | Elapsed seconds during the extractor frontend + * 3 | CPU seconds used by the extractor backend + * 4 | Elapsed seconds during the extractor backend + */ +#keyset[id, num, kind] +compilation_time( + int id : @compilation ref, + int num : int ref, + /* kind: + 1 = frontend_cpu_seconds + 2 = frontend_elapsed_seconds + 3 = extractor_cpu_seconds + 4 = extractor_elapsed_seconds + */ + int kind : int ref, + float seconds : float ref +); + +/** + * An error or warning generated by the extractor. + * The diagnostic message `diagnostic` was generated during compiler + * invocation `compilation`, and is the `file_number_diagnostic_number`th + * message generated while extracting the `file_number`th file of that + * invocation. + */ +#keyset[compilation, file_number, file_number_diagnostic_number] +diagnostic_for( + int diagnostic : @diagnostic ref, + int compilation : @compilation ref, + int file_number : int ref, + int file_number_diagnostic_number : int ref +); + +/** + * If extraction was successful, then `cpu_seconds` and + * `elapsed_seconds` are the CPU time and elapsed time (respectively) + * that extraction took for compiler invocation `id`. + */ +compilation_finished( + unique int id : @compilation ref, + float cpu_seconds : float ref, + float elapsed_seconds : float ref +); + +/*- External data -*/ + +/** + * External data, loaded from CSV files during snapshot creation. See + * [Tutorial: Incorporating external data](https://help.semmle.com/wiki/display/SD/Tutorial%3A+Incorporating+external+data) + * for more information. + */ +externalData( + int id : @externalDataElement, + string path : string ref, + int column: int ref, + string value : string ref +); + +/*- Source location prefix -*/ + +/** + * The source location of the snapshot. + */ +sourceLocationPrefix(string prefix : string ref); + +/*- Files and folders -*/ + +/** + * The location of an element. + * The location spans column `startcolumn` of line `startline` to + * column `endcolumn` of line `endline` in file `file`. + * For more information, see + * [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/). + */ +locations_default( + unique int id: @location_default, + int file: @file ref, + int beginLine: int ref, + int beginColumn: int ref, + int endLine: int ref, + int endColumn: int ref +); + +files( + unique int id: @file, + string name: string ref +); + +folders( + unique int id: @folder, + string name: string ref +); + +@container = @file | @folder + +containerparent( + int parent: @container ref, + unique int child: @container ref +); + +/*- Lines of code -*/ + +numlines( + int element_id: @sourceline ref, + int num_lines: int ref, + int num_code: int ref, + int num_comment: int ref +); + +/*- Diagnostic messages -*/ + +diagnostics( + unique int id: @diagnostic, + int severity: int ref, + string error_tag: string ref, + string error_message: string ref, + string full_error_message: string ref, + int location: @location_default ref +); + +/*- C++ dbscheme -*/ + +extractor_version( + string codeql_version: string ref, + string frontend_version: string ref +) + +/** + * Gives the TRAP filename that `trap` is associated with. + * For debugging only. + */ +trap_filename( + int trap: @trap, + string filename: string ref +); + +/** + * Gives the tag name for `tag`. + * For debugging only. + */ +tag_name( + int tag: @tag, + string name: string ref +); + +@trap_or_tag = @tag | @trap; + +/** + * Gives the name for the source file. + */ +source_file_name( + int sf: @source_file, + string name: string ref +); + +/** + * In `build-mode: none` overlay mode, indicates that `source_file` + * (`/path/to/foo.c`) uses the TRAP file `trap_file`; i.e. it is the + * TRAP file corresponding to `foo.c`, something it transitively + * includes, or a template instantiation it transitively uses. + */ +source_file_uses_trap( + int source_file: @source_file ref, + int trap_file: @trap ref +); + +/** + * In `build-mode: none` overlay mode, indicates that the TRAP file + * `trap_file` uses tag `tag`. + */ +trap_uses_tag( + int trap_file: @trap ref, + int tag: @tag ref +); + +/** + * Holds if there is a definition of `element` in TRAP file or tag `t`. + */ +in_trap_or_tag( + int element: @element ref, + int t: @trap_or_tag ref +); + +pch_uses( + int pch: @pch ref, + int compilation: @compilation ref, + int id: @file ref +) + +#keyset[pch, compilation] +pch_creations( + int pch: @pch, + int compilation: @compilation ref, + int from: @file ref +) + +/** An element for which line-count information is available. */ +@sourceline = @file | @function | @variable | @enumconstant | @xmllocatable; + +fileannotations( + int id: @file ref, + int kind: int ref, + string name: string ref, + string value: string ref +); + +inmacroexpansion( + int id: @element ref, + int inv: @macroinvocation ref +); + +affectedbymacroexpansion( + int id: @element ref, + int inv: @macroinvocation ref +); + +case @macroinvocation.kind of + 1 = @macro_expansion +| 2 = @other_macro_reference +; + +macroinvocations( + unique int id: @macroinvocation, + int macro_id: @ppd_define ref, + int location: @location_default ref, + int kind: int ref +); + +macroparent( + unique int id: @macroinvocation ref, + int parent_id: @macroinvocation ref +); + +// a macroinvocation may be part of another location +// the way to find a constant expression that uses a macro +// is thus to find a constant expression that has a location +// to which a macro invocation is bound +macrolocationbind( + int id: @macroinvocation ref, + int location: @location_default ref +); + +#keyset[invocation, argument_index] +macro_argument_unexpanded( + int invocation: @macroinvocation ref, + int argument_index: int ref, + string text: string ref +); + +#keyset[invocation, argument_index] +macro_argument_expanded( + int invocation: @macroinvocation ref, + int argument_index: int ref, + string text: string ref +); + +case @function.kind of + 0 = @unknown_function +| 1 = @normal_function +| 2 = @constructor +| 3 = @destructor +| 4 = @conversion_function +| 5 = @operator +// ... 6 = @builtin_function deprecated // GCC built-in functions, e.g. __builtin___memcpy_chk +| 7 = @user_defined_literal +| 8 = @deduction_guide +; + +functions( + unique int id: @function, + string name: string ref, + int kind: int ref +); + +builtin_functions( + int id: @function ref +) + +function_entry_point( + int id: @function ref, + unique int entry_point: @stmt ref +); + +function_return_type( + int id: @function ref, + int return_type: @type ref +); + +/** + * If `function` is a coroutine, then this gives the `std::experimental::resumable_traits` + * instance associated with it, and the variables representing the `handle` and `promise` + * for it. + */ +coroutine( + unique int function: @function ref, + int traits: @type ref +); + +/* +case @coroutine_placeholder_variable.kind of + 1 = @handle +| 2 = @promise +| 3 = @init_await_resume +; +*/ + +coroutine_placeholder_variable( + unique int placeholder_variable: @variable ref, + int kind: int ref, + int function: @function ref +) + +/** The `new` function used for allocating the coroutine state, if any. */ +coroutine_new( + unique int function: @function ref, + int new: @function ref +); + +/** The `delete` function used for deallocating the coroutine state, if any. */ +coroutine_delete( + unique int function: @function ref, + int delete: @function ref +); + +purefunctions(unique int id: @function ref); + +function_deleted(unique int id: @function ref); + +function_defaulted(unique int id: @function ref); + +function_prototyped(unique int id: @function ref) + +deduction_guide_for_class( + int id: @function ref, + int class_template: @usertype ref +) + +member_function_this_type( + unique int id: @function ref, + int this_type: @type ref +); + +#keyset[id, type_id] +fun_decls( + int id: @fun_decl, + int function: @function ref, + int type_id: @type ref, + string name: string ref, + int location: @location_default ref +); +fun_def(unique int id: @fun_decl ref); +fun_specialized(unique int id: @fun_decl ref); +fun_implicit(unique int id: @fun_decl ref); +fun_decl_specifiers( + int id: @fun_decl ref, + string name: string ref +) +#keyset[fun_decl, index] +fun_decl_throws( + int fun_decl: @fun_decl ref, + int index: int ref, + int type_id: @type ref +); +/* an empty throw specification is different from none */ +fun_decl_empty_throws(unique int fun_decl: @fun_decl ref); +fun_decl_noexcept( + int fun_decl: @fun_decl ref, + int constant: @expr ref +); +fun_decl_empty_noexcept(int fun_decl: @fun_decl ref); +fun_decl_typedef_type( + unique int fun_decl: @fun_decl ref, + int typedeftype_id: @usertype ref +); + +/* +case @fun_requires.kind of + 1 = @template_attached +| 2 = @function_attached +; +*/ + +fun_requires( + int id: @fun_decl ref, + int kind: int ref, + int constraint: @expr ref +); + +param_decl_bind( + unique int id: @var_decl ref, + int index: int ref, + int fun_decl: @fun_decl ref +); + +#keyset[id, type_id] +var_decls( + int id: @var_decl, + int variable: @variable ref, + int type_id: @type ref, + string name: string ref, + int location: @location_default ref +); +var_def(unique int id: @var_decl ref); +var_specialized(int id: @var_decl ref); +var_decl_specifiers( + int id: @var_decl ref, + string name: string ref +) +is_structured_binding(unique int id: @variable ref); +var_requires( + int id: @var_decl ref, + int constraint: @expr ref +); + +type_decls( + unique int id: @type_decl, + int type_id: @type ref, + int location: @location_default ref +); +type_def(unique int id: @type_decl ref); +type_decl_top( + unique int type_decl: @type_decl ref +); +type_requires( + int id: @type_decl ref, + int constraint: @expr ref +); + +namespace_decls( + unique int id: @namespace_decl, + int namespace_id: @namespace ref, + int location: @location_default ref, + int bodylocation: @location_default ref +); + +case @using.kind of + 1 = @using_declaration +| 2 = @using_directive +| 3 = @using_enum_declaration +; + +usings( + unique int id: @using, + int element_id: @element ref, + int location: @location_default ref, + int kind: int ref +); + +/** The element which contains the `using` declaration. */ +using_container( + int parent: @element ref, + int child: @using ref +); + +static_asserts( + unique int id: @static_assert, + int condition : @expr ref, + string message : string ref, + int location: @location_default ref, + int enclosing : @element ref +); + +// each function has an ordered list of parameters +#keyset[id, type_id] +#keyset[function, index, type_id] +params( + int id: @parameter, + int function: @parameterized_element ref, + int index: int ref, + int type_id: @type ref +); + +overrides( + int new: @function ref, + int old: @function ref +); + +#keyset[id, type_id] +membervariables( + int id: @membervariable, + int type_id: @type ref, + string name: string ref +); + +#keyset[id, type_id] +globalvariables( + int id: @globalvariable, + int type_id: @type ref, + string name: string ref +); + +#keyset[id, type_id] +localvariables( + int id: @localvariable, + int type_id: @type ref, + string name: string ref +); + +autoderivation( + unique int var: @variable ref, + int derivation_type: @type ref +); + +orphaned_variables( + int var: @localvariable ref, + int function: @function ref +) + +enumconstants( + unique int id: @enumconstant, + int parent: @usertype ref, + int index: int ref, + int type_id: @type ref, + string name: string ref, + int location: @location_default ref +); + +@variable = @localscopevariable | @globalvariable | @membervariable; + +@localscopevariable = @localvariable | @parameter; + +/** + * Built-in types are the fundamental types, e.g., integral, floating, and void. + */ +case @builtintype.kind of + 1 = @errortype +| 2 = @unknowntype +| 3 = @void +| 4 = @boolean +| 5 = @char +| 6 = @unsigned_char +| 7 = @signed_char +| 8 = @short +| 9 = @unsigned_short +| 10 = @signed_short +| 11 = @int +| 12 = @unsigned_int +| 13 = @signed_int +| 14 = @long +| 15 = @unsigned_long +| 16 = @signed_long +| 17 = @long_long +| 18 = @unsigned_long_long +| 19 = @signed_long_long +// ... 20 Microsoft-specific __int8 +// ... 21 Microsoft-specific __int16 +// ... 22 Microsoft-specific __int32 +// ... 23 Microsoft-specific __int64 +| 24 = @float +| 25 = @double +| 26 = @long_double +| 27 = @complex_float // C99-specific _Complex float +| 28 = @complex_double // C99-specific _Complex double +| 29 = @complex_long_double // C99-specific _Complex long double +| 30 = @imaginary_float // C99-specific _Imaginary float +| 31 = @imaginary_double // C99-specific _Imaginary double +| 32 = @imaginary_long_double // C99-specific _Imaginary long double +| 33 = @wchar_t // Microsoft-specific +| 34 = @decltype_nullptr // C++11 +| 35 = @int128 // __int128 +| 36 = @unsigned_int128 // unsigned __int128 +| 37 = @signed_int128 // signed __int128 +| 38 = @float128 // __float128 +| 39 = @complex_float128 // _Complex __float128 +// ... 40 _Decimal32 +// ... 41 _Decimal64 +// ... 42 _Decimal128 +| 43 = @char16_t +| 44 = @char32_t +| 45 = @std_float32 // _Float32 +| 46 = @float32x // _Float32x +| 47 = @std_float64 // _Float64 +| 48 = @float64x // _Float64x +| 49 = @std_float128 // _Float128 +// ... 50 _Float128x +| 51 = @char8_t +| 52 = @float16 // _Float16 +| 53 = @complex_float16 // _Complex _Float16 +| 54 = @fp16 // __fp16 +| 55 = @std_bfloat16 // __bf16 +| 56 = @std_float16 // std::float16_t +| 57 = @complex_std_float32 // _Complex _Float32 +| 58 = @complex_float32x // _Complex _Float32x +| 59 = @complex_std_float64 // _Complex _Float64 +| 60 = @complex_float64x // _Complex _Float64x +| 61 = @complex_std_float128 // _Complex _Float128 +| 62 = @mfp8 // __mfp8 +| 63 = @scalable_vector_count // __SVCount_t +| 64 = @complex_fp16 // _Complex __fp16 +| 65 = @complex_std_bfloat16 // _Complex __bf16 +| 66 = @complex_std_float16 // _Complex std::float16_t +; + +builtintypes( + unique int id: @builtintype, + string name: string ref, + int kind: int ref, + int size: int ref, + int sign: int ref, + int alignment: int ref +); + +/** + * Derived types are types that are directly derived from existing types and + * point to, refer to, transform type data to return a new type. + */ +case @derivedtype.kind of + 1 = @pointer +| 2 = @reference +| 3 = @type_with_specifiers +| 4 = @array +| 5 = @gnu_vector +| 6 = @routineptr +| 7 = @routinereference +| 8 = @rvalue_reference // C++11 +// ... 9 type_conforming_to_protocols deprecated +| 10 = @block +| 11 = @scalable_vector // Arm SVE +; + +derivedtypes( + unique int id: @derivedtype, + string name: string ref, + int kind: int ref, + int type_id: @type ref +); + +pointerishsize(unique int id: @derivedtype ref, + int size: int ref, + int alignment: int ref); + +arraysizes( + unique int id: @derivedtype ref, + int num_elements: int ref, + int bytesize: int ref, + int alignment: int ref +); + +tupleelements( + unique int id: @derivedtype ref, + int num_elements: int ref +); + +typedefbase( + unique int id: @usertype ref, + int type_id: @type ref +); + +/** + * An instance of the C++11 `decltype` operator or C23 `typeof`/`typeof_unqual` + * operator taking an expression as its argument. For example: + * ``` + * int a; + * decltype(1+a) b; + * typeof(1+a) c; + * ``` + * Here `expr` is `1+a`. + * + * Sometimes an additional pair of parentheses around the expression + * changes the semantics of the decltype, e.g. + * ``` + * struct A { double x; }; + * const A* a = new A(); + * decltype( a->x ); // type is double + * decltype((a->x)); // type is const double& + * ``` + * (Please consult the C++11 standard for more details). + * `parentheses_would_change_meaning` is `true` iff that is the case. + */ + +/* +case @decltype.kind of +| 0 = @decltype +| 1 = @typeof // The frontend does not differentiate between typeof and typeof_unqual +; +*/ + +#keyset[id, expr] +decltypes( + int id: @decltype, + int expr: @expr ref, + int kind: int ref, + int base_type: @type ref, + boolean parentheses_would_change_meaning: boolean ref +); + +case @type_operator.kind of + 0 = @typeof // The frontend does not differentiate between typeof and typeof_unqual +| 1 = @underlying_type +| 2 = @bases +| 3 = @direct_bases +| 4 = @add_lvalue_reference +| 5 = @add_pointer +| 6 = @add_rvalue_reference +| 7 = @decay +| 8 = @make_signed +| 9 = @make_unsigned +| 10 = @remove_all_extents +| 11 = @remove_const +| 12 = @remove_cv +| 13 = @remove_cvref +| 14 = @remove_extent +| 15 = @remove_pointer +| 16 = @remove_reference_t +| 17 = @remove_restrict +| 18 = @remove_volatile +| 19 = @remove_reference +; + +type_operators( + unique int id: @type_operator, + int arg_type: @type ref, + int kind: int ref, + int base_type: @type ref +) + +case @usertype.kind of + 0 = @unknown_usertype +| 1 = @struct +| 2 = @class +| 3 = @union +| 4 = @enum +// ... 5 = @typedef deprecated // classic C: typedef typedef type name +// ... 6 = @template deprecated +| 7 = @template_parameter +| 8 = @template_template_parameter +| 9 = @proxy_class // a proxy class associated with a template parameter +// ... 10 objc_class deprecated +// ... 11 objc_protocol deprecated +// ... 12 objc_category deprecated +| 13 = @scoped_enum +// ... 14 = @using_alias deprecated // a using name = type style typedef +| 15 = @template_struct +| 16 = @template_class +| 17 = @template_union +| 18 = @alias +; + +usertypes( + unique int id: @usertype, + string name: string ref, + int kind: int ref +); + +usertypesize( + unique int id: @usertype ref, + int size: int ref, + int alignment: int ref +); + +usertype_final(unique int id: @usertype ref); + +usertype_uuid( + unique int id: @usertype ref, + string uuid: string ref +); + +/* +case @usertype.alias_kind of +| 0 = @typedef +| 1 = @alias +*/ + +usertype_alias_kind( + int id: @usertype ref, + int alias_kind: int ref +) + +nontype_template_parameters( + int id: @expr ref +); + +type_template_type_constraint( + int id: @usertype ref, + int constraint: @expr ref +); + +mangled_name( + unique int id: @declaration ref, + int mangled_name : @mangledname, + boolean is_complete: boolean ref +); + +is_pod_class(unique int id: @usertype ref); +is_standard_layout_class(unique int id: @usertype ref); + +is_complete(unique int id: @usertype ref); + +is_class_template(unique int id: @usertype ref); +class_instantiation( + int to: @usertype ref, + int from: @usertype ref +); +class_template_argument( + int type_id: @usertype ref, + int index: int ref, + int arg_type: @type ref +); +class_template_argument_value( + int type_id: @usertype ref, + int index: int ref, + int arg_value: @expr ref +); +class_template_generated_from( + unique int template: @usertype ref, + int from: @usertype ref +) + +@user_or_decltype = @usertype | @decltype; + +is_proxy_class_for( + unique int id: @usertype ref, + int templ_param_id: @user_or_decltype ref +); + +type_mentions( + unique int id: @type_mention, + int type_id: @type ref, + int location: @location_default ref, + // a_symbol_reference_kind from the frontend. + int kind: int ref +); + +is_function_template(unique int id: @function ref); +function_instantiation( + unique int to: @function ref, + int from: @function ref +); +function_template_argument( + int function_id: @function ref, + int index: int ref, + int arg_type: @type ref +); +function_template_argument_value( + int function_id: @function ref, + int index: int ref, + int arg_value: @expr ref +); +function_template_generated_from( + unique int template: @function ref, + int from: @function ref +); + +is_variable_template(unique int id: @variable ref); +variable_instantiation( + unique int to: @variable ref, + int from: @variable ref +); +variable_template_argument( + int variable_id: @variable ref, + int index: int ref, + int arg_type: @type ref +); +variable_template_argument_value( + int variable_id: @variable ref, + int index: int ref, + int arg_value: @expr ref +); +variable_template_generated_from( + unique int template: @variable ref, + int from: @variable ref +); + +is_alias_template(unique int id: @usertype ref); +alias_instantiation( + unique int to: @usertype ref, + int from: @usertype ref +); +alias_template_argument( + int type_id: @usertype ref, + int index: int ref, + int arg_type: @type ref +); +alias_template_argument_value( + int type_id: @usertype ref, + int index: int ref, + int arg_value: @expr ref +); +alias_template_generated_from( + unique int template: @usertype ref, + int from: @usertype ref +); + +template_template_instantiation( + int to: @usertype ref, + int from: @usertype ref +); +template_template_argument( + int type_id: @usertype ref, + int index: int ref, + int arg_type: @type ref +); +template_template_argument_value( + int type_id: @usertype ref, + int index: int ref, + int arg_value: @expr ref +); + +@concept = @concept_template | @concept_id; + +concept_templates( + unique int concept_id: @concept_template, + string name: string ref, + int location: @location_default ref +); +concept_instantiation( + unique int to: @concept_id ref, + int from: @concept_template ref +); +is_type_constraint(int concept_id: @concept_id ref); +concept_template_argument( + int concept_id: @concept ref, + int index: int ref, + int arg_type: @type ref +); +concept_template_argument_value( + int concept_id: @concept ref, + int index: int ref, + int arg_value: @expr ref +); + +routinetypes( + unique int id: @routinetype, + int return_type: @type ref +); + +routinetypeargs( + int routine: @routinetype ref, + int index: int ref, + int type_id: @type ref +); + +ptrtomembers( + unique int id: @ptrtomember, + int type_id: @type ref, + int class_id: @type ref +); + +/* + specifiers for types, functions, and variables + + "public", + "protected", + "private", + + "const", + "volatile", + "static", + + "pure", + "virtual", + "sealed", // Microsoft + "__interface", // Microsoft + "inline", + "explicit", + + "near", // near far extension + "far", // near far extension + "__ptr32", // Microsoft + "__ptr64", // Microsoft + "__sptr", // Microsoft + "__uptr", // Microsoft + "dllimport", // Microsoft + "dllexport", // Microsoft + "thread", // Microsoft + "naked", // Microsoft + "microsoft_inline", // Microsoft + "forceinline", // Microsoft + "selectany", // Microsoft + "nothrow", // Microsoft + "novtable", // Microsoft + "noreturn", // Microsoft + "noinline", // Microsoft + "noalias", // Microsoft + "restrict", // Microsoft +*/ + +specifiers( + unique int id: @specifier, + unique string str: string ref +); + +typespecifiers( + int type_id: @type ref, + int spec_id: @specifier ref +); + +funspecifiers( + int func_id: @function ref, + int spec_id: @specifier ref +); + +varspecifiers( + int var_id: @accessible ref, + int spec_id: @specifier ref +); + +explicit_specifier_exprs( + unique int func_id: @function ref, + int constant: @expr ref +) + +attributes( + unique int id: @attribute, + int kind: int ref, + string name: string ref, + string name_space: string ref, + int location: @location_default ref +); + +case @attribute.kind of + 0 = @gnuattribute +| 1 = @stdattribute +| 2 = @declspec +| 3 = @msattribute +| 4 = @alignas +// ... 5 @objc_propertyattribute deprecated +; + +attribute_args( + unique int id: @attribute_arg, + int kind: int ref, + int attribute: @attribute ref, + int index: int ref, + int location: @location_default ref +); + +case @attribute_arg.kind of + 0 = @attribute_arg_empty +| 1 = @attribute_arg_token +| 2 = @attribute_arg_constant +| 3 = @attribute_arg_type +| 4 = @attribute_arg_constant_expr +| 5 = @attribute_arg_expr +; + +attribute_arg_value( + unique int arg: @attribute_arg ref, + string value: string ref +); +attribute_arg_type( + unique int arg: @attribute_arg ref, + int type_id: @type ref +); +attribute_arg_constant( + unique int arg: @attribute_arg ref, + int constant: @expr ref +) +attribute_arg_expr( + unique int arg: @attribute_arg ref, + int expr: @expr ref +) +attribute_arg_name( + unique int arg: @attribute_arg ref, + string name: string ref +); + +typeattributes( + int type_id: @type ref, + int spec_id: @attribute ref +); + +funcattributes( + int func_id: @function ref, + int spec_id: @attribute ref +); + +varattributes( + int var_id: @accessible ref, + int spec_id: @attribute ref +); + +namespaceattributes( + int namespace_id: @namespace ref, + int spec_id: @attribute ref +); + +stmtattributes( + int stmt_id: @stmt ref, + int spec_id: @attribute ref +); + +@type = @builtintype + | @derivedtype + | @usertype + | @routinetype + | @ptrtomember + | @decltype + | @type_operator; + +unspecifiedtype( + unique int type_id: @type ref, + int unspecified_type_id: @type ref +); + +member( + int parent: @type ref, + int index: int ref, + int child: @member ref +); + +@enclosingfunction_child = @usertype | @variable | @namespace + +enclosingfunction( + unique int child: @enclosingfunction_child ref, + int parent: @function ref +); + +derivations( + unique int derivation: @derivation, + int sub: @type ref, + int index: int ref, + int super: @type ref, + int location: @location_default ref +); + +derspecifiers( + int der_id: @derivation ref, + int spec_id: @specifier ref +); + +/** + * Contains the byte offset of the base class subobject within the derived + * class. Only holds for non-virtual base classes, but see table + * `virtual_base_offsets` for offsets of virtual base class subobjects. + */ +direct_base_offsets( + unique int der_id: @derivation ref, + int offset: int ref +); + +/** + * Contains the byte offset of the virtual base class subobject for class + * `super` within a most-derived object of class `sub`. `super` can be either a + * direct or indirect base class. + */ +#keyset[sub, super] +virtual_base_offsets( + int sub: @usertype ref, + int super: @usertype ref, + int offset: int ref +); + +frienddecls( + unique int id: @frienddecl, + int type_id: @type ref, + int decl_id: @declaration ref, + int location: @location_default ref +); + +@declaredtype = @usertype ; + +@declaration = @function + | @declaredtype + | @variable + | @enumconstant + | @frienddecl + | @concept_template; + +@member = @membervariable + | @function + | @declaredtype + | @enumconstant; + +@locatable = @diagnostic + | @declaration + | @ppd_include + | @ppd_define + | @macroinvocation + /*| @funcall*/ + | @xmllocatable + | @attribute + | @attribute_arg; + +@namedscope = @namespace | @usertype; + +@element = @locatable + | @file + | @folder + | @specifier + | @type + | @expr + | @namespace + | @initialiser + | @stmt + | @derivation + | @comment + | @preprocdirect + | @fun_decl + | @var_decl + | @type_decl + | @namespace_decl + | @using + | @namequalifier + | @specialnamequalifyingelement + | @static_assert + | @type_mention + | @lambdacapture; + +@exprparent = @element; + +comments( + unique int id: @comment, + string contents: string ref, + int location: @location_default ref +); + +commentbinding( + int id: @comment ref, + int element: @element ref +); + +exprconv( + int converted: @expr ref, + unique int conversion: @expr ref +); + +compgenerated(unique int id: @element ref); + +/** + * `destructor_call` destructs the `i`'th entity that should be + * destructed following `element`. Note that entities should be + * destructed in reverse construction order, so for a given `element` + * these should be called from highest to lowest `i`. + */ +#keyset[element, destructor_call] +#keyset[element, i] +synthetic_destructor_call( + int element: @element ref, + int i: int ref, + int destructor_call: @routineexpr ref +); + +namespaces( + unique int id: @namespace, + string name: string ref +); + +namespace_inline( + unique int id: @namespace ref +); + +namespacembrs( + int parentid: @namespace ref, + unique int memberid: @namespacembr ref +); + +@namespacembr = @declaration | @namespace; + +exprparents( + int expr_id: @expr ref, + int child_index: int ref, + int parent_id: @exprparent ref +); + +expr_isload(unique int expr_id: @expr ref); + +@cast = @c_style_cast + | @const_cast + | @dynamic_cast + | @reinterpret_cast + | @static_cast + ; + +/* +case @conversion.kind of + 0 = @simple_conversion // a numeric conversion, qualification conversion, or a reinterpret_cast +| 1 = @bool_conversion // conversion to 'bool' +| 2 = @base_class_conversion // a derived-to-base conversion +| 3 = @derived_class_conversion // a base-to-derived conversion +| 4 = @pm_base_class_conversion // a derived-to-base conversion of a pointer to member +| 5 = @pm_derived_class_conversion // a base-to-derived conversion of a pointer to member +| 6 = @glvalue_adjust // an adjustment of the type of a glvalue +| 7 = @prvalue_adjust // an adjustment of the type of a prvalue +; +*/ +/** + * Describes the semantics represented by a cast expression. This is largely + * independent of the source syntax of the cast, so it is separate from the + * regular expression kind. + */ +conversionkinds( + unique int expr_id: @cast ref, + int kind: int ref +); + +@conversion = @cast + | @array_to_pointer + | @parexpr + | @reference_to + | @ref_indirect + | @temp_init + | @c11_generic + ; + +/* +case @funbindexpr.kind of + 0 = @normal_call // a normal call +| 1 = @virtual_call // a virtual call +| 2 = @adl_call // a call whose target is only found by ADL +; +*/ +iscall( + unique int caller: @funbindexpr ref, + int kind: int ref +); + +numtemplatearguments( + unique int expr_id: @expr ref, + int num: int ref +); + +specialnamequalifyingelements( + unique int id: @specialnamequalifyingelement, + unique string name: string ref +); + +@namequalifiableelement = @expr | @namequalifier; +@namequalifyingelement = @namespace + | @specialnamequalifyingelement + | @usertype + | @decltype; + +namequalifiers( + unique int id: @namequalifier, + unique int qualifiableelement: @namequalifiableelement ref, + int qualifyingelement: @namequalifyingelement ref, + int location: @location_default ref +); + +varbind( + int expr: @varbindexpr ref, + int var: @accessible ref +); + +funbind( + int expr: @funbindexpr ref, + int fun: @function ref +); + +@any_new_expr = @new_expr + | @new_array_expr; + +@new_or_delete_expr = @any_new_expr + | @delete_expr + | @delete_array_expr; + +@prefix_crement_expr = @preincrexpr | @predecrexpr; + +@postfix_crement_expr = @postincrexpr | @postdecrexpr; + +@increment_expr = @preincrexpr | @postincrexpr; + +@decrement_expr = @predecrexpr | @postdecrexpr; + +@crement_expr = @increment_expr | @decrement_expr; + +@un_arith_op_expr = @arithnegexpr + | @unaryplusexpr + | @conjugation + | @realpartexpr + | @imagpartexpr + | @crement_expr + ; + +@un_bitwise_op_expr = @complementexpr; + +@un_log_op_expr = @notexpr; + +@un_op_expr = @address_of + | @indirect + | @un_arith_op_expr + | @un_bitwise_op_expr + | @builtinaddressof + | @vec_fill + | @un_log_op_expr + | @co_await + | @co_yield + ; + +@bin_log_op_expr = @andlogicalexpr | @orlogicalexpr; + +@cmp_op_expr = @eq_op_expr | @rel_op_expr; + +@eq_op_expr = @eqexpr | @neexpr; + +@rel_op_expr = @gtexpr + | @ltexpr + | @geexpr + | @leexpr + | @spaceshipexpr + ; + +@bin_bitwise_op_expr = @lshiftexpr + | @rshiftexpr + | @andexpr + | @orexpr + | @xorexpr + ; + +@p_arith_op_expr = @paddexpr + | @psubexpr + | @pdiffexpr + ; + +@bin_arith_op_expr = @addexpr + | @subexpr + | @mulexpr + | @divexpr + | @remexpr + | @jmulexpr + | @jdivexpr + | @fjaddexpr + | @jfaddexpr + | @fjsubexpr + | @jfsubexpr + | @minexpr + | @maxexpr + | @p_arith_op_expr + ; + +@bin_op_expr = @bin_arith_op_expr + | @bin_bitwise_op_expr + | @cmp_op_expr + | @bin_log_op_expr + ; + +@op_expr = @un_op_expr + | @bin_op_expr + | @assign_expr + | @conditionalexpr + ; + +@assign_arith_expr = @assignaddexpr + | @assignsubexpr + | @assignmulexpr + | @assigndivexpr + | @assignremexpr + ; + +@assign_bitwise_expr = @assignandexpr + | @assignorexpr + | @assignxorexpr + | @assignlshiftexpr + | @assignrshiftexpr + ; + +@assign_pointer_expr = @assignpaddexpr + | @assignpsubexpr + ; + +@assign_op_expr = @assign_arith_expr + | @assign_bitwise_expr + | @assign_pointer_expr + ; + +@assign_expr = @assignexpr | @assign_op_expr | @blockassignexpr + +/* + Binary encoding of the allocator form. + + case @allocator.form of + 0 = plain + | 1 = alignment + ; +*/ + +/** + * The allocator function associated with a `new` or `new[]` expression. + * The `form` column specified whether the allocation call contains an alignment + * argument. + */ +expr_allocator( + unique int expr: @any_new_expr ref, + int func: @function ref, + int form: int ref +); + +/* + Binary encoding of the deallocator form. + + case @deallocator.form of + 0 = plain + | 1 = size + | 2 = alignment + | 4 = destroying_delete + ; +*/ + +/** + * The deallocator function associated with a `delete`, `delete[]`, `new`, or + * `new[]` expression. For a `new` or `new[]` expression, the deallocator is the + * one used to free memory if the initialization throws an exception. + * The `form` column specifies whether the deallocation call contains a size + * argument, and alignment argument, or both. + */ +expr_deallocator( + unique int expr: @new_or_delete_expr ref, + int func: @function ref, + int form: int ref +); + +/** + * Holds if the `@conditionalexpr` is of the two operand form + * `guard ? : false`. + */ +expr_cond_two_operand( + unique int cond: @conditionalexpr ref +); + +/** + * The guard of `@conditionalexpr` `guard ? true : false` + */ +expr_cond_guard( + unique int cond: @conditionalexpr ref, + int guard: @expr ref +); + +/** + * The expression used when the guard of `@conditionalexpr` + * `guard ? true : false` holds. For the two operand form + * `guard ?: false` consider using `expr_cond_guard` instead. + */ +expr_cond_true( + unique int cond: @conditionalexpr ref, + int true: @expr ref +); + +/** + * The expression used when the guard of `@conditionalexpr` + * `guard ? true : false` does not hold. + */ +expr_cond_false( + unique int cond: @conditionalexpr ref, + int false: @expr ref +); + +/** A string representation of the value. */ +values( + unique int id: @value, + string str: string ref +); + +/** The actual text in the source code for the value, if any. */ +valuetext( + unique int id: @value ref, + string text: string ref +); + +valuebind( + int val: @value ref, + unique int expr: @expr ref +); + +fieldoffsets( + unique int id: @variable ref, + int byteoffset: int ref, + int bitoffset: int ref +); + +bitfield( + unique int id: @variable ref, + int bits: int ref, + int declared_bits: int ref +); + +/* TODO +memberprefix( + int member: @expr ref, + int prefix: @expr ref +); +*/ + +/* + kind(1) = mbrcallexpr + kind(2) = mbrptrcallexpr + kind(3) = mbrptrmbrcallexpr + kind(4) = ptrmbrptrmbrcallexpr + kind(5) = mbrreadexpr // x.y + kind(6) = mbrptrreadexpr // p->y + kind(7) = mbrptrmbrreadexpr // x.*pm + kind(8) = mbrptrmbrptrreadexpr // x->*pm + kind(9) = staticmbrreadexpr // static x.y + kind(10) = staticmbrptrreadexpr // static p->y +*/ +/* TODO +memberaccess( + int member: @expr ref, + int kind: int ref +); +*/ + +initialisers( + unique int init: @initialiser, + int var: @accessible ref, + unique int expr: @expr ref, + int location: @location_default ref +); + +braced_initialisers( + int init: @initialiser ref +); + +/** + * An ancestor for the expression, for cases in which we cannot + * otherwise find the expression's parent. + */ +expr_ancestor( + int exp: @expr ref, + int ancestor: @element ref +); + +exprs( + unique int id: @expr, + int kind: int ref, + int location: @location_default ref +); + +expr_reuse( + int reuse: @expr ref, + int original: @expr ref, + int value_category: int ref +) + +/* + case @value.category of + 1 = prval + | 2 = xval + | 3 = lval + ; +*/ +expr_types( + int id: @expr ref, + int typeid: @type ref, + int value_category: int ref +); + +case @expr.kind of + 1 = @errorexpr +| 2 = @address_of // & AddressOfExpr +| 3 = @reference_to // ReferenceToExpr (implicit?) +| 4 = @indirect // * PointerDereferenceExpr +| 5 = @ref_indirect // ReferenceDereferenceExpr (implicit?) +// ... +| 8 = @array_to_pointer // (???) +| 9 = @vacuous_destructor_call // VacuousDestructorCall +// ... +| 11 = @assume // Microsoft +| 12 = @parexpr +| 13 = @arithnegexpr +| 14 = @unaryplusexpr +| 15 = @complementexpr +| 16 = @notexpr +| 17 = @conjugation // GNU ~ operator +| 18 = @realpartexpr // GNU __real +| 19 = @imagpartexpr // GNU __imag +| 20 = @postincrexpr +| 21 = @postdecrexpr +| 22 = @preincrexpr +| 23 = @predecrexpr +| 24 = @conditionalexpr +| 25 = @addexpr +| 26 = @subexpr +| 27 = @mulexpr +| 28 = @divexpr +| 29 = @remexpr +| 30 = @jmulexpr // C99 mul imaginary +| 31 = @jdivexpr // C99 div imaginary +| 32 = @fjaddexpr // C99 add real + imaginary +| 33 = @jfaddexpr // C99 add imaginary + real +| 34 = @fjsubexpr // C99 sub real - imaginary +| 35 = @jfsubexpr // C99 sub imaginary - real +| 36 = @paddexpr // pointer add (pointer + int or int + pointer) +| 37 = @psubexpr // pointer sub (pointer - integer) +| 38 = @pdiffexpr // difference between two pointers +| 39 = @lshiftexpr +| 40 = @rshiftexpr +| 41 = @andexpr +| 42 = @orexpr +| 43 = @xorexpr +| 44 = @eqexpr +| 45 = @neexpr +| 46 = @gtexpr +| 47 = @ltexpr +| 48 = @geexpr +| 49 = @leexpr +| 50 = @minexpr // GNU minimum +| 51 = @maxexpr // GNU maximum +| 52 = @assignexpr +| 53 = @assignaddexpr +| 54 = @assignsubexpr +| 55 = @assignmulexpr +| 56 = @assigndivexpr +| 57 = @assignremexpr +| 58 = @assignlshiftexpr +| 59 = @assignrshiftexpr +| 60 = @assignandexpr +| 61 = @assignorexpr +| 62 = @assignxorexpr +| 63 = @assignpaddexpr // assign pointer add +| 64 = @assignpsubexpr // assign pointer sub +| 65 = @andlogicalexpr +| 66 = @orlogicalexpr +| 67 = @commaexpr +| 68 = @subscriptexpr // access to member of an array, e.g., a[5] +// ... 69 @objc_subscriptexpr deprecated +// ... 70 @cmdaccess deprecated +// ... +| 73 = @virtfunptrexpr +| 74 = @callexpr +// ... 75 @msgexpr_normal deprecated +// ... 76 @msgexpr_super deprecated +// ... 77 @atselectorexpr deprecated +// ... 78 @atprotocolexpr deprecated +| 79 = @vastartexpr +| 80 = @vaargexpr +| 81 = @vaendexpr +| 82 = @vacopyexpr +// ... 83 @atencodeexpr deprecated +| 84 = @varaccess +| 85 = @thisaccess +// ... 86 @objc_box_expr deprecated +| 87 = @new_expr +| 88 = @delete_expr +| 89 = @throw_expr +| 90 = @condition_decl // a variable declared in a condition, e.g., if(int x = y > 2) +| 91 = @braced_init_list +| 92 = @type_id +| 93 = @runtime_sizeof +| 94 = @runtime_alignof +| 95 = @sizeof_pack +| 96 = @expr_stmt // GNU extension +| 97 = @routineexpr +| 98 = @type_operand // used to access a type in certain contexts (haven't found any examples yet....) +| 99 = @offsetofexpr // offsetof ::= type and field +| 100 = @hasassignexpr // __has_assign ::= type +| 101 = @hascopyexpr // __has_copy ::= type +| 102 = @hasnothrowassign // __has_nothrow_assign ::= type +| 103 = @hasnothrowconstr // __has_nothrow_constructor ::= type +| 104 = @hasnothrowcopy // __has_nothrow_copy ::= type +| 105 = @hastrivialassign // __has_trivial_assign ::= type +| 106 = @hastrivialconstr // __has_trivial_constructor ::= type +| 107 = @hastrivialcopy // __has_trivial_copy ::= type +| 108 = @hasuserdestr // __has_user_destructor ::= type +| 109 = @hasvirtualdestr // __has_virtual_destructor ::= type +| 110 = @isabstractexpr // __is_abstract ::= type +| 111 = @isbaseofexpr // __is_base_of ::= type type +| 112 = @isclassexpr // __is_class ::= type +| 113 = @isconvtoexpr // __is_convertible_to ::= type type +| 114 = @isemptyexpr // __is_empty ::= type +| 115 = @isenumexpr // __is_enum ::= type +| 116 = @ispodexpr // __is_pod ::= type +| 117 = @ispolyexpr // __is_polymorphic ::= type +| 118 = @isunionexpr // __is_union ::= type +| 119 = @typescompexpr // GNU __builtin_types_compatible ::= type type +| 120 = @intaddrexpr // frontend internal builtin, used to implement offsetof +// ... +| 122 = @hastrivialdestructor // __has_trivial_destructor ::= type +| 123 = @literal +| 124 = @uuidof +| 127 = @aggregateliteral +| 128 = @delete_array_expr +| 129 = @new_array_expr +// ... 130 @objc_array_literal deprecated +// ... 131 @objc_dictionary_literal deprecated +| 132 = @foldexpr +// ... +| 200 = @ctordirectinit +| 201 = @ctorvirtualinit +| 202 = @ctorfieldinit +| 203 = @ctordelegatinginit +| 204 = @dtordirectdestruct +| 205 = @dtorvirtualdestruct +| 206 = @dtorfielddestruct +// ... +| 210 = @static_cast +| 211 = @reinterpret_cast +| 212 = @const_cast +| 213 = @dynamic_cast +| 214 = @c_style_cast +| 215 = @lambdaexpr +| 216 = @param_ref +| 217 = @noopexpr +// ... +| 294 = @istriviallyconstructibleexpr +| 295 = @isdestructibleexpr +| 296 = @isnothrowdestructibleexpr +| 297 = @istriviallydestructibleexpr +| 298 = @istriviallyassignableexpr +| 299 = @isnothrowassignableexpr +| 300 = @istrivialexpr +| 301 = @isstandardlayoutexpr +| 302 = @istriviallycopyableexpr +| 303 = @isliteraltypeexpr +| 304 = @hastrivialmoveconstructorexpr +| 305 = @hastrivialmoveassignexpr +| 306 = @hasnothrowmoveassignexpr +| 307 = @isconstructibleexpr +| 308 = @isnothrowconstructibleexpr +| 309 = @hasfinalizerexpr +| 310 = @isdelegateexpr +| 311 = @isinterfaceclassexpr +| 312 = @isrefarrayexpr +| 313 = @isrefclassexpr +| 314 = @issealedexpr +| 315 = @issimplevalueclassexpr +| 316 = @isvalueclassexpr +| 317 = @isfinalexpr +| 319 = @noexceptexpr +| 320 = @builtinshufflevector +| 321 = @builtinchooseexpr +| 322 = @builtinaddressof +| 323 = @vec_fill +| 324 = @builtinconvertvector +| 325 = @builtincomplex +| 326 = @spaceshipexpr +| 327 = @co_await +| 328 = @co_yield +| 329 = @temp_init +| 330 = @isassignable +| 331 = @isaggregate +| 332 = @hasuniqueobjectrepresentations +| 333 = @builtinbitcast +| 334 = @builtinshuffle +| 335 = @blockassignexpr +| 336 = @issame +| 337 = @isfunction +| 338 = @islayoutcompatible +| 339 = @ispointerinterconvertiblebaseof +| 340 = @isarray +| 341 = @arrayrank +| 342 = @arrayextent +| 343 = @isarithmetic +| 344 = @iscompletetype +| 345 = @iscompound +| 346 = @isconst +| 347 = @isfloatingpoint +| 348 = @isfundamental +| 349 = @isintegral +| 350 = @islvaluereference +| 351 = @ismemberfunctionpointer +| 352 = @ismemberobjectpointer +| 353 = @ismemberpointer +| 354 = @isobject +| 355 = @ispointer +| 356 = @isreference +| 357 = @isrvaluereference +| 358 = @isscalar +| 359 = @issigned +| 360 = @isunsigned +| 361 = @isvoid +| 362 = @isvolatile +| 363 = @reuseexpr +| 364 = @istriviallycopyassignable +| 365 = @isassignablenopreconditioncheck +| 366 = @referencebindstotemporary +| 367 = @issameas +| 368 = @builtinhasattribute +| 369 = @ispointerinterconvertiblewithclass +| 370 = @builtinispointerinterconvertiblewithclass +| 371 = @iscorrespondingmember +| 372 = @builtiniscorrespondingmember +| 373 = @isboundedarray +| 374 = @isunboundedarray +| 375 = @isreferenceable +| 378 = @isnothrowconvertible +| 379 = @referenceconstructsfromtemporary +| 380 = @referenceconvertsfromtemporary +| 381 = @isconvertible +| 382 = @isvalidwinrttype +| 383 = @iswinclass +| 384 = @iswininterface +| 385 = @istriviallyequalitycomparable +| 386 = @isscopedenum +| 387 = @istriviallyrelocatable +| 388 = @datasizeof +| 389 = @c11_generic +| 390 = @requires_expr +| 391 = @nested_requirement +| 392 = @compound_requirement +| 393 = @concept_id +| 394 = @isinvocable +| 395 = @isnothrowinvocable +| 396 = @isbitwisecloneable +; + +@var_args_expr = @vastartexpr + | @vaendexpr + | @vaargexpr + | @vacopyexpr + ; + +@builtin_op = @var_args_expr + | @noopexpr + | @offsetofexpr + | @intaddrexpr + | @hasassignexpr + | @hascopyexpr + | @hasnothrowassign + | @hasnothrowconstr + | @hasnothrowcopy + | @hastrivialassign + | @hastrivialconstr + | @hastrivialcopy + | @hastrivialdestructor + | @hasuserdestr + | @hasvirtualdestr + | @isabstractexpr + | @isbaseofexpr + | @isclassexpr + | @isconvtoexpr + | @isemptyexpr + | @isenumexpr + | @ispodexpr + | @ispolyexpr + | @isunionexpr + | @typescompexpr + | @builtinshufflevector + | @builtinconvertvector + | @builtinaddressof + | @istriviallyconstructibleexpr + | @isdestructibleexpr + | @isnothrowdestructibleexpr + | @istriviallydestructibleexpr + | @istriviallyassignableexpr + | @isnothrowassignableexpr + | @istrivialexpr + | @isstandardlayoutexpr + | @istriviallycopyableexpr + | @isliteraltypeexpr + | @hastrivialmoveconstructorexpr + | @hastrivialmoveassignexpr + | @hasnothrowmoveassignexpr + | @isconstructibleexpr + | @isnothrowconstructibleexpr + | @hasfinalizerexpr + | @isdelegateexpr + | @isinterfaceclassexpr + | @isrefarrayexpr + | @isrefclassexpr + | @issealedexpr + | @issimplevalueclassexpr + | @isvalueclassexpr + | @isfinalexpr + | @builtinchooseexpr + | @builtincomplex + | @isassignable + | @isaggregate + | @hasuniqueobjectrepresentations + | @builtinbitcast + | @builtinshuffle + | @issame + | @isfunction + | @islayoutcompatible + | @ispointerinterconvertiblebaseof + | @isarray + | @arrayrank + | @arrayextent + | @isarithmetic + | @iscompletetype + | @iscompound + | @isconst + | @isfloatingpoint + | @isfundamental + | @isintegral + | @islvaluereference + | @ismemberfunctionpointer + | @ismemberobjectpointer + | @ismemberpointer + | @isobject + | @ispointer + | @isreference + | @isrvaluereference + | @isscalar + | @issigned + | @isunsigned + | @isvoid + | @isvolatile + | @istriviallycopyassignable + | @isassignablenopreconditioncheck + | @referencebindstotemporary + | @issameas + | @builtinhasattribute + | @ispointerinterconvertiblewithclass + | @builtinispointerinterconvertiblewithclass + | @iscorrespondingmember + | @builtiniscorrespondingmember + | @isboundedarray + | @isunboundedarray + | @isreferenceable + | @isnothrowconvertible + | @referenceconstructsfromtemporary + | @referenceconvertsfromtemporary + | @isconvertible + | @isvalidwinrttype + | @iswinclass + | @iswininterface + | @istriviallyequalitycomparable + | @isscopedenum + | @istriviallyrelocatable + | @isinvocable + | @isnothrowinvocable + | @isbitwisecloneable + ; + +compound_requirement_is_noexcept( + int expr: @compound_requirement ref +); + +new_allocated_type( + unique int expr: @new_expr ref, + int type_id: @type ref +); + +new_array_allocated_type( + unique int expr: @new_array_expr ref, + int type_id: @type ref +); + +param_ref_to_this( + int expr: @param_ref ref +) + +/** + * The field being initialized by an initializer expression within an aggregate + * initializer for a class/struct/union. Position is used to sort repeated initializers. + */ +#keyset[aggregate, position] +aggregate_field_init( + int aggregate: @aggregateliteral ref, + int initializer: @expr ref, + int field: @membervariable ref, + int position: int ref, + boolean is_designated: boolean ref +); + +/** + * The index of the element being initialized by an initializer expression + * within an aggregate initializer for an array. Position is used to sort repeated initializers. + */ +#keyset[aggregate, position] +aggregate_array_init( + int aggregate: @aggregateliteral ref, + int initializer: @expr ref, + int element_index: int ref, + int position: int ref, + boolean is_designated: boolean ref +); + +@ctorinit = @ctordirectinit + | @ctorvirtualinit + | @ctorfieldinit + | @ctordelegatinginit; +@dtordestruct = @dtordirectdestruct + | @dtorvirtualdestruct + | @dtorfielddestruct; + + +condition_decl_bind( + unique int expr: @condition_decl ref, + unique int decl: @declaration ref +); + +typeid_bind( + unique int expr: @type_id ref, + int type_id: @type ref +); + +uuidof_bind( + unique int expr: @uuidof ref, + int type_id: @type ref +); + +@sizeof_or_alignof = @runtime_sizeof | @runtime_alignof | @datasizeof | @sizeof_pack; + +sizeof_bind( + unique int expr: @sizeof_or_alignof ref, + int type_id: @type ref +); + +code_block( + unique int block: @literal ref, + unique int routine: @function ref +); + +lambdas( + unique int expr: @lambdaexpr ref, + string default_capture: string ref, + boolean has_explicit_return_type: boolean ref, + boolean has_explicit_parameter_list: boolean ref +); + +lambda_capture( + unique int id: @lambdacapture, + int lambda: @lambdaexpr ref, + int index: int ref, + int field: @membervariable ref, + boolean captured_by_reference: boolean ref, + boolean is_implicit: boolean ref, + int location: @location_default ref +); + +@funbindexpr = @routineexpr + | @new_expr + | @delete_expr + | @delete_array_expr + | @ctordirectinit + | @ctorvirtualinit + | @ctordelegatinginit + | @dtordirectdestruct + | @dtorvirtualdestruct; + +@varbindexpr = @varaccess | @ctorfieldinit | @dtorfielddestruct; +@addressable = @function | @variable ; +@accessible = @addressable | @enumconstant ; + +@access = @varaccess | @routineexpr ; + +fold( + int expr: @foldexpr ref, + string operator: string ref, + boolean is_left_fold: boolean ref +); + +stmts( + unique int id: @stmt, + int kind: int ref, + int location: @location_default ref +); + +case @stmt.kind of + 1 = @stmt_expr +| 2 = @stmt_if +| 3 = @stmt_while +| 4 = @stmt_goto +| 5 = @stmt_label +| 6 = @stmt_return +| 7 = @stmt_block +| 8 = @stmt_end_test_while // do { ... } while ( ... ) +| 9 = @stmt_for +| 10 = @stmt_switch_case +| 11 = @stmt_switch +| 13 = @stmt_asm // "asm" statement or the body of an asm function +| 15 = @stmt_try_block +| 16 = @stmt_microsoft_try // Microsoft +| 17 = @stmt_decl +| 18 = @stmt_set_vla_size // C99 +| 19 = @stmt_vla_decl // C99 +| 25 = @stmt_assigned_goto // GNU +| 26 = @stmt_empty +| 27 = @stmt_continue +| 28 = @stmt_break +| 29 = @stmt_range_based_for // C++11 +// ... 30 @stmt_at_autoreleasepool_block deprecated +// ... 31 @stmt_objc_for_in deprecated +// ... 32 @stmt_at_synchronized deprecated +| 33 = @stmt_handler +// ... 34 @stmt_finally_end deprecated +| 35 = @stmt_constexpr_if +| 37 = @stmt_co_return +| 38 = @stmt_consteval_if +| 39 = @stmt_not_consteval_if +| 40 = @stmt_leave +; + +type_vla( + int type_id: @type ref, + int decl: @stmt_vla_decl ref +); + +variable_vla( + int var: @variable ref, + int decl: @stmt_vla_decl ref +); + +type_is_vla(unique int type_id: @derivedtype ref) + +if_initialization( + unique int if_stmt: @stmt_if ref, + int init_id: @stmt ref +); + +if_then( + unique int if_stmt: @stmt_if ref, + int then_id: @stmt ref +); + +if_else( + unique int if_stmt: @stmt_if ref, + int else_id: @stmt ref +); + +constexpr_if_initialization( + unique int constexpr_if_stmt: @stmt_constexpr_if ref, + int init_id: @stmt ref +); + +constexpr_if_then( + unique int constexpr_if_stmt: @stmt_constexpr_if ref, + int then_id: @stmt ref +); + +constexpr_if_else( + unique int constexpr_if_stmt: @stmt_constexpr_if ref, + int else_id: @stmt ref +); + +@stmt_consteval_or_not_consteval_if = @stmt_consteval_if | @stmt_not_consteval_if; + +consteval_if_then( + unique int constexpr_if_stmt: @stmt_consteval_or_not_consteval_if ref, + int then_id: @stmt ref +); + +consteval_if_else( + unique int constexpr_if_stmt: @stmt_consteval_or_not_consteval_if ref, + int else_id: @stmt ref +); + +while_body( + unique int while_stmt: @stmt_while ref, + int body_id: @stmt ref +); + +do_body( + unique int do_stmt: @stmt_end_test_while ref, + int body_id: @stmt ref +); + +switch_initialization( + unique int switch_stmt: @stmt_switch ref, + int init_id: @stmt ref +); + +#keyset[switch_stmt, index] +switch_case( + int switch_stmt: @stmt_switch ref, + int index: int ref, + int case_id: @stmt_switch_case ref +); + +switch_body( + unique int switch_stmt: @stmt_switch ref, + int body_id: @stmt ref +); + +@stmt_for_or_range_based_for = @stmt_for + | @stmt_range_based_for; + +for_initialization( + unique int for_stmt: @stmt_for_or_range_based_for ref, + int init_id: @stmt ref +); + +for_condition( + unique int for_stmt: @stmt_for ref, + int condition_id: @expr ref +); + +for_update( + unique int for_stmt: @stmt_for ref, + int update_id: @expr ref +); + +for_body( + unique int for_stmt: @stmt_for ref, + int body_id: @stmt ref +); + +@stmtparent = @stmt | @expr_stmt ; +stmtparents( + unique int id: @stmt ref, + int index: int ref, + int parent: @stmtparent ref +); + +ishandler(unique int block: @stmt_block ref); + +@cfgnode = @stmt | @expr | @function | @initialiser ; + +stmt_decl_bind( + int stmt: @stmt_decl ref, + int num: int ref, + int decl: @declaration ref +); + +stmt_decl_entry_bind( + int stmt: @stmt_decl ref, + int num: int ref, + int decl_entry: @element ref +); + +@parameterized_element = @function | @stmt_block | @requires_expr; + +blockscope( + unique int block: @stmt_block ref, + int enclosing: @parameterized_element ref +); + +@jump = @stmt_goto | @stmt_break | @stmt_continue | @stmt_leave; + +@jumporlabel = @jump | @stmt_label | @literal; + +jumpinfo( + unique int id: @jumporlabel ref, + string str: string ref, + int target: @stmt ref +); + +preprocdirects( + unique int id: @preprocdirect, + int kind: int ref, + int location: @location_default ref +); +case @preprocdirect.kind of + 0 = @ppd_if +| 1 = @ppd_ifdef +| 2 = @ppd_ifndef +| 3 = @ppd_elif +| 4 = @ppd_else +| 5 = @ppd_endif +| 6 = @ppd_plain_include +| 7 = @ppd_define +| 8 = @ppd_undef +| 9 = @ppd_line +| 10 = @ppd_error +| 11 = @ppd_pragma +| 12 = @ppd_objc_import +| 13 = @ppd_include_next +| 14 = @ppd_ms_import +| 15 = @ppd_elifdef +| 16 = @ppd_elifndef +| 17 = @ppd_embed +| 18 = @ppd_warning +; + +@ppd_include = @ppd_plain_include | @ppd_objc_import | @ppd_include_next | @ppd_ms_import; + +@ppd_branch = @ppd_if | @ppd_ifdef | @ppd_ifndef | @ppd_elif | @ppd_elifdef | @ppd_elifndef; + +preprocpair( + int begin : @ppd_branch ref, + int elseelifend : @preprocdirect ref +); + +preproctrue(int branch : @ppd_branch ref); +preprocfalse(int branch : @ppd_branch ref); + +preproctext( + unique int id: @preprocdirect ref, + string head: string ref, + string body: string ref +); + +includes( + unique int id: @ppd_include ref, + int included: @file ref +); + +embeds( + unique int id: @ppd_embed ref, + int included: @file ref +); + +link_targets( + int id: @link_target, + int binary: @file ref +); + +link_parent( + int element : @element ref, + int link_target : @link_target ref +); + +/*- Database metadata -*/ + +/** + * The CLI will automatically emit applicable tuples for this table, + * such as `databaseMetadata("isOverlay", "true")` when building an + * overlay database. + */ +databaseMetadata( + string metadataKey: string ref, + string value: string ref +); + +/*- Overlay support -*/ + +/** + * The CLI will automatically emit tuples for each new/modified/deleted file + * when building an overlay database. + */ +overlayChangedFiles( + string path: string ref +); + +/*- XML Files -*/ + +xmlEncoding( + unique int id: @file ref, + string encoding: string ref +); + +xmlDTDs( + unique int id: @xmldtd, + string root: string ref, + string publicId: string ref, + string systemId: string ref, + int fileid: @file ref +); + +xmlElements( + unique int id: @xmlelement, + string name: string ref, + int parentid: @xmlparent ref, + int idx: int ref, + int fileid: @file ref +); + +xmlAttrs( + unique int id: @xmlattribute, + int elementid: @xmlelement ref, + string name: string ref, + string value: string ref, + int idx: int ref, + int fileid: @file ref +); + +xmlNs( + int id: @xmlnamespace, + string prefixName: string ref, + string URI: string ref, + int fileid: @file ref +); + +xmlHasNs( + int elementId: @xmlnamespaceable ref, + int nsId: @xmlnamespace ref, + int fileid: @file ref +); + +xmlComments( + unique int id: @xmlcomment, + string text: string ref, + int parentid: @xmlparent ref, + int fileid: @file ref +); + +xmlChars( + unique int id: @xmlcharacters, + string text: string ref, + int parentid: @xmlparent ref, + int idx: int ref, + int isCDATA: int ref, + int fileid: @file ref +); + +@xmlparent = @file | @xmlelement; +@xmlnamespaceable = @xmlelement | @xmlattribute; + +xmllocations( + int xmlElement: @xmllocatable ref, + int location: @location_default ref +); + +@xmllocatable = @xmlcharacters | @xmlelement | @xmlcomment | @xmlattribute | @xmldtd | @file | @xmlnamespace; diff --git a/cpp/ql/lib/upgrades/ef8d209a22e27413aaaeff4446f0ecb9fa2c227b/semmlecode.cpp.dbscheme b/cpp/ql/lib/upgrades/ef8d209a22e27413aaaeff4446f0ecb9fa2c227b/semmlecode.cpp.dbscheme new file mode 100644 index 00000000000..0853f43dc8c --- /dev/null +++ b/cpp/ql/lib/upgrades/ef8d209a22e27413aaaeff4446f0ecb9fa2c227b/semmlecode.cpp.dbscheme @@ -0,0 +1,2578 @@ + +/*- Compilations -*/ + +/** + * An invocation of the compiler. Note that more than one file may be + * compiled per invocation. For example, this command compiles three + * source files: + * + * gcc -c f1.c f2.c f3.c + * + * The `id` simply identifies the invocation, while `cwd` is the working + * directory from which the compiler was invoked. + */ +compilations( + /** + * An invocation of the compiler. Note that more than one file may + * be compiled per invocation. For example, this command compiles + * three source files: + * + * gcc -c f1.c f2.c f3.c + */ + unique int id : @compilation, + string cwd : string ref +); + +/** + * The arguments that were passed to the extractor for a compiler + * invocation. If `id` is for the compiler invocation + * + * gcc -c f1.c f2.c f3.c + * + * then typically there will be rows for + * + * num | arg + * --- | --- + * 0 | *path to extractor* + * 1 | `--mimic` + * 2 | `/usr/bin/gcc` + * 3 | `-c` + * 4 | f1.c + * 5 | f2.c + * 6 | f3.c + */ +#keyset[id, num] +compilation_args( + int id : @compilation ref, + int num : int ref, + string arg : string ref +); + +/** + * The expanded arguments that were passed to the extractor for a + * compiler invocation. This is similar to `compilation_args`, but + * for a `@someFile` argument, it includes the arguments from that + * file, rather than just taking the argument literally. + */ +#keyset[id, num] +compilation_expanded_args( + int id : @compilation ref, + int num : int ref, + string arg : string ref +); + +/** + * Optionally, record the build mode for each compilation. + */ +compilation_build_mode( + unique int id : @compilation ref, + int mode : int ref +); + +/* +case @compilation_build_mode.mode of + 0 = @build_mode_none +| 1 = @build_mode_manual +| 2 = @build_mode_auto +; +*/ + +/** + * The source files that are compiled by a compiler invocation. + * If `id` is for the compiler invocation + * + * gcc -c f1.c f2.c f3.c + * + * then there will be rows for + * + * num | arg + * --- | --- + * 0 | f1.c + * 1 | f2.c + * 2 | f3.c + * + * Note that even if those files `#include` headers, those headers + * do not appear as rows. + */ +#keyset[id, num] +compilation_compiling_files( + int id : @compilation ref, + int num : int ref, + int file : @file ref +); + +/** + * The time taken by the extractor for a compiler invocation. + * + * For each file `num`, there will be rows for + * + * kind | seconds + * ---- | --- + * 1 | CPU seconds used by the extractor frontend + * 2 | Elapsed seconds during the extractor frontend + * 3 | CPU seconds used by the extractor backend + * 4 | Elapsed seconds during the extractor backend + */ +#keyset[id, num, kind] +compilation_time( + int id : @compilation ref, + int num : int ref, + /* kind: + 1 = frontend_cpu_seconds + 2 = frontend_elapsed_seconds + 3 = extractor_cpu_seconds + 4 = extractor_elapsed_seconds + */ + int kind : int ref, + float seconds : float ref +); + +/** + * An error or warning generated by the extractor. + * The diagnostic message `diagnostic` was generated during compiler + * invocation `compilation`, and is the `file_number_diagnostic_number`th + * message generated while extracting the `file_number`th file of that + * invocation. + */ +#keyset[compilation, file_number, file_number_diagnostic_number] +diagnostic_for( + int diagnostic : @diagnostic ref, + int compilation : @compilation ref, + int file_number : int ref, + int file_number_diagnostic_number : int ref +); + +/** + * If extraction was successful, then `cpu_seconds` and + * `elapsed_seconds` are the CPU time and elapsed time (respectively) + * that extraction took for compiler invocation `id`. + */ +compilation_finished( + unique int id : @compilation ref, + float cpu_seconds : float ref, + float elapsed_seconds : float ref +); + +/*- External data -*/ + +/** + * External data, loaded from CSV files during snapshot creation. See + * [Tutorial: Incorporating external data](https://help.semmle.com/wiki/display/SD/Tutorial%3A+Incorporating+external+data) + * for more information. + */ +externalData( + int id : @externalDataElement, + string path : string ref, + int column: int ref, + string value : string ref +); + +/*- Source location prefix -*/ + +/** + * The source location of the snapshot. + */ +sourceLocationPrefix(string prefix : string ref); + +/*- Files and folders -*/ + +/** + * The location of an element. + * The location spans column `startcolumn` of line `startline` to + * column `endcolumn` of line `endline` in file `file`. + * For more information, see + * [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/). + */ +locations_default( + unique int id: @location_default, + int file: @file ref, + int beginLine: int ref, + int beginColumn: int ref, + int endLine: int ref, + int endColumn: int ref +); + +files( + unique int id: @file, + string name: string ref +); + +folders( + unique int id: @folder, + string name: string ref +); + +@container = @file | @folder + +containerparent( + int parent: @container ref, + unique int child: @container ref +); + +/*- Lines of code -*/ + +numlines( + int element_id: @sourceline ref, + int num_lines: int ref, + int num_code: int ref, + int num_comment: int ref +); + +/*- Diagnostic messages -*/ + +diagnostics( + unique int id: @diagnostic, + int severity: int ref, + string error_tag: string ref, + string error_message: string ref, + string full_error_message: string ref, + int location: @location_default ref +); + +/*- C++ dbscheme -*/ + +extractor_version( + string codeql_version: string ref, + string frontend_version: string ref +) + +/** + * Gives the TRAP filename that `trap` is associated with. + * For debugging only. + */ +trap_filename( + int trap: @trap, + string filename: string ref +); + +/** + * Gives the tag name for `tag`. + * For debugging only. + */ +tag_name( + int tag: @tag, + string name: string ref +); + +@trap_or_tag = @tag | @trap; + +/** + * Gives the name for the source file. + */ +source_file_name( + int sf: @source_file, + string name: string ref +); + +/** + * In `build-mode: none` overlay mode, indicates that `source_file` + * (`/path/to/foo.c`) uses the TRAP file `trap_file`; i.e. it is the + * TRAP file corresponding to `foo.c`, something it transitively + * includes, or a template instantiation it transitively uses. + */ +source_file_uses_trap( + int source_file: @source_file ref, + int trap_file: @trap ref +); + +/** + * In `build-mode: none` overlay mode, indicates that the TRAP file + * `trap_file` uses tag `tag`. + */ +trap_uses_tag( + int trap_file: @trap ref, + int tag: @tag ref +); + +/** + * Holds if there is a definition of `element` in TRAP file or tag `t`. + */ +in_trap_or_tag( + int element: @element ref, + int t: @trap_or_tag ref +); + +pch_uses( + int pch: @pch ref, + int compilation: @compilation ref, + int id: @file ref +) + +#keyset[pch, compilation] +pch_creations( + int pch: @pch, + int compilation: @compilation ref, + int from: @file ref +) + +/** An element for which line-count information is available. */ +@sourceline = @file | @function | @variable | @enumconstant | @xmllocatable; + +fileannotations( + int id: @file ref, + int kind: int ref, + string name: string ref, + string value: string ref +); + +inmacroexpansion( + int id: @element ref, + int inv: @macroinvocation ref +); + +affectedbymacroexpansion( + int id: @element ref, + int inv: @macroinvocation ref +); + +case @macroinvocation.kind of + 1 = @macro_expansion +| 2 = @other_macro_reference +; + +macroinvocations( + unique int id: @macroinvocation, + int macro_id: @ppd_define ref, + int location: @location_default ref, + int kind: int ref +); + +macroparent( + unique int id: @macroinvocation ref, + int parent_id: @macroinvocation ref +); + +// a macroinvocation may be part of another location +// the way to find a constant expression that uses a macro +// is thus to find a constant expression that has a location +// to which a macro invocation is bound +macrolocationbind( + int id: @macroinvocation ref, + int location: @location_default ref +); + +#keyset[invocation, argument_index] +macro_argument_unexpanded( + int invocation: @macroinvocation ref, + int argument_index: int ref, + string text: string ref +); + +#keyset[invocation, argument_index] +macro_argument_expanded( + int invocation: @macroinvocation ref, + int argument_index: int ref, + string text: string ref +); + +case @function.kind of + 0 = @unknown_function +| 1 = @normal_function +| 2 = @constructor +| 3 = @destructor +| 4 = @conversion_function +| 5 = @operator +// ... 6 = @builtin_function deprecated // GCC built-in functions, e.g. __builtin___memcpy_chk +| 7 = @user_defined_literal +| 8 = @deduction_guide +; + +functions( + unique int id: @function, + string name: string ref, + int kind: int ref +); + +builtin_functions( + int id: @function ref +) + +function_entry_point( + int id: @function ref, + unique int entry_point: @stmt ref +); + +function_return_type( + int id: @function ref, + int return_type: @type ref +); + +/** + * If `function` is a coroutine, then this gives the `std::experimental::resumable_traits` + * instance associated with it, and the variables representing the `handle` and `promise` + * for it. + */ +coroutine( + unique int function: @function ref, + int traits: @type ref +); + +/* +case @coroutine_placeholder_variable.kind of + 1 = @handle +| 2 = @promise +| 3 = @init_await_resume +; +*/ + +coroutine_placeholder_variable( + unique int placeholder_variable: @variable ref, + int kind: int ref, + int function: @function ref +) + +/** The `new` function used for allocating the coroutine state, if any. */ +coroutine_new( + unique int function: @function ref, + int new: @function ref +); + +/** The `delete` function used for deallocating the coroutine state, if any. */ +coroutine_delete( + unique int function: @function ref, + int delete: @function ref +); + +purefunctions(unique int id: @function ref); + +function_deleted(unique int id: @function ref); + +function_defaulted(unique int id: @function ref); + +function_prototyped(unique int id: @function ref) + +deduction_guide_for_class( + int id: @function ref, + int class_template: @usertype ref +) + +member_function_this_type( + unique int id: @function ref, + int this_type: @type ref +); + +#keyset[id, type_id] +fun_decls( + int id: @fun_decl, + int function: @function ref, + int type_id: @type ref, + string name: string ref, + int location: @location_default ref +); +fun_def(unique int id: @fun_decl ref); +fun_specialized(unique int id: @fun_decl ref); +fun_implicit(unique int id: @fun_decl ref); +fun_decl_specifiers( + int id: @fun_decl ref, + string name: string ref +) +#keyset[fun_decl, index] +fun_decl_throws( + int fun_decl: @fun_decl ref, + int index: int ref, + int type_id: @type ref +); +/* an empty throw specification is different from none */ +fun_decl_empty_throws(unique int fun_decl: @fun_decl ref); +fun_decl_noexcept( + int fun_decl: @fun_decl ref, + int constant: @expr ref +); +fun_decl_empty_noexcept(int fun_decl: @fun_decl ref); +fun_decl_typedef_type( + unique int fun_decl: @fun_decl ref, + int typedeftype_id: @usertype ref +); + +/* +case @fun_requires.kind of + 1 = @template_attached +| 2 = @function_attached +; +*/ + +fun_requires( + int id: @fun_decl ref, + int kind: int ref, + int constraint: @expr ref +); + +param_decl_bind( + unique int id: @var_decl ref, + int index: int ref, + int fun_decl: @fun_decl ref +); + +#keyset[id, type_id] +var_decls( + int id: @var_decl, + int variable: @variable ref, + int type_id: @type ref, + string name: string ref, + int location: @location_default ref +); +var_def(unique int id: @var_decl ref); +var_specialized(int id: @var_decl ref); +var_decl_specifiers( + int id: @var_decl ref, + string name: string ref +) +is_structured_binding(unique int id: @variable ref); +var_requires( + int id: @var_decl ref, + int constraint: @expr ref +); + +type_decls( + unique int id: @type_decl, + int type_id: @type ref, + int location: @location_default ref +); +type_def(unique int id: @type_decl ref); +type_decl_top( + unique int type_decl: @type_decl ref +); +type_requires( + int id: @type_decl ref, + int constraint: @expr ref +); + +namespace_decls( + unique int id: @namespace_decl, + int namespace_id: @namespace ref, + int location: @location_default ref, + int bodylocation: @location_default ref +); + +case @using.kind of + 1 = @using_declaration +| 2 = @using_directive +| 3 = @using_enum_declaration +; + +usings( + unique int id: @using, + int element_id: @element ref, + int location: @location_default ref, + int kind: int ref +); + +/** The element which contains the `using` declaration. */ +using_container( + int parent: @element ref, + int child: @using ref +); + +static_asserts( + unique int id: @static_assert, + int condition : @expr ref, + string message : string ref, + int location: @location_default ref, + int enclosing : @element ref +); + +// each function has an ordered list of parameters +#keyset[id, type_id] +#keyset[function, index, type_id] +params( + int id: @parameter, + int function: @parameterized_element ref, + int index: int ref, + int type_id: @type ref +); + +overrides( + int new: @function ref, + int old: @function ref +); + +#keyset[id, type_id] +membervariables( + int id: @membervariable, + int type_id: @type ref, + string name: string ref +); + +#keyset[id, type_id] +globalvariables( + int id: @globalvariable, + int type_id: @type ref, + string name: string ref +); + +#keyset[id, type_id] +localvariables( + int id: @localvariable, + int type_id: @type ref, + string name: string ref +); + +autoderivation( + unique int var: @variable ref, + int derivation_type: @type ref +); + +orphaned_variables( + int var: @localvariable ref, + int function: @function ref +) + +enumconstants( + unique int id: @enumconstant, + int parent: @usertype ref, + int index: int ref, + int type_id: @type ref, + string name: string ref, + int location: @location_default ref +); + +@variable = @localscopevariable | @globalvariable | @membervariable; + +@localscopevariable = @localvariable | @parameter; + +/** + * Built-in types are the fundamental types, e.g., integral, floating, and void. + */ +case @builtintype.kind of + 1 = @errortype +| 2 = @unknowntype +| 3 = @void +| 4 = @boolean +| 5 = @char +| 6 = @unsigned_char +| 7 = @signed_char +| 8 = @short +| 9 = @unsigned_short +| 10 = @signed_short +| 11 = @int +| 12 = @unsigned_int +| 13 = @signed_int +| 14 = @long +| 15 = @unsigned_long +| 16 = @signed_long +| 17 = @long_long +| 18 = @unsigned_long_long +| 19 = @signed_long_long +// ... 20 Microsoft-specific __int8 +// ... 21 Microsoft-specific __int16 +// ... 22 Microsoft-specific __int32 +// ... 23 Microsoft-specific __int64 +| 24 = @float +| 25 = @double +| 26 = @long_double +| 27 = @complex_float // C99-specific _Complex float +| 28 = @complex_double // C99-specific _Complex double +| 29 = @complex_long_double // C99-specific _Complex long double +| 30 = @imaginary_float // C99-specific _Imaginary float +| 31 = @imaginary_double // C99-specific _Imaginary double +| 32 = @imaginary_long_double // C99-specific _Imaginary long double +| 33 = @wchar_t // Microsoft-specific +| 34 = @decltype_nullptr // C++11 +| 35 = @int128 // __int128 +| 36 = @unsigned_int128 // unsigned __int128 +| 37 = @signed_int128 // signed __int128 +| 38 = @float128 // __float128 +| 39 = @complex_float128 // _Complex __float128 +// ... 40 _Decimal32 +// ... 41 _Decimal64 +// ... 42 _Decimal128 +| 43 = @char16_t +| 44 = @char32_t +| 45 = @std_float32 // _Float32 +| 46 = @float32x // _Float32x +| 47 = @std_float64 // _Float64 +| 48 = @float64x // _Float64x +| 49 = @std_float128 // _Float128 +// ... 50 _Float128x +| 51 = @char8_t +| 52 = @float16 // _Float16 +| 53 = @complex_float16 // _Complex _Float16 +| 54 = @fp16 // __fp16 +| 55 = @std_bfloat16 // __bf16 +| 56 = @std_float16 // std::float16_t +| 57 = @complex_std_float32 // _Complex _Float32 +| 58 = @complex_float32x // _Complex _Float32x +| 59 = @complex_std_float64 // _Complex _Float64 +| 60 = @complex_float64x // _Complex _Float64x +| 61 = @complex_std_float128 // _Complex _Float128 +| 62 = @mfp8 // __mfp8 +| 63 = @scalable_vector_count // __SVCount_t +| 64 = @complex_fp16 // _Complex __fp16 +| 65 = @complex_std_bfloat16 // _Complex __bf16 +| 66 = @complex_std_float16 // _Complex std::float16_t +; + +builtintypes( + unique int id: @builtintype, + string name: string ref, + int kind: int ref, + int size: int ref, + int sign: int ref, + int alignment: int ref +); + +/** + * Derived types are types that are directly derived from existing types and + * point to, refer to, transform type data to return a new type. + */ +case @derivedtype.kind of + 1 = @pointer +| 2 = @reference +| 3 = @type_with_specifiers +| 4 = @array +| 5 = @gnu_vector +| 6 = @routineptr +| 7 = @routinereference +| 8 = @rvalue_reference // C++11 +// ... 9 type_conforming_to_protocols deprecated +| 10 = @block +| 11 = @scalable_vector // Arm SVE +; + +derivedtypes( + unique int id: @derivedtype, + string name: string ref, + int kind: int ref, + int type_id: @type ref +); + +pointerishsize(unique int id: @derivedtype ref, + int size: int ref, + int alignment: int ref); + +arraysizes( + unique int id: @derivedtype ref, + int num_elements: int ref, + int bytesize: int ref, + int alignment: int ref +); + +tupleelements( + unique int id: @derivedtype ref, + int num_elements: int ref +); + +typedefbase( + unique int id: @usertype ref, + int type_id: @type ref +); + +/** + * An instance of the C++11 `decltype` operator or C23 `typeof`/`typeof_unqual` + * operator taking an expression as its argument. For example: + * ``` + * int a; + * decltype(1+a) b; + * typeof(1+a) c; + * ``` + * Here `expr` is `1+a`. + * + * Sometimes an additional pair of parentheses around the expression + * changes the semantics of the decltype, e.g. + * ``` + * struct A { double x; }; + * const A* a = new A(); + * decltype( a->x ); // type is double + * decltype((a->x)); // type is const double& + * ``` + * (Please consult the C++11 standard for more details). + * `parentheses_would_change_meaning` is `true` iff that is the case. + */ + +/* +case @decltype.kind of +| 0 = @decltype +| 1 = @typeof // The frontend does not differentiate between typeof and typeof_unqual +; +*/ + +#keyset[id, expr] +decltypes( + int id: @decltype, + int expr: @expr ref, + int kind: int ref, + int base_type: @type ref, + boolean parentheses_would_change_meaning: boolean ref +); + +case @type_operator.kind of + 0 = @typeof // The frontend does not differentiate between typeof and typeof_unqual +| 1 = @underlying_type +| 2 = @bases +| 3 = @direct_bases +| 4 = @add_lvalue_reference +| 5 = @add_pointer +| 6 = @add_rvalue_reference +| 7 = @decay +| 8 = @make_signed +| 9 = @make_unsigned +| 10 = @remove_all_extents +| 11 = @remove_const +| 12 = @remove_cv +| 13 = @remove_cvref +| 14 = @remove_extent +| 15 = @remove_pointer +| 16 = @remove_reference_t +| 17 = @remove_restrict +| 18 = @remove_volatile +| 19 = @remove_reference +; + +type_operators( + unique int id: @type_operator, + int arg_type: @type ref, + int kind: int ref, + int base_type: @type ref +) + +case @usertype.kind of + 0 = @unknown_usertype +| 1 = @struct +| 2 = @class +| 3 = @union +| 4 = @enum +// ... 5 = @typedef deprecated // classic C: typedef typedef type name +// ... 6 = @template deprecated +| 7 = @template_parameter +| 8 = @template_template_parameter +| 9 = @proxy_class // a proxy class associated with a template parameter +// ... 10 objc_class deprecated +// ... 11 objc_protocol deprecated +// ... 12 objc_category deprecated +| 13 = @scoped_enum +// ... 14 = @using_alias deprecated // a using name = type style typedef +| 15 = @template_struct +| 16 = @template_class +| 17 = @template_union +| 18 = @alias +; + +usertypes( + unique int id: @usertype, + string name: string ref, + int kind: int ref +); + +usertypesize( + unique int id: @usertype ref, + int size: int ref, + int alignment: int ref +); + +usertype_final(unique int id: @usertype ref); + +usertype_uuid( + unique int id: @usertype ref, + string uuid: string ref +); + +/* +case @usertype.alias_kind of +| 0 = @typedef +| 1 = @alias +*/ + +usertype_alias_kind( + int id: @usertype ref, + int alias_kind: int ref +) + +nontype_template_parameters( + int id: @expr ref +); + +type_template_type_constraint( + int id: @usertype ref, + int constraint: @expr ref +); + +mangled_name( + unique int id: @declaration ref, + int mangled_name : @mangledname, + boolean is_complete: boolean ref +); + +is_pod_class(unique int id: @usertype ref); +is_standard_layout_class(unique int id: @usertype ref); + +is_complete(unique int id: @usertype ref); + +is_class_template(unique int id: @usertype ref); +class_instantiation( + int to: @usertype ref, + int from: @usertype ref +); +class_template_argument( + int type_id: @usertype ref, + int index: int ref, + int arg_type: @type ref +); +class_template_argument_value( + int type_id: @usertype ref, + int index: int ref, + int arg_value: @expr ref +); +class_template_generated_from( + unique int template: @usertype ref, + int from: @usertype ref +) + +@user_or_decltype = @usertype | @decltype; + +is_proxy_class_for( + unique int id: @usertype ref, + int templ_param_id: @user_or_decltype ref +); + +type_mentions( + unique int id: @type_mention, + int type_id: @type ref, + int location: @location_default ref, + // a_symbol_reference_kind from the frontend. + int kind: int ref +); + +is_function_template(unique int id: @function ref); +function_instantiation( + unique int to: @function ref, + int from: @function ref +); +function_template_argument( + int function_id: @function ref, + int index: int ref, + int arg_type: @type ref +); +function_template_argument_value( + int function_id: @function ref, + int index: int ref, + int arg_value: @expr ref +); +function_template_generated_from( + unique int template: @function ref, + int from: @function ref +); + +is_variable_template(unique int id: @variable ref); +variable_instantiation( + unique int to: @variable ref, + int from: @variable ref +); +variable_template_argument( + int variable_id: @variable ref, + int index: int ref, + int arg_type: @type ref +); +variable_template_argument_value( + int variable_id: @variable ref, + int index: int ref, + int arg_value: @expr ref +); +variable_template_generated_from( + unique int template: @variable ref, + int from: @variable ref +); + +is_alias_template(unique int id: @usertype ref); +alias_instantiation( + unique int to: @usertype ref, + int from: @usertype ref +); +alias_template_argument( + int type_id: @usertype ref, + int index: int ref, + int arg_type: @type ref +); +alias_template_argument_value( + int type_id: @usertype ref, + int index: int ref, + int arg_value: @expr ref +); +alias_template_generated_from( + unique int template: @usertype ref, + int from: @usertype ref +); + +template_template_instantiation( + int to: @usertype ref, + int from: @usertype ref +); +template_template_argument( + int type_id: @usertype ref, + int index: int ref, + int arg_type: @type ref +); +template_template_argument_value( + int type_id: @usertype ref, + int index: int ref, + int arg_value: @expr ref +); + +@concept = @concept_template | @concept_id; + +concept_templates( + unique int concept_id: @concept_template, + string name: string ref, + int location: @location_default ref +); +concept_instantiation( + unique int to: @concept_id ref, + int from: @concept_template ref +); +is_type_constraint(int concept_id: @concept_id ref); +concept_template_argument( + int concept_id: @concept ref, + int index: int ref, + int arg_type: @type ref +); +concept_template_argument_value( + int concept_id: @concept ref, + int index: int ref, + int arg_value: @expr ref +); + +routinetypes( + unique int id: @routinetype, + int return_type: @type ref +); + +routinetypeargs( + int routine: @routinetype ref, + int index: int ref, + int type_id: @type ref +); + +ptrtomembers( + unique int id: @ptrtomember, + int type_id: @type ref, + int class_id: @type ref +); + +/* + specifiers for types, functions, and variables + + "public", + "protected", + "private", + + "const", + "volatile", + "static", + + "pure", + "virtual", + "sealed", // Microsoft + "__interface", // Microsoft + "inline", + "explicit", + + "near", // near far extension + "far", // near far extension + "__ptr32", // Microsoft + "__ptr64", // Microsoft + "__sptr", // Microsoft + "__uptr", // Microsoft + "dllimport", // Microsoft + "dllexport", // Microsoft + "thread", // Microsoft + "naked", // Microsoft + "microsoft_inline", // Microsoft + "forceinline", // Microsoft + "selectany", // Microsoft + "nothrow", // Microsoft + "novtable", // Microsoft + "noreturn", // Microsoft + "noinline", // Microsoft + "noalias", // Microsoft + "restrict", // Microsoft +*/ + +specifiers( + unique int id: @specifier, + unique string str: string ref +); + +typespecifiers( + int type_id: @type ref, + int spec_id: @specifier ref +); + +funspecifiers( + int func_id: @function ref, + int spec_id: @specifier ref +); + +varspecifiers( + int var_id: @accessible ref, + int spec_id: @specifier ref +); + +explicit_specifier_exprs( + unique int func_id: @function ref, + int constant: @expr ref +) + +attributes( + unique int id: @attribute, + int kind: int ref, + string name: string ref, + string name_space: string ref, + int location: @location_default ref +); + +case @attribute.kind of + 0 = @gnuattribute +| 1 = @stdattribute +| 2 = @declspec +| 3 = @msattribute +| 4 = @alignas +// ... 5 @objc_propertyattribute deprecated +; + +attribute_args( + unique int id: @attribute_arg, + int kind: int ref, + int attribute: @attribute ref, + int index: int ref, + int location: @location_default ref +); + +case @attribute_arg.kind of + 0 = @attribute_arg_empty +| 1 = @attribute_arg_token +| 2 = @attribute_arg_constant +| 3 = @attribute_arg_type +| 4 = @attribute_arg_constant_expr +| 5 = @attribute_arg_expr +; + +attribute_arg_value( + unique int arg: @attribute_arg ref, + string value: string ref +); +attribute_arg_type( + unique int arg: @attribute_arg ref, + int type_id: @type ref +); +attribute_arg_constant( + unique int arg: @attribute_arg ref, + int constant: @expr ref +) +attribute_arg_expr( + unique int arg: @attribute_arg ref, + int expr: @expr ref +) +attribute_arg_name( + unique int arg: @attribute_arg ref, + string name: string ref +); + +typeattributes( + int type_id: @type ref, + int spec_id: @attribute ref +); + +funcattributes( + int func_id: @function ref, + int spec_id: @attribute ref +); + +varattributes( + int var_id: @accessible ref, + int spec_id: @attribute ref +); + +namespaceattributes( + int namespace_id: @namespace ref, + int spec_id: @attribute ref +); + +stmtattributes( + int stmt_id: @stmt ref, + int spec_id: @attribute ref +); + +@type = @builtintype + | @derivedtype + | @usertype + | @routinetype + | @ptrtomember + | @decltype + | @type_operator; + +unspecifiedtype( + unique int type_id: @type ref, + int unspecified_type_id: @type ref +); + +member( + int parent: @type ref, + int index: int ref, + int child: @member ref +); + +@enclosingfunction_child = @usertype | @variable | @namespace + +enclosingfunction( + unique int child: @enclosingfunction_child ref, + int parent: @function ref +); + +derivations( + unique int derivation: @derivation, + int sub: @type ref, + int index: int ref, + int super: @type ref, + int location: @location_default ref +); + +derspecifiers( + int der_id: @derivation ref, + int spec_id: @specifier ref +); + +/** + * Contains the byte offset of the base class subobject within the derived + * class. Only holds for non-virtual base classes, but see table + * `virtual_base_offsets` for offsets of virtual base class subobjects. + */ +direct_base_offsets( + unique int der_id: @derivation ref, + int offset: int ref +); + +/** + * Contains the byte offset of the virtual base class subobject for class + * `super` within a most-derived object of class `sub`. `super` can be either a + * direct or indirect base class. + */ +#keyset[sub, super] +virtual_base_offsets( + int sub: @usertype ref, + int super: @usertype ref, + int offset: int ref +); + +frienddecls( + unique int id: @frienddecl, + int type_id: @type ref, + int decl_id: @declaration ref, + int location: @location_default ref +); + +@declaredtype = @usertype ; + +@declaration = @function + | @declaredtype + | @variable + | @enumconstant + | @frienddecl + | @concept_template; + +@member = @membervariable + | @function + | @declaredtype + | @enumconstant; + +@locatable = @diagnostic + | @declaration + | @ppd_include + | @ppd_define + | @macroinvocation + /*| @funcall*/ + | @xmllocatable + | @attribute + | @attribute_arg; + +@namedscope = @namespace | @usertype; + +@element = @locatable + | @file + | @folder + | @specifier + | @type + | @expr + | @namespace + | @initialiser + | @stmt + | @derivation + | @comment + | @preprocdirect + | @fun_decl + | @var_decl + | @type_decl + | @namespace_decl + | @using + | @namequalifier + | @specialnamequalifyingelement + | @static_assert + | @type_mention + | @lambdacapture; + +@exprparent = @element; + +comments( + unique int id: @comment, + string contents: string ref, + int location: @location_default ref +); + +commentbinding( + int id: @comment ref, + int element: @element ref +); + +exprconv( + int converted: @expr ref, + unique int conversion: @expr ref +); + +compgenerated(unique int id: @element ref); + +/** + * `destructor_call` destructs the `i`'th entity that should be + * destructed following `element`. Note that entities should be + * destructed in reverse construction order, so for a given `element` + * these should be called from highest to lowest `i`. + */ +#keyset[element, destructor_call] +#keyset[element, i] +synthetic_destructor_call( + int element: @element ref, + int i: int ref, + int destructor_call: @routineexpr ref +); + +namespaces( + unique int id: @namespace, + string name: string ref +); + +namespace_inline( + unique int id: @namespace ref +); + +namespacembrs( + int parentid: @namespace ref, + unique int memberid: @namespacembr ref +); + +@namespacembr = @declaration | @namespace; + +exprparents( + int expr_id: @expr ref, + int child_index: int ref, + int parent_id: @exprparent ref +); + +expr_isload(unique int expr_id: @expr ref); + +@cast = @c_style_cast + | @const_cast + | @dynamic_cast + | @reinterpret_cast + | @static_cast + ; + +/* +case @conversion.kind of + 0 = @simple_conversion // a numeric conversion, qualification conversion, or a reinterpret_cast +| 1 = @bool_conversion // conversion to 'bool' +| 2 = @base_class_conversion // a derived-to-base conversion +| 3 = @derived_class_conversion // a base-to-derived conversion +| 4 = @pm_base_class_conversion // a derived-to-base conversion of a pointer to member +| 5 = @pm_derived_class_conversion // a base-to-derived conversion of a pointer to member +| 6 = @glvalue_adjust // an adjustment of the type of a glvalue +| 7 = @prvalue_adjust // an adjustment of the type of a prvalue +; +*/ +/** + * Describes the semantics represented by a cast expression. This is largely + * independent of the source syntax of the cast, so it is separate from the + * regular expression kind. + */ +conversionkinds( + unique int expr_id: @cast ref, + int kind: int ref +); + +@conversion = @cast + | @array_to_pointer + | @parexpr + | @reference_to + | @ref_indirect + | @temp_init + | @c11_generic + ; + +/* +case @funbindexpr.kind of + 0 = @normal_call // a normal call +| 1 = @virtual_call // a virtual call +| 2 = @adl_call // a call whose target is only found by ADL +; +*/ +iscall( + unique int caller: @funbindexpr ref, + int kind: int ref +); + +numtemplatearguments( + unique int expr_id: @expr ref, + int num: int ref +); + +specialnamequalifyingelements( + unique int id: @specialnamequalifyingelement, + unique string name: string ref +); + +@namequalifiableelement = @expr | @namequalifier; +@namequalifyingelement = @namespace + | @specialnamequalifyingelement + | @usertype + | @decltype + | @derivedtype; + +namequalifiers( + unique int id: @namequalifier, + unique int qualifiableelement: @namequalifiableelement ref, + int qualifyingelement: @namequalifyingelement ref, + int location: @location_default ref +); + +varbind( + int expr: @varbindexpr ref, + int var: @accessible ref +); + +funbind( + int expr: @funbindexpr ref, + int fun: @function ref +); + +@any_new_expr = @new_expr + | @new_array_expr; + +@new_or_delete_expr = @any_new_expr + | @delete_expr + | @delete_array_expr; + +@prefix_crement_expr = @preincrexpr | @predecrexpr; + +@postfix_crement_expr = @postincrexpr | @postdecrexpr; + +@increment_expr = @preincrexpr | @postincrexpr; + +@decrement_expr = @predecrexpr | @postdecrexpr; + +@crement_expr = @increment_expr | @decrement_expr; + +@un_arith_op_expr = @arithnegexpr + | @unaryplusexpr + | @conjugation + | @realpartexpr + | @imagpartexpr + | @crement_expr + ; + +@un_bitwise_op_expr = @complementexpr; + +@un_log_op_expr = @notexpr; + +@un_op_expr = @address_of + | @indirect + | @un_arith_op_expr + | @un_bitwise_op_expr + | @builtinaddressof + | @vec_fill + | @un_log_op_expr + | @co_await + | @co_yield + ; + +@bin_log_op_expr = @andlogicalexpr | @orlogicalexpr; + +@cmp_op_expr = @eq_op_expr | @rel_op_expr; + +@eq_op_expr = @eqexpr | @neexpr; + +@rel_op_expr = @gtexpr + | @ltexpr + | @geexpr + | @leexpr + | @spaceshipexpr + ; + +@bin_bitwise_op_expr = @lshiftexpr + | @rshiftexpr + | @andexpr + | @orexpr + | @xorexpr + ; + +@p_arith_op_expr = @paddexpr + | @psubexpr + | @pdiffexpr + ; + +@bin_arith_op_expr = @addexpr + | @subexpr + | @mulexpr + | @divexpr + | @remexpr + | @jmulexpr + | @jdivexpr + | @fjaddexpr + | @jfaddexpr + | @fjsubexpr + | @jfsubexpr + | @minexpr + | @maxexpr + | @p_arith_op_expr + ; + +@bin_op_expr = @bin_arith_op_expr + | @bin_bitwise_op_expr + | @cmp_op_expr + | @bin_log_op_expr + ; + +@op_expr = @un_op_expr + | @bin_op_expr + | @assign_expr + | @conditionalexpr + ; + +@assign_arith_expr = @assignaddexpr + | @assignsubexpr + | @assignmulexpr + | @assigndivexpr + | @assignremexpr + ; + +@assign_bitwise_expr = @assignandexpr + | @assignorexpr + | @assignxorexpr + | @assignlshiftexpr + | @assignrshiftexpr + ; + +@assign_pointer_expr = @assignpaddexpr + | @assignpsubexpr + ; + +@assign_op_expr = @assign_arith_expr + | @assign_bitwise_expr + | @assign_pointer_expr + ; + +@assign_expr = @assignexpr | @assign_op_expr | @blockassignexpr + +/* + Binary encoding of the allocator form. + + case @allocator.form of + 0 = plain + | 1 = alignment + ; +*/ + +/** + * The allocator function associated with a `new` or `new[]` expression. + * The `form` column specified whether the allocation call contains an alignment + * argument. + */ +expr_allocator( + unique int expr: @any_new_expr ref, + int func: @function ref, + int form: int ref +); + +/* + Binary encoding of the deallocator form. + + case @deallocator.form of + 0 = plain + | 1 = size + | 2 = alignment + | 4 = destroying_delete + ; +*/ + +/** + * The deallocator function associated with a `delete`, `delete[]`, `new`, or + * `new[]` expression. For a `new` or `new[]` expression, the deallocator is the + * one used to free memory if the initialization throws an exception. + * The `form` column specifies whether the deallocation call contains a size + * argument, and alignment argument, or both. + */ +expr_deallocator( + unique int expr: @new_or_delete_expr ref, + int func: @function ref, + int form: int ref +); + +/** + * Holds if the `@conditionalexpr` is of the two operand form + * `guard ? : false`. + */ +expr_cond_two_operand( + unique int cond: @conditionalexpr ref +); + +/** + * The guard of `@conditionalexpr` `guard ? true : false` + */ +expr_cond_guard( + unique int cond: @conditionalexpr ref, + int guard: @expr ref +); + +/** + * The expression used when the guard of `@conditionalexpr` + * `guard ? true : false` holds. For the two operand form + * `guard ?: false` consider using `expr_cond_guard` instead. + */ +expr_cond_true( + unique int cond: @conditionalexpr ref, + int true: @expr ref +); + +/** + * The expression used when the guard of `@conditionalexpr` + * `guard ? true : false` does not hold. + */ +expr_cond_false( + unique int cond: @conditionalexpr ref, + int false: @expr ref +); + +/** A string representation of the value. */ +values( + unique int id: @value, + string str: string ref +); + +/** The actual text in the source code for the value, if any. */ +valuetext( + unique int id: @value ref, + string text: string ref +); + +valuebind( + int val: @value ref, + unique int expr: @expr ref +); + +fieldoffsets( + unique int id: @variable ref, + int byteoffset: int ref, + int bitoffset: int ref +); + +bitfield( + unique int id: @variable ref, + int bits: int ref, + int declared_bits: int ref +); + +/* TODO +memberprefix( + int member: @expr ref, + int prefix: @expr ref +); +*/ + +/* + kind(1) = mbrcallexpr + kind(2) = mbrptrcallexpr + kind(3) = mbrptrmbrcallexpr + kind(4) = ptrmbrptrmbrcallexpr + kind(5) = mbrreadexpr // x.y + kind(6) = mbrptrreadexpr // p->y + kind(7) = mbrptrmbrreadexpr // x.*pm + kind(8) = mbrptrmbrptrreadexpr // x->*pm + kind(9) = staticmbrreadexpr // static x.y + kind(10) = staticmbrptrreadexpr // static p->y +*/ +/* TODO +memberaccess( + int member: @expr ref, + int kind: int ref +); +*/ + +initialisers( + unique int init: @initialiser, + int var: @accessible ref, + unique int expr: @expr ref, + int location: @location_default ref +); + +braced_initialisers( + int init: @initialiser ref +); + +/** + * An ancestor for the expression, for cases in which we cannot + * otherwise find the expression's parent. + */ +expr_ancestor( + int exp: @expr ref, + int ancestor: @element ref +); + +exprs( + unique int id: @expr, + int kind: int ref, + int location: @location_default ref +); + +expr_reuse( + int reuse: @expr ref, + int original: @expr ref, + int value_category: int ref +) + +/* + case @value.category of + 1 = prval + | 2 = xval + | 3 = lval + ; +*/ +expr_types( + int id: @expr ref, + int typeid: @type ref, + int value_category: int ref +); + +case @expr.kind of + 1 = @errorexpr +| 2 = @address_of // & AddressOfExpr +| 3 = @reference_to // ReferenceToExpr (implicit?) +| 4 = @indirect // * PointerDereferenceExpr +| 5 = @ref_indirect // ReferenceDereferenceExpr (implicit?) +// ... +| 8 = @array_to_pointer // (???) +| 9 = @vacuous_destructor_call // VacuousDestructorCall +// ... +| 11 = @assume // Microsoft +| 12 = @parexpr +| 13 = @arithnegexpr +| 14 = @unaryplusexpr +| 15 = @complementexpr +| 16 = @notexpr +| 17 = @conjugation // GNU ~ operator +| 18 = @realpartexpr // GNU __real +| 19 = @imagpartexpr // GNU __imag +| 20 = @postincrexpr +| 21 = @postdecrexpr +| 22 = @preincrexpr +| 23 = @predecrexpr +| 24 = @conditionalexpr +| 25 = @addexpr +| 26 = @subexpr +| 27 = @mulexpr +| 28 = @divexpr +| 29 = @remexpr +| 30 = @jmulexpr // C99 mul imaginary +| 31 = @jdivexpr // C99 div imaginary +| 32 = @fjaddexpr // C99 add real + imaginary +| 33 = @jfaddexpr // C99 add imaginary + real +| 34 = @fjsubexpr // C99 sub real - imaginary +| 35 = @jfsubexpr // C99 sub imaginary - real +| 36 = @paddexpr // pointer add (pointer + int or int + pointer) +| 37 = @psubexpr // pointer sub (pointer - integer) +| 38 = @pdiffexpr // difference between two pointers +| 39 = @lshiftexpr +| 40 = @rshiftexpr +| 41 = @andexpr +| 42 = @orexpr +| 43 = @xorexpr +| 44 = @eqexpr +| 45 = @neexpr +| 46 = @gtexpr +| 47 = @ltexpr +| 48 = @geexpr +| 49 = @leexpr +| 50 = @minexpr // GNU minimum +| 51 = @maxexpr // GNU maximum +| 52 = @assignexpr +| 53 = @assignaddexpr +| 54 = @assignsubexpr +| 55 = @assignmulexpr +| 56 = @assigndivexpr +| 57 = @assignremexpr +| 58 = @assignlshiftexpr +| 59 = @assignrshiftexpr +| 60 = @assignandexpr +| 61 = @assignorexpr +| 62 = @assignxorexpr +| 63 = @assignpaddexpr // assign pointer add +| 64 = @assignpsubexpr // assign pointer sub +| 65 = @andlogicalexpr +| 66 = @orlogicalexpr +| 67 = @commaexpr +| 68 = @subscriptexpr // access to member of an array, e.g., a[5] +// ... 69 @objc_subscriptexpr deprecated +// ... 70 @cmdaccess deprecated +// ... +| 73 = @virtfunptrexpr +| 74 = @callexpr +// ... 75 @msgexpr_normal deprecated +// ... 76 @msgexpr_super deprecated +// ... 77 @atselectorexpr deprecated +// ... 78 @atprotocolexpr deprecated +| 79 = @vastartexpr +| 80 = @vaargexpr +| 81 = @vaendexpr +| 82 = @vacopyexpr +// ... 83 @atencodeexpr deprecated +| 84 = @varaccess +| 85 = @thisaccess +// ... 86 @objc_box_expr deprecated +| 87 = @new_expr +| 88 = @delete_expr +| 89 = @throw_expr +| 90 = @condition_decl // a variable declared in a condition, e.g., if(int x = y > 2) +| 91 = @braced_init_list +| 92 = @type_id +| 93 = @runtime_sizeof +| 94 = @runtime_alignof +| 95 = @sizeof_pack +| 96 = @expr_stmt // GNU extension +| 97 = @routineexpr +| 98 = @type_operand // used to access a type in certain contexts (haven't found any examples yet....) +| 99 = @offsetofexpr // offsetof ::= type and field +| 100 = @hasassignexpr // __has_assign ::= type +| 101 = @hascopyexpr // __has_copy ::= type +| 102 = @hasnothrowassign // __has_nothrow_assign ::= type +| 103 = @hasnothrowconstr // __has_nothrow_constructor ::= type +| 104 = @hasnothrowcopy // __has_nothrow_copy ::= type +| 105 = @hastrivialassign // __has_trivial_assign ::= type +| 106 = @hastrivialconstr // __has_trivial_constructor ::= type +| 107 = @hastrivialcopy // __has_trivial_copy ::= type +| 108 = @hasuserdestr // __has_user_destructor ::= type +| 109 = @hasvirtualdestr // __has_virtual_destructor ::= type +| 110 = @isabstractexpr // __is_abstract ::= type +| 111 = @isbaseofexpr // __is_base_of ::= type type +| 112 = @isclassexpr // __is_class ::= type +| 113 = @isconvtoexpr // __is_convertible_to ::= type type +| 114 = @isemptyexpr // __is_empty ::= type +| 115 = @isenumexpr // __is_enum ::= type +| 116 = @ispodexpr // __is_pod ::= type +| 117 = @ispolyexpr // __is_polymorphic ::= type +| 118 = @isunionexpr // __is_union ::= type +| 119 = @typescompexpr // GNU __builtin_types_compatible ::= type type +| 120 = @intaddrexpr // frontend internal builtin, used to implement offsetof +// ... +| 122 = @hastrivialdestructor // __has_trivial_destructor ::= type +| 123 = @literal +| 124 = @uuidof +| 127 = @aggregateliteral +| 128 = @delete_array_expr +| 129 = @new_array_expr +// ... 130 @objc_array_literal deprecated +// ... 131 @objc_dictionary_literal deprecated +| 132 = @foldexpr +// ... +| 200 = @ctordirectinit +| 201 = @ctorvirtualinit +| 202 = @ctorfieldinit +| 203 = @ctordelegatinginit +| 204 = @dtordirectdestruct +| 205 = @dtorvirtualdestruct +| 206 = @dtorfielddestruct +// ... +| 210 = @static_cast +| 211 = @reinterpret_cast +| 212 = @const_cast +| 213 = @dynamic_cast +| 214 = @c_style_cast +| 215 = @lambdaexpr +| 216 = @param_ref +| 217 = @noopexpr +// ... +| 294 = @istriviallyconstructibleexpr +| 295 = @isdestructibleexpr +| 296 = @isnothrowdestructibleexpr +| 297 = @istriviallydestructibleexpr +| 298 = @istriviallyassignableexpr +| 299 = @isnothrowassignableexpr +| 300 = @istrivialexpr +| 301 = @isstandardlayoutexpr +| 302 = @istriviallycopyableexpr +| 303 = @isliteraltypeexpr +| 304 = @hastrivialmoveconstructorexpr +| 305 = @hastrivialmoveassignexpr +| 306 = @hasnothrowmoveassignexpr +| 307 = @isconstructibleexpr +| 308 = @isnothrowconstructibleexpr +| 309 = @hasfinalizerexpr +| 310 = @isdelegateexpr +| 311 = @isinterfaceclassexpr +| 312 = @isrefarrayexpr +| 313 = @isrefclassexpr +| 314 = @issealedexpr +| 315 = @issimplevalueclassexpr +| 316 = @isvalueclassexpr +| 317 = @isfinalexpr +| 319 = @noexceptexpr +| 320 = @builtinshufflevector +| 321 = @builtinchooseexpr +| 322 = @builtinaddressof +| 323 = @vec_fill +| 324 = @builtinconvertvector +| 325 = @builtincomplex +| 326 = @spaceshipexpr +| 327 = @co_await +| 328 = @co_yield +| 329 = @temp_init +| 330 = @isassignable +| 331 = @isaggregate +| 332 = @hasuniqueobjectrepresentations +| 333 = @builtinbitcast +| 334 = @builtinshuffle +| 335 = @blockassignexpr +| 336 = @issame +| 337 = @isfunction +| 338 = @islayoutcompatible +| 339 = @ispointerinterconvertiblebaseof +| 340 = @isarray +| 341 = @arrayrank +| 342 = @arrayextent +| 343 = @isarithmetic +| 344 = @iscompletetype +| 345 = @iscompound +| 346 = @isconst +| 347 = @isfloatingpoint +| 348 = @isfundamental +| 349 = @isintegral +| 350 = @islvaluereference +| 351 = @ismemberfunctionpointer +| 352 = @ismemberobjectpointer +| 353 = @ismemberpointer +| 354 = @isobject +| 355 = @ispointer +| 356 = @isreference +| 357 = @isrvaluereference +| 358 = @isscalar +| 359 = @issigned +| 360 = @isunsigned +| 361 = @isvoid +| 362 = @isvolatile +| 363 = @reuseexpr +| 364 = @istriviallycopyassignable +| 365 = @isassignablenopreconditioncheck +| 366 = @referencebindstotemporary +| 367 = @issameas +| 368 = @builtinhasattribute +| 369 = @ispointerinterconvertiblewithclass +| 370 = @builtinispointerinterconvertiblewithclass +| 371 = @iscorrespondingmember +| 372 = @builtiniscorrespondingmember +| 373 = @isboundedarray +| 374 = @isunboundedarray +| 375 = @isreferenceable +| 378 = @isnothrowconvertible +| 379 = @referenceconstructsfromtemporary +| 380 = @referenceconvertsfromtemporary +| 381 = @isconvertible +| 382 = @isvalidwinrttype +| 383 = @iswinclass +| 384 = @iswininterface +| 385 = @istriviallyequalitycomparable +| 386 = @isscopedenum +| 387 = @istriviallyrelocatable +| 388 = @datasizeof +| 389 = @c11_generic +| 390 = @requires_expr +| 391 = @nested_requirement +| 392 = @compound_requirement +| 393 = @concept_id +| 394 = @isinvocable +| 395 = @isnothrowinvocable +| 396 = @isbitwisecloneable +; + +@var_args_expr = @vastartexpr + | @vaendexpr + | @vaargexpr + | @vacopyexpr + ; + +@builtin_op = @var_args_expr + | @noopexpr + | @offsetofexpr + | @intaddrexpr + | @hasassignexpr + | @hascopyexpr + | @hasnothrowassign + | @hasnothrowconstr + | @hasnothrowcopy + | @hastrivialassign + | @hastrivialconstr + | @hastrivialcopy + | @hastrivialdestructor + | @hasuserdestr + | @hasvirtualdestr + | @isabstractexpr + | @isbaseofexpr + | @isclassexpr + | @isconvtoexpr + | @isemptyexpr + | @isenumexpr + | @ispodexpr + | @ispolyexpr + | @isunionexpr + | @typescompexpr + | @builtinshufflevector + | @builtinconvertvector + | @builtinaddressof + | @istriviallyconstructibleexpr + | @isdestructibleexpr + | @isnothrowdestructibleexpr + | @istriviallydestructibleexpr + | @istriviallyassignableexpr + | @isnothrowassignableexpr + | @istrivialexpr + | @isstandardlayoutexpr + | @istriviallycopyableexpr + | @isliteraltypeexpr + | @hastrivialmoveconstructorexpr + | @hastrivialmoveassignexpr + | @hasnothrowmoveassignexpr + | @isconstructibleexpr + | @isnothrowconstructibleexpr + | @hasfinalizerexpr + | @isdelegateexpr + | @isinterfaceclassexpr + | @isrefarrayexpr + | @isrefclassexpr + | @issealedexpr + | @issimplevalueclassexpr + | @isvalueclassexpr + | @isfinalexpr + | @builtinchooseexpr + | @builtincomplex + | @isassignable + | @isaggregate + | @hasuniqueobjectrepresentations + | @builtinbitcast + | @builtinshuffle + | @issame + | @isfunction + | @islayoutcompatible + | @ispointerinterconvertiblebaseof + | @isarray + | @arrayrank + | @arrayextent + | @isarithmetic + | @iscompletetype + | @iscompound + | @isconst + | @isfloatingpoint + | @isfundamental + | @isintegral + | @islvaluereference + | @ismemberfunctionpointer + | @ismemberobjectpointer + | @ismemberpointer + | @isobject + | @ispointer + | @isreference + | @isrvaluereference + | @isscalar + | @issigned + | @isunsigned + | @isvoid + | @isvolatile + | @istriviallycopyassignable + | @isassignablenopreconditioncheck + | @referencebindstotemporary + | @issameas + | @builtinhasattribute + | @ispointerinterconvertiblewithclass + | @builtinispointerinterconvertiblewithclass + | @iscorrespondingmember + | @builtiniscorrespondingmember + | @isboundedarray + | @isunboundedarray + | @isreferenceable + | @isnothrowconvertible + | @referenceconstructsfromtemporary + | @referenceconvertsfromtemporary + | @isconvertible + | @isvalidwinrttype + | @iswinclass + | @iswininterface + | @istriviallyequalitycomparable + | @isscopedenum + | @istriviallyrelocatable + | @isinvocable + | @isnothrowinvocable + | @isbitwisecloneable + ; + +compound_requirement_is_noexcept( + int expr: @compound_requirement ref +); + +new_allocated_type( + unique int expr: @new_expr ref, + int type_id: @type ref +); + +new_array_allocated_type( + unique int expr: @new_array_expr ref, + int type_id: @type ref +); + +param_ref_to_this( + int expr: @param_ref ref +) + +/** + * The field being initialized by an initializer expression within an aggregate + * initializer for a class/struct/union. Position is used to sort repeated initializers. + */ +#keyset[aggregate, position] +aggregate_field_init( + int aggregate: @aggregateliteral ref, + int initializer: @expr ref, + int field: @membervariable ref, + int position: int ref, + boolean is_designated: boolean ref +); + +/** + * The index of the element being initialized by an initializer expression + * within an aggregate initializer for an array. Position is used to sort repeated initializers. + */ +#keyset[aggregate, position] +aggregate_array_init( + int aggregate: @aggregateliteral ref, + int initializer: @expr ref, + int element_index: int ref, + int position: int ref, + boolean is_designated: boolean ref +); + +@ctorinit = @ctordirectinit + | @ctorvirtualinit + | @ctorfieldinit + | @ctordelegatinginit; +@dtordestruct = @dtordirectdestruct + | @dtorvirtualdestruct + | @dtorfielddestruct; + + +condition_decl_bind( + unique int expr: @condition_decl ref, + unique int decl: @declaration ref +); + +typeid_bind( + unique int expr: @type_id ref, + int type_id: @type ref +); + +uuidof_bind( + unique int expr: @uuidof ref, + int type_id: @type ref +); + +@sizeof_or_alignof = @runtime_sizeof | @runtime_alignof | @datasizeof | @sizeof_pack; + +sizeof_bind( + unique int expr: @sizeof_or_alignof ref, + int type_id: @type ref +); + +code_block( + unique int block: @literal ref, + unique int routine: @function ref +); + +lambdas( + unique int expr: @lambdaexpr ref, + string default_capture: string ref, + boolean has_explicit_return_type: boolean ref, + boolean has_explicit_parameter_list: boolean ref +); + +lambda_capture( + unique int id: @lambdacapture, + int lambda: @lambdaexpr ref, + int index: int ref, + int field: @membervariable ref, + boolean captured_by_reference: boolean ref, + boolean is_implicit: boolean ref, + int location: @location_default ref +); + +@funbindexpr = @routineexpr + | @new_expr + | @delete_expr + | @delete_array_expr + | @ctordirectinit + | @ctorvirtualinit + | @ctordelegatinginit + | @dtordirectdestruct + | @dtorvirtualdestruct; + +@varbindexpr = @varaccess | @ctorfieldinit | @dtorfielddestruct; +@addressable = @function | @variable ; +@accessible = @addressable | @enumconstant ; + +@access = @varaccess | @routineexpr ; + +fold( + int expr: @foldexpr ref, + string operator: string ref, + boolean is_left_fold: boolean ref +); + +stmts( + unique int id: @stmt, + int kind: int ref, + int location: @location_default ref +); + +case @stmt.kind of + 1 = @stmt_expr +| 2 = @stmt_if +| 3 = @stmt_while +| 4 = @stmt_goto +| 5 = @stmt_label +| 6 = @stmt_return +| 7 = @stmt_block +| 8 = @stmt_end_test_while // do { ... } while ( ... ) +| 9 = @stmt_for +| 10 = @stmt_switch_case +| 11 = @stmt_switch +| 13 = @stmt_asm // "asm" statement or the body of an asm function +| 15 = @stmt_try_block +| 16 = @stmt_microsoft_try // Microsoft +| 17 = @stmt_decl +| 18 = @stmt_set_vla_size // C99 +| 19 = @stmt_vla_decl // C99 +| 25 = @stmt_assigned_goto // GNU +| 26 = @stmt_empty +| 27 = @stmt_continue +| 28 = @stmt_break +| 29 = @stmt_range_based_for // C++11 +// ... 30 @stmt_at_autoreleasepool_block deprecated +// ... 31 @stmt_objc_for_in deprecated +// ... 32 @stmt_at_synchronized deprecated +| 33 = @stmt_handler +// ... 34 @stmt_finally_end deprecated +| 35 = @stmt_constexpr_if +| 37 = @stmt_co_return +| 38 = @stmt_consteval_if +| 39 = @stmt_not_consteval_if +| 40 = @stmt_leave +; + +type_vla( + int type_id: @type ref, + int decl: @stmt_vla_decl ref +); + +variable_vla( + int var: @variable ref, + int decl: @stmt_vla_decl ref +); + +type_is_vla(unique int type_id: @derivedtype ref) + +if_initialization( + unique int if_stmt: @stmt_if ref, + int init_id: @stmt ref +); + +if_then( + unique int if_stmt: @stmt_if ref, + int then_id: @stmt ref +); + +if_else( + unique int if_stmt: @stmt_if ref, + int else_id: @stmt ref +); + +constexpr_if_initialization( + unique int constexpr_if_stmt: @stmt_constexpr_if ref, + int init_id: @stmt ref +); + +constexpr_if_then( + unique int constexpr_if_stmt: @stmt_constexpr_if ref, + int then_id: @stmt ref +); + +constexpr_if_else( + unique int constexpr_if_stmt: @stmt_constexpr_if ref, + int else_id: @stmt ref +); + +@stmt_consteval_or_not_consteval_if = @stmt_consteval_if | @stmt_not_consteval_if; + +consteval_if_then( + unique int constexpr_if_stmt: @stmt_consteval_or_not_consteval_if ref, + int then_id: @stmt ref +); + +consteval_if_else( + unique int constexpr_if_stmt: @stmt_consteval_or_not_consteval_if ref, + int else_id: @stmt ref +); + +while_body( + unique int while_stmt: @stmt_while ref, + int body_id: @stmt ref +); + +do_body( + unique int do_stmt: @stmt_end_test_while ref, + int body_id: @stmt ref +); + +switch_initialization( + unique int switch_stmt: @stmt_switch ref, + int init_id: @stmt ref +); + +#keyset[switch_stmt, index] +switch_case( + int switch_stmt: @stmt_switch ref, + int index: int ref, + int case_id: @stmt_switch_case ref +); + +switch_body( + unique int switch_stmt: @stmt_switch ref, + int body_id: @stmt ref +); + +@stmt_for_or_range_based_for = @stmt_for + | @stmt_range_based_for; + +for_initialization( + unique int for_stmt: @stmt_for_or_range_based_for ref, + int init_id: @stmt ref +); + +for_condition( + unique int for_stmt: @stmt_for ref, + int condition_id: @expr ref +); + +for_update( + unique int for_stmt: @stmt_for ref, + int update_id: @expr ref +); + +for_body( + unique int for_stmt: @stmt_for ref, + int body_id: @stmt ref +); + +@stmtparent = @stmt | @expr_stmt ; +stmtparents( + unique int id: @stmt ref, + int index: int ref, + int parent: @stmtparent ref +); + +ishandler(unique int block: @stmt_block ref); + +@cfgnode = @stmt | @expr | @function | @initialiser ; + +stmt_decl_bind( + int stmt: @stmt_decl ref, + int num: int ref, + int decl: @declaration ref +); + +stmt_decl_entry_bind( + int stmt: @stmt_decl ref, + int num: int ref, + int decl_entry: @element ref +); + +@parameterized_element = @function | @stmt_block | @requires_expr; + +blockscope( + unique int block: @stmt_block ref, + int enclosing: @parameterized_element ref +); + +@jump = @stmt_goto | @stmt_break | @stmt_continue | @stmt_leave; + +@jumporlabel = @jump | @stmt_label | @literal; + +jumpinfo( + unique int id: @jumporlabel ref, + string str: string ref, + int target: @stmt ref +); + +preprocdirects( + unique int id: @preprocdirect, + int kind: int ref, + int location: @location_default ref +); +case @preprocdirect.kind of + 0 = @ppd_if +| 1 = @ppd_ifdef +| 2 = @ppd_ifndef +| 3 = @ppd_elif +| 4 = @ppd_else +| 5 = @ppd_endif +| 6 = @ppd_plain_include +| 7 = @ppd_define +| 8 = @ppd_undef +| 9 = @ppd_line +| 10 = @ppd_error +| 11 = @ppd_pragma +| 12 = @ppd_objc_import +| 13 = @ppd_include_next +| 14 = @ppd_ms_import +| 15 = @ppd_elifdef +| 16 = @ppd_elifndef +| 17 = @ppd_embed +| 18 = @ppd_warning +; + +@ppd_include = @ppd_plain_include | @ppd_objc_import | @ppd_include_next | @ppd_ms_import; + +@ppd_branch = @ppd_if | @ppd_ifdef | @ppd_ifndef | @ppd_elif | @ppd_elifdef | @ppd_elifndef; + +preprocpair( + int begin : @ppd_branch ref, + int elseelifend : @preprocdirect ref +); + +preproctrue(int branch : @ppd_branch ref); +preprocfalse(int branch : @ppd_branch ref); + +preproctext( + unique int id: @preprocdirect ref, + string head: string ref, + string body: string ref +); + +includes( + unique int id: @ppd_include ref, + int included: @file ref +); + +embeds( + unique int id: @ppd_embed ref, + int included: @file ref +); + +link_targets( + int id: @link_target, + int binary: @file ref +); + +link_parent( + int element : @element ref, + int link_target : @link_target ref +); + +/*- Database metadata -*/ + +/** + * The CLI will automatically emit applicable tuples for this table, + * such as `databaseMetadata("isOverlay", "true")` when building an + * overlay database. + */ +databaseMetadata( + string metadataKey: string ref, + string value: string ref +); + +/*- Overlay support -*/ + +/** + * The CLI will automatically emit tuples for each new/modified/deleted file + * when building an overlay database. + */ +overlayChangedFiles( + string path: string ref +); + +/*- XML Files -*/ + +xmlEncoding( + unique int id: @file ref, + string encoding: string ref +); + +xmlDTDs( + unique int id: @xmldtd, + string root: string ref, + string publicId: string ref, + string systemId: string ref, + int fileid: @file ref +); + +xmlElements( + unique int id: @xmlelement, + string name: string ref, + int parentid: @xmlparent ref, + int idx: int ref, + int fileid: @file ref +); + +xmlAttrs( + unique int id: @xmlattribute, + int elementid: @xmlelement ref, + string name: string ref, + string value: string ref, + int idx: int ref, + int fileid: @file ref +); + +xmlNs( + int id: @xmlnamespace, + string prefixName: string ref, + string URI: string ref, + int fileid: @file ref +); + +xmlHasNs( + int elementId: @xmlnamespaceable ref, + int nsId: @xmlnamespace ref, + int fileid: @file ref +); + +xmlComments( + unique int id: @xmlcomment, + string text: string ref, + int parentid: @xmlparent ref, + int fileid: @file ref +); + +xmlChars( + unique int id: @xmlcharacters, + string text: string ref, + int parentid: @xmlparent ref, + int idx: int ref, + int isCDATA: int ref, + int fileid: @file ref +); + +@xmlparent = @file | @xmlelement; +@xmlnamespaceable = @xmlelement | @xmlattribute; + +xmllocations( + int xmlElement: @xmllocatable ref, + int location: @location_default ref +); + +@xmllocatable = @xmlcharacters | @xmlelement | @xmlcomment | @xmlattribute | @xmldtd | @file | @xmlnamespace; diff --git a/cpp/ql/lib/upgrades/ef8d209a22e27413aaaeff4446f0ecb9fa2c227b/upgrade.properties b/cpp/ql/lib/upgrades/ef8d209a22e27413aaaeff4446f0ecb9fa2c227b/upgrade.properties new file mode 100644 index 00000000000..d3a842d2cbb --- /dev/null +++ b/cpp/ql/lib/upgrades/ef8d209a22e27413aaaeff4446f0ecb9fa2c227b/upgrade.properties @@ -0,0 +1,2 @@ +description: Fix NameQualifier inconsistency +compatibility: full From 4c411bbcb5de03da4d852d742aa1da6777b095c8 Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Wed, 10 Jun 2026 07:07:49 +0200 Subject: [PATCH 10/23] Convert hand-rolled inline expectations test --- .../go/frameworks/Twirp/RequestForgery.qlref | 4 +- .../semmle/go/frameworks/Twirp/client/main.go | 2 +- .../frameworks/Twirp/rpc/notes/service.pb.go | 10 +- .../Twirp/rpc/notes/service.twirp.go | 36 +-- .../semmle/go/frameworks/Twirp/server/main.go | 10 +- .../semmle/go/frameworks/Twirp/tests.expected | 32 +-- .../semmle/go/frameworks/Twirp/tests.ql | 229 +++++------------- 7 files changed, 95 insertions(+), 228 deletions(-) diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Twirp/RequestForgery.qlref b/go/ql/test/library-tests/semmle/go/frameworks/Twirp/RequestForgery.qlref index 061679da228..760862973f1 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Twirp/RequestForgery.qlref +++ b/go/ql/test/library-tests/semmle/go/frameworks/Twirp/RequestForgery.qlref @@ -1,2 +1,4 @@ query: Security/CWE-918/RequestForgery.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Twirp/client/main.go b/go/ql/test/library-tests/semmle/go/frameworks/Twirp/client/main.go index 76abd1a0a9c..e5b4cd2351d 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Twirp/client/main.go +++ b/go/ql/test/library-tests/semmle/go/frameworks/Twirp/client/main.go @@ -9,7 +9,7 @@ import ( ) func main() { - client := notes.NewNotesServiceProtobufClient("http://localhost:8000", &http.Client{}) // test: ssrfSink + client := notes.NewNotesServiceProtobufClient("http://localhost:8000", &http.Client{}) // $ ssrfSink ctx := context.Background() diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Twirp/rpc/notes/service.pb.go b/go/ql/test/library-tests/semmle/go/frameworks/Twirp/rpc/notes/service.pb.go index f0c3e4910d9..e91168f43a9 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Twirp/rpc/notes/service.pb.go +++ b/go/ql/test/library-tests/semmle/go/frameworks/Twirp/rpc/notes/service.pb.go @@ -20,7 +20,7 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type Note struct { // test: message +type Note struct { // $ message state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -83,7 +83,7 @@ func (x *Note) GetCreatedAt() int64 { return 0 } -type CreateNoteParams struct { // test: message +type CreateNoteParams struct { // $ message state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -130,7 +130,7 @@ func (x *CreateNoteParams) GetText() string { return "" } -type GetAllNotesParams struct { // test: message +type GetAllNotesParams struct { // $ message state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -168,7 +168,7 @@ func (*GetAllNotesParams) Descriptor() ([]byte, []int) { return file_rpc_notes_service_proto_rawDescGZIP(), []int{2} } -type GetAllNotesResult struct { // test: message +type GetAllNotesResult struct { // $ message state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -340,7 +340,7 @@ func file_rpc_notes_service_proto_init() { } } } - type x struct{} + type x struct{} // $ SPURIOUS: message // not message out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Twirp/rpc/notes/service.twirp.go b/go/ql/test/library-tests/semmle/go/frameworks/Twirp/rpc/notes/service.twirp.go index 19bcc56f261..6b34dcf08ea 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Twirp/rpc/notes/service.twirp.go +++ b/go/ql/test/library-tests/semmle/go/frameworks/Twirp/rpc/notes/service.twirp.go @@ -31,7 +31,7 @@ const _ = twirp.TwirpPackageMinVersion_8_1_0 // NotesService Interface // ====================== -type NotesService interface { // test: serviceInterface +type NotesService interface { // $ serviceInterface CreateNote(context.Context, *CreateNoteParams) (*Note, error) GetAllNotes(context.Context, *GetAllNotesParams) (*GetAllNotesResult, error) @@ -41,7 +41,7 @@ type NotesService interface { // test: serviceInterface // NotesService Protobuf Client // ============================ -type notesServiceProtobufClient struct { // test: serviceClient +type notesServiceProtobufClient struct { // $ serviceClient client HTTPClient urls [2]string interceptor twirp.Interceptor @@ -50,7 +50,7 @@ type notesServiceProtobufClient struct { // test: serviceClient // NewNotesServiceProtobufClient creates a Protobuf client that implements the NotesService interface. // It communicates using Protobuf and can be configured with a custom HTTPClient. -func NewNotesServiceProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) NotesService { // test: clientConstructor +func NewNotesServiceProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) NotesService { // $ clientConstructor if c, ok := client.(*http.Client); ok { client = withoutRedirects(c) } @@ -84,7 +84,7 @@ func NewNotesServiceProtobufClient(baseURL string, client HTTPClient, opts ...tw } } -func (c *notesServiceProtobufClient) CreateNote(ctx context.Context, in *CreateNoteParams) (*Note, error) { // test: !handler +func (c *notesServiceProtobufClient) CreateNote(ctx context.Context, in *CreateNoteParams) (*Note, error) { // not handler ctx = ctxsetters.WithPackageName(ctx, "gotwirprpcexample.rpc.notes") ctx = ctxsetters.WithServiceName(ctx, "NotesService") ctx = ctxsetters.WithMethodName(ctx, "CreateNote") @@ -113,7 +113,7 @@ func (c *notesServiceProtobufClient) CreateNote(ctx context.Context, in *CreateN return caller(ctx, in) } -func (c *notesServiceProtobufClient) callCreateNote(ctx context.Context, in *CreateNoteParams) (*Note, error) { // test: !handler +func (c *notesServiceProtobufClient) callCreateNote(ctx context.Context, in *CreateNoteParams) (*Note, error) { // not handler out := new(Note) ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out) if err != nil { @@ -130,7 +130,7 @@ func (c *notesServiceProtobufClient) callCreateNote(ctx context.Context, in *Cre return out, nil } -func (c *notesServiceProtobufClient) GetAllNotes(ctx context.Context, in *GetAllNotesParams) (*GetAllNotesResult, error) { // test: !handler +func (c *notesServiceProtobufClient) GetAllNotes(ctx context.Context, in *GetAllNotesParams) (*GetAllNotesResult, error) { // not handler ctx = ctxsetters.WithPackageName(ctx, "gotwirprpcexample.rpc.notes") ctx = ctxsetters.WithServiceName(ctx, "NotesService") ctx = ctxsetters.WithMethodName(ctx, "GetAllNotes") @@ -159,7 +159,7 @@ func (c *notesServiceProtobufClient) GetAllNotes(ctx context.Context, in *GetAll return caller(ctx, in) } -func (c *notesServiceProtobufClient) callGetAllNotes(ctx context.Context, in *GetAllNotesParams) (*GetAllNotesResult, error) { // test: !handler +func (c *notesServiceProtobufClient) callGetAllNotes(ctx context.Context, in *GetAllNotesParams) (*GetAllNotesResult, error) { // not handler out := new(GetAllNotesResult) ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[1], in, out) if err != nil { @@ -180,7 +180,7 @@ func (c *notesServiceProtobufClient) callGetAllNotes(ctx context.Context, in *Ge // NotesService JSON Client // ======================== -type notesServiceJSONClient struct { // test: serviceClient +type notesServiceJSONClient struct { // $ serviceClient client HTTPClient urls [2]string interceptor twirp.Interceptor @@ -189,7 +189,7 @@ type notesServiceJSONClient struct { // test: serviceClient // NewNotesServiceJSONClient creates a JSON client that implements the NotesService interface. // It communicates using JSON and can be configured with a custom HTTPClient. -func NewNotesServiceJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) NotesService { // test: clientConstructor +func NewNotesServiceJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) NotesService { // $ clientConstructor if c, ok := client.(*http.Client); ok { client = withoutRedirects(c) } @@ -223,7 +223,7 @@ func NewNotesServiceJSONClient(baseURL string, client HTTPClient, opts ...twirp. } } -func (c *notesServiceJSONClient) CreateNote(ctx context.Context, in *CreateNoteParams) (*Note, error) { // test: !handler +func (c *notesServiceJSONClient) CreateNote(ctx context.Context, in *CreateNoteParams) (*Note, error) { // not handler ctx = ctxsetters.WithPackageName(ctx, "gotwirprpcexample.rpc.notes") ctx = ctxsetters.WithServiceName(ctx, "NotesService") ctx = ctxsetters.WithMethodName(ctx, "CreateNote") @@ -252,7 +252,7 @@ func (c *notesServiceJSONClient) CreateNote(ctx context.Context, in *CreateNoteP return caller(ctx, in) } -func (c *notesServiceJSONClient) callCreateNote(ctx context.Context, in *CreateNoteParams) (*Note, error) { // test: !handler +func (c *notesServiceJSONClient) callCreateNote(ctx context.Context, in *CreateNoteParams) (*Note, error) { // not handler out := new(Note) ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out) if err != nil { @@ -269,7 +269,7 @@ func (c *notesServiceJSONClient) callCreateNote(ctx context.Context, in *CreateN return out, nil } -func (c *notesServiceJSONClient) GetAllNotes(ctx context.Context, in *GetAllNotesParams) (*GetAllNotesResult, error) { // test: !handler +func (c *notesServiceJSONClient) GetAllNotes(ctx context.Context, in *GetAllNotesParams) (*GetAllNotesResult, error) { // not handler ctx = ctxsetters.WithPackageName(ctx, "gotwirprpcexample.rpc.notes") ctx = ctxsetters.WithServiceName(ctx, "NotesService") ctx = ctxsetters.WithMethodName(ctx, "GetAllNotes") @@ -298,7 +298,7 @@ func (c *notesServiceJSONClient) GetAllNotes(ctx context.Context, in *GetAllNote return caller(ctx, in) } -func (c *notesServiceJSONClient) callGetAllNotes(ctx context.Context, in *GetAllNotesParams) (*GetAllNotesResult, error) { // test: !handler +func (c *notesServiceJSONClient) callGetAllNotes(ctx context.Context, in *GetAllNotesParams) (*GetAllNotesResult, error) { // not handler out := new(GetAllNotesResult) ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[1], in, out) if err != nil { @@ -319,7 +319,7 @@ func (c *notesServiceJSONClient) callGetAllNotes(ctx context.Context, in *GetAll // NotesService Server Handler // =========================== -type notesServiceServer struct { // test: serviceServer +type notesServiceServer struct { // $ serviceServer NotesService interceptor twirp.Interceptor hooks *twirp.ServerHooks @@ -331,7 +331,7 @@ type notesServiceServer struct { // test: serviceServer // NewNotesServiceServer builds a TwirpServer that can be used as an http.Handler to handle // HTTP requests that are routed to the right method in the provided svc implementation. // The opts are twirp.ServerOption modifiers, for example twirp.WithServerHooks(hooks). -func NewNotesServiceServer(svc NotesService, opts ...interface{}) TwirpServer { // test: serverConstructor +func NewNotesServiceServer(svc NotesService, opts ...interface{}) TwirpServer { // $ serverConstructor serverOpts := newServerOpts(opts) // Using ReadOpt allows backwards and forwards compatibility with new options in the future @@ -535,7 +535,7 @@ func (s *notesServiceServer) serveCreateNoteProtobuf(ctx context.Context, resp h return } - buf, err := io.ReadAll(req.Body) + buf, err := io.ReadAll(req.Body) // $ Source if err != nil { s.handleRequestBodyError(ctx, resp, "failed to read request body", err) return @@ -812,7 +812,7 @@ func (s *notesServiceServer) PathPrefix() string { // automatically disabled if *(net/http).Client is passed to client // constructors. See the withoutRedirects function in this file for more // details. -type HTTPClient interface { +type HTTPClient interface { // $ SPURIOUS: serviceInterface // not serviceInterface Do(req *http.Request) (*http.Response, error) } @@ -820,7 +820,7 @@ type HTTPClient interface { // HTTP handlers with additional methods for accessing metadata about the // service. Those accessors are a low-level API for building reflection tools. // Most people can think of TwirpServers as just http.Handlers. -type TwirpServer interface { +type TwirpServer interface { // $ SPURIOUS: serviceInterface // not serviceInterface http.Handler // ServiceDescriptor returns gzipped bytes describing the .proto file that diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Twirp/server/main.go b/go/ql/test/library-tests/semmle/go/frameworks/Twirp/server/main.go index 203b3af1736..7499e79f827 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Twirp/server/main.go +++ b/go/ql/test/library-tests/semmle/go/frameworks/Twirp/server/main.go @@ -16,7 +16,7 @@ type notesService struct { CurrentId int32 } -func (s *notesService) CreateNote(ctx context.Context, params *notes.CreateNoteParams) (*notes.Note, error) { // test: routeHandler, request +func (s *notesService) CreateNote(ctx context.Context, params *notes.CreateNoteParams) (*notes.Note, error) { // $ Source request handler // route handler if len(params.Text) < 4 { return nil, twirp.InvalidArgument.Error("Text should be min 4 characters.") } @@ -27,8 +27,8 @@ func (s *notesService) CreateNote(ctx context.Context, params *notes.CreateNoteP CreatedAt: time.Now().UnixMilli(), } - notes.NewNotesServiceProtobufClient(params.Text, &http.Client{}) // test: ssrfSink, ssrf - notes.NewNotesServiceProtobufClient(strconv.FormatInt(int64(s.CurrentId), 10), &http.Client{}) // test: ssrfSink, !ssrf + notes.NewNotesServiceProtobufClient(params.Text, &http.Client{}) // $ Alert ssrfSink ssrf + notes.NewNotesServiceProtobufClient(strconv.FormatInt(int64(s.CurrentId), 10), &http.Client{}) // $ ssrfSink // not ssrf s.Notes = append(s.Notes, note) @@ -37,7 +37,7 @@ func (s *notesService) CreateNote(ctx context.Context, params *notes.CreateNoteP return ¬e, nil } -func (s *notesService) GetAllNotes(ctx context.Context, params *notes.GetAllNotesParams) (*notes.GetAllNotesResult, error) { // test: routeHandler, request +func (s *notesService) GetAllNotes(ctx context.Context, params *notes.GetAllNotesParams) (*notes.GetAllNotesResult, error) { // $ request handler // route handler allNotes := make([]*notes.Note, 0) fmt.Println(params) @@ -57,7 +57,7 @@ func main() { mux := http.NewServeMux() mux.Handle(notesServer.PathPrefix(), notesServer) - err := http.ListenAndServe(":8000", notesServer) // test: !ssrfSink + err := http.ListenAndServe(":8000", notesServer) // not ssrfSink if err != nil { panic(err) } diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Twirp/tests.expected b/go/ql/test/library-tests/semmle/go/frameworks/Twirp/tests.expected index 4b0a2d917e7..42831abaf15 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Twirp/tests.expected +++ b/go/ql/test/library-tests/semmle/go/frameworks/Twirp/tests.expected @@ -1,32 +1,2 @@ invalidModelRow -passingPositiveTests -| PASSED | clientConstructor | rpc/notes/service.twirp.go:53:114:53:139 | comment | -| PASSED | clientConstructor | rpc/notes/service.twirp.go:192:110:192:135 | comment | -| PASSED | message | rpc/notes/service.pb.go:23:20:23:35 | comment | -| PASSED | message | rpc/notes/service.pb.go:86:32:86:47 | comment | -| PASSED | message | rpc/notes/service.pb.go:133:33:133:48 | comment | -| PASSED | message | rpc/notes/service.pb.go:171:33:171:48 | comment | -| PASSED | request | server/main.go:19:111:19:140 | comment | -| PASSED | request | server/main.go:40:126:40:155 | comment | -| PASSED | serverConstructor | rpc/notes/service.twirp.go:334:81:334:106 | comment | -| PASSED | serviceClient | rpc/notes/service.twirp.go:44:42:44:63 | comment | -| PASSED | serviceClient | rpc/notes/service.twirp.go:183:38:183:59 | comment | -| PASSED | serviceInterface | rpc/notes/service.twirp.go:34:31:34:55 | comment | -| PASSED | serviceServer | rpc/notes/service.twirp.go:322:34:322:55 | comment | -| PASSED | ssrf | server/main.go:30:97:30:119 | comment | -| PASSED | ssrfSink | client/main.go:12:89:12:105 | comment | -| PASSED | ssrfSink | server/main.go:30:97:30:119 | comment | -| PASSED | ssrfSink | server/main.go:31:97:31:120 | comment | -failingPositiveTests -passingNegativeTests -| PASSED | !handler | rpc/notes/service.twirp.go:87:109:87:125 | comment | -| PASSED | !handler | rpc/notes/service.twirp.go:116:113:116:129 | comment | -| PASSED | !handler | rpc/notes/service.twirp.go:133:124:133:140 | comment | -| PASSED | !handler | rpc/notes/service.twirp.go:162:128:162:144 | comment | -| PASSED | !handler | rpc/notes/service.twirp.go:226:105:226:121 | comment | -| PASSED | !handler | rpc/notes/service.twirp.go:255:109:255:125 | comment | -| PASSED | !handler | rpc/notes/service.twirp.go:272:120:272:136 | comment | -| PASSED | !handler | rpc/notes/service.twirp.go:301:124:301:140 | comment | -| PASSED | !ssrf | server/main.go:31:97:31:120 | comment | -| PASSED | !ssrfSink | server/main.go:60:51:60:68 | comment | -failingNegativeTests +testFailures diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Twirp/tests.ql b/go/ql/test/library-tests/semmle/go/frameworks/Twirp/tests.ql index 5866b6ff3ed..2b445ce4d86 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Twirp/tests.ql +++ b/go/ql/test/library-tests/semmle/go/frameworks/Twirp/tests.ql @@ -2,181 +2,76 @@ import go import semmle.go.dataflow.ExternalFlow import ModelValidation import semmle.go.security.RequestForgery +import utils.test.InlineExpectationsTest -class InlineTest extends LineComment { - string tests; - - InlineTest() { tests = this.getText().regexpCapture("\\s*test:(.*)", 1) } - - string getPositiveTest() { - result = tests.trim().splitAt(",").trim() and not result.matches("!%") +module TwirpTest implements TestSig { + string getARelevantTag() { + result = + [ + "handler", "request", "ssrfSink", "message", "serviceInterface", "serviceClient", + "serviceServer", "clientConstructor", "serverConstructor", "ssrf" + ] } - string getNegativeTest() { result = tests.trim().splitAt(",").trim() and result.matches("!%") } - - predicate hasPositiveTest(string test) { test = this.getPositiveTest() } - - predicate hasNegativeTest(string test) { test = this.getNegativeTest() } - - predicate inNode(DataFlow::Node n) { - this.getLocation().getFile() = n.getFile() and - this.getLocation().getStartLine() = n.getStartLine() + additional predicate hasEntityResult(Location location, string element, Entity entity) { + location = entity.getDeclaration().getLocation() and + element = entity.toString() } - predicate inEntity(Entity e) { - this.getLocation().getFile() = e.getDeclaration().getFile() and - this.getLocation().getStartLine() = e.getDeclaration().getLocation().getStartLine() + additional predicate hasTypeResult(Location location, string element, Type goType) { + exists(TypeEntity typeEntity | + typeEntity.getType() = goType and + location = typeEntity.getDeclaration().getLocation() and + element = goType.toString() + ) } - predicate inType(Type t) { - exists(TypeEntity te | - te.getType() = t and - this.getLocation().getFile() = te.getDeclaration().getFile() and - this.getLocation().getStartLine() = te.getDeclaration().getLocation().getStartLine() + predicate hasActualResult(Location location, string element, string tag, string value) { + value = "" and + ( + tag = "handler" and + exists(Twirp::ServiceHandler handler | hasEntityResult(location, element, handler)) + or + tag = "request" and + exists(Twirp::Request request | + location = request.getLocation() and + element = request.toString() + ) + or + tag = "ssrfSink" and + exists(RequestForgery::Sink sink | + location = sink.getLocation() and + element = sink.toString() + ) + or + tag = "message" and + exists(Twirp::ProtobufMessageType message | hasTypeResult(location, element, message)) + or + tag = "serviceInterface" and + exists(Twirp::ServiceInterfaceType serviceInterface | + hasTypeResult(location, element, serviceInterface.getDefinedType()) + ) + or + tag = "serviceClient" and + exists(Twirp::ServiceClientType client | hasTypeResult(location, element, client)) + or + tag = "serviceServer" and + exists(Twirp::ServiceServerType server | hasTypeResult(location, element, server)) + or + tag = "clientConstructor" and + exists(Twirp::ClientConstructor constructor | hasEntityResult(location, element, constructor)) + or + tag = "serverConstructor" and + exists(Twirp::ServerConstructor constructor | hasEntityResult(location, element, constructor)) + or + tag = "ssrf" and + exists(DataFlow::Node sink | + RequestForgery::Flow::flowTo(sink) and + location = sink.getLocation() and + element = sink.toString() + ) ) } } -query predicate passingPositiveTests(string res, string expectation, InlineTest t) { - res = "PASSED" and - t.hasPositiveTest(expectation) and - ( - expectation = "handler" and - exists(Twirp::ServiceHandler n | t.inEntity(n)) - or - expectation = "request" and - exists(Twirp::Request n | t.inNode(n)) - or - expectation = "ssrfSink" and - exists(RequestForgery::Sink n | t.inNode(n)) - or - expectation = "message" and - exists(Twirp::ProtobufMessageType n | t.inType(n)) - or - expectation = "serviceInterface" and - exists(Twirp::ServiceInterfaceType n | t.inType(n.getDefinedType())) - or - expectation = "serviceClient" and - exists(Twirp::ServiceClientType n | t.inType(n)) - or - expectation = "serviceServer" and - exists(Twirp::ServiceServerType n | t.inType(n)) - or - expectation = "clientConstructor" and - exists(Twirp::ClientConstructor n | t.inEntity(n)) - or - expectation = "serverConstructor" and - exists(Twirp::ServerConstructor n | t.inEntity(n)) - or - expectation = "ssrf" and - exists(DataFlow::Node sink | RequestForgery::Flow::flowTo(sink) and t.inNode(sink)) - ) -} - -query predicate failingPositiveTests(string res, string expectation, InlineTest t) { - res = "FAILED" and - t.hasPositiveTest(expectation) and - ( - expectation = "handler" and - not exists(Twirp::ServiceHandler n | t.inEntity(n)) - or - expectation = "request" and - not exists(Twirp::Request n | t.inNode(n)) - or - expectation = "ssrfSink" and - not exists(RequestForgery::Sink n | t.inNode(n)) - or - expectation = "message" and - not exists(Twirp::ProtobufMessageType n | t.inType(n)) - or - expectation = "serviceInterface" and - not exists(Twirp::ServiceInterfaceType n | t.inType(n.getDefinedType())) - or - expectation = "serviceClient" and - not exists(Twirp::ServiceClientType n | t.inType(n)) - or - expectation = "serviceServer" and - not exists(Twirp::ServiceServerType n | t.inType(n)) - or - expectation = "clientConstructor" and - not exists(Twirp::ClientConstructor n | t.inEntity(n)) - or - expectation = "serverConstructor" and - not exists(Twirp::ServerConstructor n | t.inEntity(n)) - or - expectation = "ssrf" and - not exists(DataFlow::Node sink | RequestForgery::Flow::flowTo(sink) and t.inNode(sink)) - ) -} - -query predicate passingNegativeTests(string res, string expectation, InlineTest t) { - res = "PASSED" and - t.hasNegativeTest(expectation) and - ( - expectation = "!handler" and - not exists(Twirp::ServiceHandler n | t.inEntity(n)) - or - expectation = "!request" and - not exists(Twirp::Request n | t.inNode(n)) - or - expectation = "!ssrfSink" and - not exists(RequestForgery::Sink n | t.inNode(n)) - or - expectation = "!message" and - not exists(Twirp::ProtobufMessageType n | t.inType(n)) - or - expectation = "!serviceInterface" and - not exists(Twirp::ServiceInterfaceType n | t.inType(n)) - or - expectation = "!serviceClient" and - not exists(Twirp::ServiceClientType n | t.inType(n)) - or - expectation = "!serviceServer" and - not exists(Twirp::ServiceServerType n | t.inType(n)) - or - expectation = "!clientConstructor" and - not exists(Twirp::ClientConstructor n | t.inEntity(n)) - or - expectation = "!serverConstructor" and - not exists(Twirp::ServerConstructor n | t.inEntity(n)) - or - expectation = "!ssrf" and - not exists(DataFlow::Node sink | RequestForgery::Flow::flowTo(sink) and t.inNode(sink)) - ) -} - -query predicate failingNegativeTests(string res, string expectation, InlineTest t) { - res = "FAILED" and - t.hasNegativeTest(expectation) and - ( - expectation = "!handler" and - exists(Twirp::ServiceHandler n | t.inEntity(n)) - or - expectation = "!request" and - exists(Twirp::Request n | t.inNode(n)) - or - expectation = "!ssrfSink" and - exists(RequestForgery::Sink n | t.inNode(n)) - or - expectation = "!message" and - exists(Twirp::ProtobufMessageType n | t.inType(n)) - or - expectation = "!serviceInterface" and - exists(Twirp::ServiceInterfaceType n | t.inType(n)) - or - expectation = "!serviceClient" and - exists(Twirp::ServiceClientType n | t.inType(n)) - or - expectation = "!serviceServer" and - exists(Twirp::ServiceServerType n | t.inType(n)) - or - expectation = "!clientConstructor" and - exists(Twirp::ClientConstructor n | t.inEntity(n)) - or - expectation = "!serverConstructor" and - exists(Twirp::ServerConstructor n | t.inEntity(n)) - or - expectation = "!ssrf" and - exists(DataFlow::Node sink | RequestForgery::Flow::flowTo(sink) and t.inNode(sink)) - ) -} +import MakeTest From 6a8e20a0c87d3e8cc027db59db5afd985e48d74a Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Wed, 10 Jun 2026 07:12:08 +0200 Subject: [PATCH 11/23] Fix pre-existing whitespace issues in go test files --- .../WhitespaceContradictsPrecedence/main.go | 2 +- .../Security/CWE-089/StringBreak.expected | 40 +++++++++---------- .../Security/CWE-089/StringBreak.go | 1 + .../Security/CWE-089/StringBreakMismatched.go | 3 +- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/go/ql/test/query-tests/InconsistentCode/WhitespaceContradictsPrecedence/main.go b/go/ql/test/query-tests/InconsistentCode/WhitespaceContradictsPrecedence/main.go index faf23f9f1cf..dc1bf222aec 100644 --- a/go/ql/test/query-tests/InconsistentCode/WhitespaceContradictsPrecedence/main.go +++ b/go/ql/test/query-tests/InconsistentCode/WhitespaceContradictsPrecedence/main.go @@ -21,7 +21,7 @@ func ok3(x int) int { func ok4(x int, y int, z int) int { return x + y + z; } - + func ok5(x int, y int, z int) int { return x + y+z; } diff --git a/go/ql/test/query-tests/Security/CWE-089/StringBreak.expected b/go/ql/test/query-tests/Security/CWE-089/StringBreak.expected index 5deab249337..63caa73d596 100644 --- a/go/ql/test/query-tests/Security/CWE-089/StringBreak.expected +++ b/go/ql/test/query-tests/Security/CWE-089/StringBreak.expected @@ -1,26 +1,26 @@ #select -| StringBreak.go:14:47:14:57 | versionJSON | StringBreak.go:10:2:10:40 | ... := ...[0] | StringBreak.go:14:47:14:57 | versionJSON | If this $@ contains a single quote, it could break out of the enclosing quotes. | StringBreak.go:10:2:10:40 | ... := ...[0] | JSON value | -| StringBreakMismatched.go:17:26:17:32 | escaped | StringBreakMismatched.go:12:2:12:40 | ... := ...[0] | StringBreakMismatched.go:17:26:17:32 | escaped | If this $@ contains a single quote, it could break out of the enclosing quotes. | StringBreakMismatched.go:12:2:12:40 | ... := ...[0] | JSON value | -| StringBreakMismatched.go:29:27:29:33 | escaped | StringBreakMismatched.go:24:2:24:40 | ... := ...[0] | StringBreakMismatched.go:29:27:29:33 | escaped | If this $@ contains a double quote, it could break out of the enclosing quotes. | StringBreakMismatched.go:24:2:24:40 | ... := ...[0] | JSON value | +| StringBreak.go:15:47:15:57 | versionJSON | StringBreak.go:11:2:11:40 | ... := ...[0] | StringBreak.go:15:47:15:57 | versionJSON | If this $@ contains a single quote, it could break out of the enclosing quotes. | StringBreak.go:11:2:11:40 | ... := ...[0] | JSON value | +| StringBreakMismatched.go:18:26:18:32 | escaped | StringBreakMismatched.go:13:2:13:40 | ... := ...[0] | StringBreakMismatched.go:18:26:18:32 | escaped | If this $@ contains a single quote, it could break out of the enclosing quotes. | StringBreakMismatched.go:13:2:13:40 | ... := ...[0] | JSON value | +| StringBreakMismatched.go:30:27:30:33 | escaped | StringBreakMismatched.go:25:2:25:40 | ... := ...[0] | StringBreakMismatched.go:30:27:30:33 | escaped | If this $@ contains a double quote, it could break out of the enclosing quotes. | StringBreakMismatched.go:25:2:25:40 | ... := ...[0] | JSON value | edges -| StringBreak.go:10:2:10:40 | ... := ...[0] | StringBreak.go:14:47:14:57 | versionJSON | provenance | | -| StringBreakMismatched.go:12:2:12:40 | ... := ...[0] | StringBreakMismatched.go:13:29:13:47 | type conversion | provenance | | -| StringBreakMismatched.go:13:13:13:62 | call to Replace | StringBreakMismatched.go:17:26:17:32 | escaped | provenance | | -| StringBreakMismatched.go:13:29:13:47 | type conversion | StringBreakMismatched.go:13:13:13:62 | call to Replace | provenance | MaD:1 | -| StringBreakMismatched.go:24:2:24:40 | ... := ...[0] | StringBreakMismatched.go:25:29:25:47 | type conversion | provenance | | -| StringBreakMismatched.go:25:13:25:61 | call to Replace | StringBreakMismatched.go:29:27:29:33 | escaped | provenance | | -| StringBreakMismatched.go:25:29:25:47 | type conversion | StringBreakMismatched.go:25:13:25:61 | call to Replace | provenance | MaD:1 | +| StringBreak.go:11:2:11:40 | ... := ...[0] | StringBreak.go:15:47:15:57 | versionJSON | provenance | | +| StringBreakMismatched.go:13:2:13:40 | ... := ...[0] | StringBreakMismatched.go:14:29:14:47 | type conversion | provenance | | +| StringBreakMismatched.go:14:13:14:62 | call to Replace | StringBreakMismatched.go:18:26:18:32 | escaped | provenance | | +| StringBreakMismatched.go:14:29:14:47 | type conversion | StringBreakMismatched.go:14:13:14:62 | call to Replace | provenance | MaD:1 | +| StringBreakMismatched.go:25:2:25:40 | ... := ...[0] | StringBreakMismatched.go:26:29:26:47 | type conversion | provenance | | +| StringBreakMismatched.go:26:13:26:61 | call to Replace | StringBreakMismatched.go:30:27:30:33 | escaped | provenance | | +| StringBreakMismatched.go:26:29:26:47 | type conversion | StringBreakMismatched.go:26:13:26:61 | call to Replace | provenance | MaD:1 | models | 1 | Summary: strings; ; false; Replace; ; ; Argument[0]; ReturnValue; taint; manual | nodes -| StringBreak.go:10:2:10:40 | ... := ...[0] | semmle.label | ... := ...[0] | -| StringBreak.go:14:47:14:57 | versionJSON | semmle.label | versionJSON | -| StringBreakMismatched.go:12:2:12:40 | ... := ...[0] | semmle.label | ... := ...[0] | -| StringBreakMismatched.go:13:13:13:62 | call to Replace | semmle.label | call to Replace | -| StringBreakMismatched.go:13:29:13:47 | type conversion | semmle.label | type conversion | -| StringBreakMismatched.go:17:26:17:32 | escaped | semmle.label | escaped | -| StringBreakMismatched.go:24:2:24:40 | ... := ...[0] | semmle.label | ... := ...[0] | -| StringBreakMismatched.go:25:13:25:61 | call to Replace | semmle.label | call to Replace | -| StringBreakMismatched.go:25:29:25:47 | type conversion | semmle.label | type conversion | -| StringBreakMismatched.go:29:27:29:33 | escaped | semmle.label | escaped | +| StringBreak.go:11:2:11:40 | ... := ...[0] | semmle.label | ... := ...[0] | +| StringBreak.go:15:47:15:57 | versionJSON | semmle.label | versionJSON | +| StringBreakMismatched.go:13:2:13:40 | ... := ...[0] | semmle.label | ... := ...[0] | +| StringBreakMismatched.go:14:13:14:62 | call to Replace | semmle.label | call to Replace | +| StringBreakMismatched.go:14:29:14:47 | type conversion | semmle.label | type conversion | +| StringBreakMismatched.go:18:26:18:32 | escaped | semmle.label | escaped | +| StringBreakMismatched.go:25:2:25:40 | ... := ...[0] | semmle.label | ... := ...[0] | +| StringBreakMismatched.go:26:13:26:61 | call to Replace | semmle.label | call to Replace | +| StringBreakMismatched.go:26:29:26:47 | type conversion | semmle.label | type conversion | +| StringBreakMismatched.go:30:27:30:33 | escaped | semmle.label | escaped | subpaths diff --git a/go/ql/test/query-tests/Security/CWE-089/StringBreak.go b/go/ql/test/query-tests/Security/CWE-089/StringBreak.go index d5aec9777d4..5667ca35035 100644 --- a/go/ql/test/query-tests/Security/CWE-089/StringBreak.go +++ b/go/ql/test/query-tests/Security/CWE-089/StringBreak.go @@ -3,6 +3,7 @@ package main import ( "encoding/json" "fmt" + sq "github.com/Masterminds/squirrel" ) diff --git a/go/ql/test/query-tests/Security/CWE-089/StringBreakMismatched.go b/go/ql/test/query-tests/Security/CWE-089/StringBreakMismatched.go index ba8ee72d0fa..c838d5f6b7d 100644 --- a/go/ql/test/query-tests/Security/CWE-089/StringBreakMismatched.go +++ b/go/ql/test/query-tests/Security/CWE-089/StringBreakMismatched.go @@ -2,8 +2,9 @@ package main import ( "encoding/json" - sq "github.com/Masterminds/squirrel" "strings" + + sq "github.com/Masterminds/squirrel" ) // Bad because quote characters are removed before concatenation, From b4a9689341383f94ec8979d381e59ec7d460e849 Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Wed, 10 Jun 2026 06:43:10 +0200 Subject: [PATCH 12/23] Convert .qlref test to inline expectations --- .../experimental/CWE-525/WebCacheDeception.ql | 2 +- .../experimental/CWE-090/LDAPInjection.go | 24 +-- .../experimental/CWE-090/LDAPInjection.qlref | 4 +- go/ql/test/experimental/CWE-203/Timing.qlref | 4 +- go/ql/test/experimental/CWE-203/timing.go | 12 +- .../experimental/CWE-285/PamAuthBypass.qlref | 3 +- go/ql/test/experimental/CWE-285/main.go | 2 +- .../experimental/CWE-287/ImproperLdapAuth.go | 8 +- .../CWE-287/ImproperLdapAuth.qlref | 4 +- .../CWE-321-V2/HardCodedKeys.expected | 6 +- .../CWE-321-V2/HardCodedKeys.qlref | 3 +- .../experimental/CWE-321-V2/go-jose.v3.go | 4 +- .../experimental/CWE-321-V2/golang-jwt-v5.go | 4 +- .../test/experimental/CWE-369/DivideByZero.go | 24 +-- .../experimental/CWE-369/DivideByZero.qlref | 4 +- .../CWE-400/DatabaseCallInLoop.expected | 8 +- .../CWE-400/DatabaseCallInLoop.go | 4 +- .../CWE-400/DatabaseCallInLoop.qlref | 3 +- go/ql/test/experimental/CWE-400/test.go | 6 +- .../DecompressionBombs.qlref | 4 +- .../CWE-522-DecompressionBombs/test.go | 104 +++++------ .../CWE-525/WebCacheDeception.qlref | 3 +- .../CWE-525/WebCacheDeceptionBad.go | 2 +- .../CWE-525/WebCacheDeceptionFiber.go | 4 +- .../CWE-525/WebCacheDeceptionGoChi.go | 2 +- .../CWE-525/WebCacheDeceptionHTTPRouter.go | 2 +- go/ql/test/experimental/CWE-74/Dsn.go | 12 +- .../experimental/CWE-74/DsnInjection.qlref | 4 +- .../CWE-74/DsnInjectionLocal.qlref | 4 +- .../CWE-807/SensitiveConditionBypass.qlref | 3 +- .../CWE-807/SensitiveConditionBypassBad.go | 2 +- go/ql/test/experimental/CWE-807/condition.go | 6 +- .../CWE-840/ConditionalBypass.qlref | 3 +- .../CWE-840/ConditionalBypassBad.go | 2 +- go/ql/test/experimental/CWE-840/condition.go | 4 +- .../InconsistentCode/DeferInLoop.go | 2 +- .../InconsistentCode/DeferInLoop.qlref | 3 +- .../InconsistentCode/GORMErrorNotChecked.go | 2 +- .../GORMErrorNotChecked.qlref | 3 +- .../experimental/InconsistentCode/test.go | 10 +- .../Unsafe/WrongUsageOfUnsafe.expected | 24 +-- .../experimental/Unsafe/WrongUsageOfUnsafe.go | 24 +-- .../Unsafe/WrongUsageOfUnsafe.qlref | 3 +- .../go/frameworks/BeegoOrm/SqlInjection.qlref | 4 +- .../go/frameworks/BeegoOrm/StoredXss.qlref | 4 +- .../semmle/go/frameworks/BeegoOrm/test.go | 164 +++++++++--------- .../go/frameworks/Chi/ReflectedXss.qlref | 4 +- .../semmle/go/frameworks/Chi/test.go | 10 +- .../go/frameworks/Echo/OpenRedirect.qlref | 4 +- .../go/frameworks/Echo/ReflectedXss.qlref | 4 +- .../go/frameworks/Echo/TaintedPath.qlref | 4 +- .../semmle/go/frameworks/Echo/test.go | 92 +++++----- .../frameworks/GoMicro/LogInjection.expected | 4 +- .../go/frameworks/GoMicro/LogInjection.qlref | 3 +- .../semmle/go/frameworks/GoMicro/main.go | 4 +- .../CONSISTENCY/DataFlowConsistency.expected | 48 ++--- .../semmle/go/frameworks/Revel/EndToEnd.go | 17 +- .../go/frameworks/Revel/OpenRedirect.expected | 24 +-- .../go/frameworks/Revel/OpenRedirect.qlref | 4 +- .../go/frameworks/Revel/ReflectedXss.expected | 32 ++-- .../go/frameworks/Revel/ReflectedXss.qlref | 4 +- .../semmle/go/frameworks/Revel/Revel.go | 2 +- .../go/frameworks/Revel/TaintedPath.expected | 24 +-- .../go/frameworks/Revel/TaintedPath.qlref | 4 +- .../Revel/examples/booking/app/init.go | 4 +- .../go/frameworks/XNetHtml/ReflectedXss.qlref | 4 +- .../go/frameworks/XNetHtml/SqlInjection.qlref | 4 +- .../semmle/go/frameworks/XNetHtml/test.go | 50 +++--- .../ConstantLengthComparison.go | 2 +- .../ConstantLengthComparison.qlref | 3 +- .../InconsistentLoopOrientation.go | 2 +- .../InconsistentLoopOrientation.qlref | 3 +- .../InconsistentLoopOrientation/main.go | 6 +- .../LengthComparisonOffByOne.go | 4 +- .../LengthComparisonOffByOne.qlref | 3 +- .../LengthComparisonOffByOne/main.go | 8 +- .../MissingErrorCheck/MissingErrorCheck.qlref | 3 +- .../MissingErrorCheck/tests.go | 4 +- .../MistypedExponentiation.go | 2 +- .../MistypedExponentiation.qlref | 3 +- .../MistypedExponentiation/main.go | 10 +- .../WhitespaceContradictsPrecedence.go | 2 +- .../WhitespaceContradictsPrecedence.qlref | 3 +- .../WhitespaceContradictsPrecedence/main.go | 2 +- .../WrappedErrorAlwaysNil.go | 8 +- .../WrappedErrorAlwaysNil.qlref | 3 +- .../CompareIdenticalValues.go | 2 +- .../CompareIdenticalValues.qlref | 3 +- .../CompareIdenticalValues/tst.go | 4 +- .../CompareIdenticalValues/vp.go | 2 +- .../DeadStoreOfField/DeadStoreOfField.go | 2 +- .../DeadStoreOfField/DeadStoreOfField.qlref | 3 +- .../DeadStoreOfLocal/DeadStoreOfLocal.qlref | 3 +- .../RedundantCode/DeadStoreOfLocal/main.go | 2 +- .../DeadStoreOfLocal/testdata.go | 58 +++---- .../DuplicateBranches/DuplicateBranches.go | 2 +- .../DuplicateBranches/DuplicateBranches.qlref | 3 +- .../RedundantCode/DuplicateBranches/main.go | 2 +- .../DuplicateCondition/DuplicateCondition.go | 4 +- .../DuplicateCondition.qlref | 3 +- .../RedundantCode/DuplicateCondition/tst.go | 4 +- .../DuplicateSwitchCase.go | 2 +- .../DuplicateSwitchCase.qlref | 3 +- .../RedundantCode/DuplicateSwitchCase/tst.go | 2 +- .../ExprHasNoEffect/ExprHasNoEffect.go | 2 +- .../ExprHasNoEffect/ExprHasNoEffect.qlref | 3 +- .../RedundantCode/ExprHasNoEffect/main.go | 6 +- .../ImpossibleInterfaceNilCheck.go | 2 +- .../ImpossibleInterfaceNilCheck.qlref | 3 +- .../ImpossibleInterfaceNilCheck/tst.go | 2 +- .../NegativeLengthCheck.go | 2 +- .../NegativeLengthCheck.qlref | 3 +- .../RedundantCode/NegativeLengthCheck/main.go | 10 +- .../RedundantExpr/RedundantExpr.go | 2 +- .../RedundantExpr/RedundantExpr.qlref | 3 +- .../RedundantCode/RedundantExpr/tst.go | 4 +- .../RedundantRecover/RedundantRecover.qlref | 3 +- .../RedundantRecover/RedundantRecover1.go | 2 +- .../RedundantRecover/RedundantRecover2.go | 2 +- .../RedundantCode/RedundantRecover/tst.go | 2 +- .../SelfAssignment/SelfAssignment.go | 2 +- .../SelfAssignment/SelfAssignment.qlref | 3 +- .../RedundantCode/SelfAssignment/tst.go | 2 +- .../ShiftOutOfRange/ShiftOutOfRange.go | 2 +- .../ShiftOutOfRange/ShiftOutOfRange.qlref | 3 +- .../RedundantCode/ShiftOutOfRange/main.go | 6 +- .../UnreachableStatement.go | 2 +- .../UnreachableStatement.qlref | 3 +- .../UnreachableStatement/main.go | 22 +-- .../IncompleteHostnameRegexp.go | 4 +- .../IncompleteHostnameRegexp.qlref | 4 +- .../CWE-020/IncompleteHostnameRegexp/main.go | 14 +- .../IncompleteUrlSchemeCheck.go | 2 +- .../IncompleteUrlSchemeCheck.qlref | 3 +- .../CWE-020/IncompleteUrlSchemeCheck/main.go | 2 +- .../MissingRegexpAnchor.go | 2 +- .../MissingRegexpAnchor.qlref | 3 +- .../CWE-020/MissingRegexpAnchor/main.go | 20 +-- .../SuspiciousCharacterInRegexp.go | 2 +- .../SuspiciousCharacterInRegexp.qlref | 3 +- .../SuspiciousCharacterInRegexp/test.go | 20 +-- .../GorillaMuxDefault/TaintedPath.qlref | 4 +- .../CWE-022/GorillaMuxSkipClean/MuxClean.go | 4 +- .../GorillaMuxSkipClean/TaintedPath.qlref | 4 +- .../Security/CWE-022/TaintedPath.go | 8 +- .../Security/CWE-022/TaintedPath.qlref | 4 +- .../Security/CWE-022/UnsafeUnzipSymlink.go | 8 +- .../Security/CWE-022/UnsafeUnzipSymlink.qlref | 4 +- .../CWE-022/UnsafeUnzipSymlinkGood.go | 4 +- .../query-tests/Security/CWE-022/ZipSlip.go | 4 +- .../Security/CWE-022/ZipSlip.qlref | 4 +- .../query-tests/Security/CWE-022/tarslip.go | 4 +- .../test/query-tests/Security/CWE-022/tst.go | 4 +- .../Security/CWE-078/ArgumentInjection.go | 4 +- .../Security/CWE-078/CommandInjection.go | 4 +- .../Security/CWE-078/CommandInjection.qlref | 4 +- .../Security/CWE-078/CommandInjection2.go | 8 +- .../Security/CWE-078/GitSubcommands.go | 16 +- .../Security/CWE-078/SanitizingDoubleDash.go | 36 ++-- .../Security/CWE-078/StoredCommand.go | 4 +- .../Security/CWE-078/StoredCommand.qlref | 4 +- .../Security/CWE-089/SqlInjection.go | 4 +- .../Security/CWE-089/SqlInjection.qlref | 4 +- .../Security/CWE-089/StringBreak.go | 4 +- .../Security/CWE-089/StringBreak.qlref | 4 +- .../Security/CWE-089/StringBreakMismatched.go | 8 +- .../query-tests/Security/CWE-089/issue48.go | 12 +- .../test/query-tests/Security/CWE-089/main.go | 22 +-- .../query-tests/Security/CWE-089/mongoDB.go | 30 ++-- .../CWE-190/AllocationSizeOverflow.go | 4 +- .../CWE-190/AllocationSizeOverflow.qlref | 4 +- .../test/query-tests/Security/CWE-190/tst.go | 16 +- .../test/query-tests/Security/CWE-190/tst2.go | 8 +- .../test/query-tests/Security/CWE-190/tst3.go | 8 +- .../Security/CWE-209/StackTraceExposure.qlref | 3 +- .../test/query-tests/Security/CWE-209/test.go | 4 +- .../DisabledCertificateCheck.go | 2 +- .../DisabledCertificateCheck.qlref | 3 +- .../CWE-295/DisabledCertificateCheck/main.go | 6 +- .../CWE-322/InsecureHostKeyCallback.expected | 10 +- .../CWE-322/InsecureHostKeyCallback.qlref | 3 +- .../CWE-322/InsecureHostKeyCallbackExample.go | 12 +- .../Security/CWE-326/InsufficientKeySize.go | 22 +-- .../CWE-326/InsufficientKeySize.qlref | 3 +- .../query-tests/Security/CWE-327/UnsafeTLS.go | 94 +++++----- .../Security/CWE-327/UnsafeTLS.qlref | 4 +- .../InsecureRandomness/InsecureRandomness.go | 2 +- .../InsecureRandomness.qlref | 4 +- .../CWE-338/InsecureRandomness/sample.go | 14 +- .../CWE-347/MissingJwtSignatureCheck.qlref | 4 +- .../Security/CWE-347/go-jose.v3.go | 4 +- .../Security/CWE-347/golang-jwt-v5.go | 4 +- .../Security/CWE-352/ConstantOauth2State.go | 16 +- .../CWE-352/ConstantOauth2State.qlref | 3 +- .../BadRedirectCheck/BadRedirectCheck.go | 4 +- .../BadRedirectCheck/BadRedirectCheck.qlref | 4 +- .../Security/CWE-601/BadRedirectCheck/cves.go | 18 +- .../Security/CWE-601/BadRedirectCheck/main.go | 24 +-- .../Security/CWE-643/XPathInjection.go | 4 +- .../Security/CWE-643/XPathInjection.qlref | 4 +- .../test/query-tests/Security/CWE-643/tst.go | 90 +++++----- .../CWE-798/AlertSuppressionExample.go | 2 +- .../Security/CWE-798/HardcodedCredentials.go | 2 +- .../Security/CWE-798/HardcodedKeysBad.go | 2 +- .../test/query-tests/Security/CWE-798/jwt.go | 38 ++-- .../test/query-tests/Security/CWE-798/main.go | 2 +- .../query-tests/Security/CWE-798/sanitizer.go | 2 +- 207 files changed, 1009 insertions(+), 901 deletions(-) diff --git a/go/ql/src/experimental/CWE-525/WebCacheDeception.ql b/go/ql/src/experimental/CWE-525/WebCacheDeception.ql index eb488b0b0d1..04faa7c29e1 100644 --- a/go/ql/src/experimental/CWE-525/WebCacheDeception.ql +++ b/go/ql/src/experimental/CWE-525/WebCacheDeception.ql @@ -1,4 +1,4 @@ -/* +/** * @name Web Cache Deception * @description A caching system has been detected on the application and is vulnerable to web cache deception. By manipulating the URL it is possible to force the application to cache pages that are only accessible by an authenticated user. Once cached, these pages can be accessed by an unauthenticated user. * @kind problem diff --git a/go/ql/test/experimental/CWE-090/LDAPInjection.go b/go/ql/test/experimental/CWE-090/LDAPInjection.go index 87741a08d28..0acae7c0617 100644 --- a/go/ql/test/experimental/CWE-090/LDAPInjection.go +++ b/go/ql/test/experimental/CWE-090/LDAPInjection.go @@ -54,31 +54,31 @@ func main() {} // bad is an example of a bad implementation func (ld *Ldap) bad(req *http.Request) { // ... - untrusted := req.UserAgent() + untrusted := req.UserAgent() // $ Source goldap.NewSearchRequest( - untrusted, // BAD: untrusted dn + untrusted, // $ Alert // BAD: untrusted dn goldap.ScopeWholeSubtree, goldap.NeverDerefAliases, 0, 0, false, - "(&(objectClass=organizationalPerson))"+untrusted, // BAD: untrusted filter - []string{"dn", "cn", untrusted}, // BAD: untrusted attribute + "(&(objectClass=organizationalPerson))"+untrusted, // $ Alert // BAD: untrusted filter + []string{"dn", "cn", untrusted}, // $ Alert // BAD: untrusted attribute nil, ) goldapv3.NewSearchRequest( - untrusted, // BAD: untrusted dn + untrusted, // $ Alert // BAD: untrusted dn goldap.ScopeWholeSubtree, goldap.NeverDerefAliases, 0, 0, false, - "(&(objectClass=organizationalPerson))"+untrusted, // BAD: untrusted filter - []string{"dn", "cn", untrusted}, // BAD: untrusted attribute + "(&(objectClass=organizationalPerson))"+untrusted, // $ Alert // BAD: untrusted filter + []string{"dn", "cn", untrusted}, // $ Alert // BAD: untrusted attribute nil, ) gopkgldapv2.NewSearchRequest( - untrusted, // BAD: untrusted dn + untrusted, // $ Alert // BAD: untrusted dn goldap.ScopeWholeSubtree, goldap.NeverDerefAliases, 0, 0, false, - "(&(objectClass=organizationalPerson))"+untrusted, // BAD: untrusted filter - []string{"dn", "cn", untrusted}, // BAD: untrusted attribute + "(&(objectClass=organizationalPerson))"+untrusted, // $ Alert // BAD: untrusted filter + []string{"dn", "cn", untrusted}, // $ Alert // BAD: untrusted attribute nil, ) client := &ldapclient.LDAPClient{} - client.Authenticate(untrusted, "123456") // BAD: untrusted filter - client.GetGroupsOfUser(untrusted) // BAD: untrusted filter + client.Authenticate(untrusted, "123456") // $ Alert // BAD: untrusted filter + client.GetGroupsOfUser(untrusted) // $ Alert // BAD: untrusted filter // ... } diff --git a/go/ql/test/experimental/CWE-090/LDAPInjection.qlref b/go/ql/test/experimental/CWE-090/LDAPInjection.qlref index 7049e09a726..45935a174c4 100644 --- a/go/ql/test/experimental/CWE-090/LDAPInjection.qlref +++ b/go/ql/test/experimental/CWE-090/LDAPInjection.qlref @@ -1,2 +1,4 @@ query: experimental/CWE-090/LDAPInjection.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/experimental/CWE-203/Timing.qlref b/go/ql/test/experimental/CWE-203/Timing.qlref index 7306096e724..e14641beccf 100644 --- a/go/ql/test/experimental/CWE-203/Timing.qlref +++ b/go/ql/test/experimental/CWE-203/Timing.qlref @@ -1,2 +1,4 @@ query: experimental/CWE-203/Timing.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/experimental/CWE-203/timing.go b/go/ql/test/experimental/CWE-203/timing.go index 43401bd4111..32543e367b6 100644 --- a/go/ql/test/experimental/CWE-203/timing.go +++ b/go/ql/test/experimental/CWE-203/timing.go @@ -12,9 +12,9 @@ func bad(w http.ResponseWriter, req *http.Request) (interface{}, error) { secret := "MySuperSecretPasscode" secretHeader := "X-Secret" - headerSecret := req.Header.Get(secretHeader) + headerSecret := req.Header.Get(secretHeader) // $ Source secretStr := string(secret) - if len(headerSecret) != 0 && headerSecret != secretStr { + if len(headerSecret) != 0 && headerSecret != secretStr { // $ Alert return nil, fmt.Errorf("header %s=%s did not match expected secret", secretHeader, headerSecret) } return nil, nil @@ -25,9 +25,9 @@ func bad2(w http.ResponseWriter, req *http.Request) (interface{}, error) { secret := "MySuperSecretPasscode" secretHeader := "X-Secret" - headerSecret := req.Header.Get(secretHeader) + headerSecret := req.Header.Get(secretHeader) // $ Source secretStr := string(secret) - if len(headerSecret) != 0 && strings.Compare(headerSecret, secretStr) != 0 { + if len(headerSecret) != 0 && strings.Compare(headerSecret, secretStr) != 0 { // $ Alert return nil, fmt.Errorf("header %s=%s did not match expected secret", secretHeader, headerSecret) } return nil, nil @@ -38,8 +38,8 @@ func bad4(w http.ResponseWriter, req *http.Request) (interface{}, error) { secret := "MySuperSecretPasscode" secretHeader := "X-Secret" - headerSecret := req.Header.Get(secretHeader) - if len(secret) != 0 && headerSecret != "SecretStringLiteral" { + headerSecret := req.Header.Get(secretHeader) // $ Source + if len(secret) != 0 && headerSecret != "SecretStringLiteral" { // $ Alert return nil, fmt.Errorf("header %s=%s did not match expected secret", secretHeader, headerSecret) } return nil, nil diff --git a/go/ql/test/experimental/CWE-285/PamAuthBypass.qlref b/go/ql/test/experimental/CWE-285/PamAuthBypass.qlref index 8a1d5b259e0..85ba5b1005d 100644 --- a/go/ql/test/experimental/CWE-285/PamAuthBypass.qlref +++ b/go/ql/test/experimental/CWE-285/PamAuthBypass.qlref @@ -1 +1,2 @@ -experimental/CWE-285/PamAuthBypass.ql \ No newline at end of file +query: experimental/CWE-285/PamAuthBypass.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/experimental/CWE-285/main.go b/go/ql/test/experimental/CWE-285/main.go index b0607a74a41..352a57bb699 100644 --- a/go/ql/test/experimental/CWE-285/main.go +++ b/go/ql/test/experimental/CWE-285/main.go @@ -9,7 +9,7 @@ import ( func bad() error { t, _ := pam.StartFunc("", "", func(s pam.Style, msg string) (string, error) { return "", nil - }) + }) // $ Alert return t.Authenticate(0) } diff --git a/go/ql/test/experimental/CWE-287/ImproperLdapAuth.go b/go/ql/test/experimental/CWE-287/ImproperLdapAuth.go index b4e7b796b90..6e2f7d44033 100644 --- a/go/ql/test/experimental/CWE-287/ImproperLdapAuth.go +++ b/go/ql/test/experimental/CWE-287/ImproperLdapAuth.go @@ -15,7 +15,7 @@ func bad(w http.ResponseWriter, req *http.Request) (interface{}, error) { ldapServer := "ldap.example.com" ldapPort := 389 bindDN := "cn=admin,dc=example,dc=com" - bindPassword := req.URL.Query()["password"][0] + bindPassword := req.URL.Query()["password"][0] // $ Source // Connect to the LDAP server l, err := ldap.Dial("tcp", fmt.Sprintf("%s:%d", ldapServer, ldapPort)) @@ -25,7 +25,7 @@ func bad(w http.ResponseWriter, req *http.Request) (interface{}, error) { defer l.Close() // BAD: user input is not sanetized - err = l.Bind(bindDN, bindPassword) + err = l.Bind(bindDN, bindPassword) // $ Alert if err != nil { return fmt.Errorf("LDAP bind failed: %v", err), err } @@ -84,7 +84,7 @@ func bad2(req *http.Request) { ldapPort := 389 bindDN := "cn=admin,dc=example,dc=com" // BAD : empty password - bindPassword := "" + bindPassword := "" // $ Source // Connect to the LDAP server l, err := ldap.Dial("tcp", fmt.Sprintf("%s:%d", ldapServer, ldapPort)) @@ -94,7 +94,7 @@ func bad2(req *http.Request) { defer l.Close() // BAD : bindPassword is empty - err = l.Bind(bindDN, bindPassword) + err = l.Bind(bindDN, bindPassword) // $ Alert if err != nil { log.Fatalf("LDAP bind failed: %v", err) } diff --git a/go/ql/test/experimental/CWE-287/ImproperLdapAuth.qlref b/go/ql/test/experimental/CWE-287/ImproperLdapAuth.qlref index 35ca7800cc8..409b5b3347d 100644 --- a/go/ql/test/experimental/CWE-287/ImproperLdapAuth.qlref +++ b/go/ql/test/experimental/CWE-287/ImproperLdapAuth.qlref @@ -1,2 +1,4 @@ query: experimental/CWE-287/ImproperLdapAuth.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/experimental/CWE-321-V2/HardCodedKeys.expected b/go/ql/test/experimental/CWE-321-V2/HardCodedKeys.expected index 5b26a2a9b36..0cad327e641 100644 --- a/go/ql/test/experimental/CWE-321-V2/HardCodedKeys.expected +++ b/go/ql/test/experimental/CWE-321-V2/HardCodedKeys.expected @@ -1,3 +1,6 @@ +#select +| go-jose.v3.go:24:32:24:37 | JwtKey | go-jose.v3.go:13:21:13:33 | "AllYourBase" | go-jose.v3.go:24:32:24:37 | JwtKey | This $@. | go-jose.v3.go:13:21:13:33 | "AllYourBase" | Constant Key is used as JWT Secret key | +| golang-jwt-v5.go:27:9:27:15 | JwtKey1 | golang-jwt-v5.go:19:22:19:34 | "AllYourBase" | golang-jwt-v5.go:27:9:27:15 | JwtKey1 | This $@. | golang-jwt-v5.go:19:22:19:34 | "AllYourBase" | Constant Key is used as JWT Secret key | edges | go-jose.v3.go:13:14:13:34 | type conversion | go-jose.v3.go:24:32:24:37 | JwtKey | provenance | | | go-jose.v3.go:13:21:13:33 | "AllYourBase" | go-jose.v3.go:13:14:13:34 | type conversion | provenance | | @@ -11,6 +14,3 @@ nodes | golang-jwt-v5.go:19:22:19:34 | "AllYourBase" | semmle.label | "AllYourBase" | | golang-jwt-v5.go:27:9:27:15 | JwtKey1 | semmle.label | JwtKey1 | subpaths -#select -| go-jose.v3.go:24:32:24:37 | JwtKey | go-jose.v3.go:13:21:13:33 | "AllYourBase" | go-jose.v3.go:24:32:24:37 | JwtKey | This $@. | go-jose.v3.go:13:21:13:33 | "AllYourBase" | Constant Key is used as JWT Secret key | -| golang-jwt-v5.go:27:9:27:15 | JwtKey1 | golang-jwt-v5.go:19:22:19:34 | "AllYourBase" | golang-jwt-v5.go:27:9:27:15 | JwtKey1 | This $@. | golang-jwt-v5.go:19:22:19:34 | "AllYourBase" | Constant Key is used as JWT Secret key | diff --git a/go/ql/test/experimental/CWE-321-V2/HardCodedKeys.qlref b/go/ql/test/experimental/CWE-321-V2/HardCodedKeys.qlref index e6cee546420..63827b14d7a 100644 --- a/go/ql/test/experimental/CWE-321-V2/HardCodedKeys.qlref +++ b/go/ql/test/experimental/CWE-321-V2/HardCodedKeys.qlref @@ -1 +1,2 @@ -experimental/CWE-321-V2/HardCodedKeys.ql \ No newline at end of file +query: experimental/CWE-321-V2/HardCodedKeys.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/experimental/CWE-321-V2/go-jose.v3.go b/go/ql/test/experimental/CWE-321-V2/go-jose.v3.go index e25624bb680..c9d103710ba 100644 --- a/go/ql/test/experimental/CWE-321-V2/go-jose.v3.go +++ b/go/ql/test/experimental/CWE-321-V2/go-jose.v3.go @@ -10,7 +10,7 @@ import ( ) // NOT OK -var JwtKey = []byte("AllYourBase") +var JwtKey = []byte("AllYourBase") // $ Source func main2(r *http.Request) { signedToken := r.URL.Query().Get("signedToken") @@ -21,7 +21,7 @@ func verifyJWT(signedToken string) { fmt.Println("verifying JWT") DecodedToken, _ := jwt.ParseSigned(signedToken) out := CustomerInfo{} - if err := DecodedToken.Claims(JwtKey, &out); err != nil { + if err := DecodedToken.Claims(JwtKey, &out); err != nil { // $ Alert panic(err) } fmt.Printf("%v\n", out) diff --git a/go/ql/test/experimental/CWE-321-V2/golang-jwt-v5.go b/go/ql/test/experimental/CWE-321-V2/golang-jwt-v5.go index 71917160bda..166c8e6454e 100644 --- a/go/ql/test/experimental/CWE-321-V2/golang-jwt-v5.go +++ b/go/ql/test/experimental/CWE-321-V2/golang-jwt-v5.go @@ -16,7 +16,7 @@ type CustomerInfo struct { } // BAD constant key -var JwtKey1 = []byte("AllYourBase") +var JwtKey1 = []byte("AllYourBase") // $ Source func main1(r *http.Request) { signedToken := r.URL.Query().Get("signedToken") @@ -24,7 +24,7 @@ func main1(r *http.Request) { } func LoadJwtKey(token *jwt.Token) (interface{}, error) { - return JwtKey1, nil + return JwtKey1, nil // $ Alert } func verifyJWT_golangjwt(signedToken string) { diff --git a/go/ql/test/experimental/CWE-369/DivideByZero.go b/go/ql/test/experimental/CWE-369/DivideByZero.go index 613479981b1..75588a18b45 100644 --- a/go/ql/test/experimental/CWE-369/DivideByZero.go +++ b/go/ql/test/experimental/CWE-369/DivideByZero.go @@ -7,37 +7,37 @@ import ( ) func myHandler1(w http.ResponseWriter, r *http.Request) { - param1 := r.URL.Query()["param1"][0] + param1 := r.URL.Query()["param1"][0] // $ Source value, _ := strconv.Atoi(param1) - out := 1337 / value + out := 1337 / value // $ Alert fmt.Println(out) } func myHandler2(w http.ResponseWriter, r *http.Request) { - param1 := r.URL.Query()["param1"][0] + param1 := r.URL.Query()["param1"][0] // $ Source value := int(param1[0]) - out := 1337 / value + out := 1337 / value // $ Alert fmt.Println(out) } func myHandler3(w http.ResponseWriter, r *http.Request) { - param1 := r.URL.Query()["param1"][0] + param1 := r.URL.Query()["param1"][0] // $ Source value, _ := strconv.ParseInt(param1, 10, 64) - out := 1337 / value + out := 1337 / value // $ Alert fmt.Println(out) } func myHandler4(w http.ResponseWriter, r *http.Request) { - param1 := r.URL.Query()["param1"][0] + param1 := r.URL.Query()["param1"][0] // $ Source value, _ := strconv.ParseFloat(param1, 32) - out := 1337 / value + out := 1337 / value // $ Alert fmt.Println(out) } func myHandler5(w http.ResponseWriter, r *http.Request) { - param1 := r.URL.Query()["param1"][0] + param1 := r.URL.Query()["param1"][0] // $ Source value, _ := strconv.ParseUint(param1, 10, 64) - out := 1337 / value + out := 1337 / value // $ Alert fmt.Println(out) } @@ -51,10 +51,10 @@ func myHandler6(w http.ResponseWriter, r *http.Request) { } func myHandler7(w http.ResponseWriter, r *http.Request) { - param1 := r.URL.Query()["param1"][0] + param1 := r.URL.Query()["param1"][0] // $ Source value := int(param1[0]) if value >= 0 { - out := 1337 / value + out := 1337 / value // $ Alert fmt.Println(out) } } diff --git a/go/ql/test/experimental/CWE-369/DivideByZero.qlref b/go/ql/test/experimental/CWE-369/DivideByZero.qlref index 80eca2d3219..0713092d4b8 100644 --- a/go/ql/test/experimental/CWE-369/DivideByZero.qlref +++ b/go/ql/test/experimental/CWE-369/DivideByZero.qlref @@ -1,2 +1,4 @@ query: experimental/CWE-369/DivideByZero.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/experimental/CWE-400/DatabaseCallInLoop.expected b/go/ql/test/experimental/CWE-400/DatabaseCallInLoop.expected index 074dfaa134f..e95505223cd 100644 --- a/go/ql/test/experimental/CWE-400/DatabaseCallInLoop.expected +++ b/go/ql/test/experimental/CWE-400/DatabaseCallInLoop.expected @@ -1,3 +1,7 @@ +#select +| DatabaseCallInLoop.go:9:3:9:41 | call to First | DatabaseCallInLoop.go:7:2:11:2 | range statement | DatabaseCallInLoop.go:9:3:9:41 | call to First | This calls call to First in a $@. | DatabaseCallInLoop.go:7:2:11:2 | range statement | loop | +| test.go:11:2:11:13 | call to Take | test.go:20:2:22:2 | for statement | test.go:11:2:11:13 | call to Take | This calls call to Take in a $@. | test.go:20:2:22:2 | for statement | loop | +| test.go:11:2:11:13 | call to Take | test.go:24:2:26:2 | for statement | test.go:11:2:11:13 | call to Take | This calls call to Take in a $@. | test.go:24:2:26:2 | for statement | loop | edges | DatabaseCallInLoop.go:7:2:11:2 | range statement | DatabaseCallInLoop.go:9:3:9:41 | call to First | | test.go:10:1:12:1 | function declaration | test.go:11:2:11:13 | call to Take | @@ -7,7 +11,3 @@ edges | test.go:21:3:21:14 | call to runQuery | test.go:10:1:12:1 | function declaration | | test.go:24:2:26:2 | for statement | test.go:25:3:25:17 | call to runRunQuery | | test.go:25:3:25:17 | call to runRunQuery | test.go:14:1:16:1 | function declaration | -#select -| DatabaseCallInLoop.go:9:3:9:41 | call to First | DatabaseCallInLoop.go:7:2:11:2 | range statement | DatabaseCallInLoop.go:9:3:9:41 | call to First | This calls call to First in a $@. | DatabaseCallInLoop.go:7:2:11:2 | range statement | loop | -| test.go:11:2:11:13 | call to Take | test.go:20:2:22:2 | for statement | test.go:11:2:11:13 | call to Take | This calls call to Take in a $@. | test.go:20:2:22:2 | for statement | loop | -| test.go:11:2:11:13 | call to Take | test.go:24:2:26:2 | for statement | test.go:11:2:11:13 | call to Take | This calls call to Take in a $@. | test.go:24:2:26:2 | for statement | loop | diff --git a/go/ql/test/experimental/CWE-400/DatabaseCallInLoop.go b/go/ql/test/experimental/CWE-400/DatabaseCallInLoop.go index 138bbbcd9d4..eff08179ee5 100644 --- a/go/ql/test/experimental/CWE-400/DatabaseCallInLoop.go +++ b/go/ql/test/experimental/CWE-400/DatabaseCallInLoop.go @@ -6,8 +6,8 @@ func getUsers(db *gorm.DB, names []string) []User { res := make([]User, 0, len(names)) for _, name := range names { var user User - db.Where("name = ?", name).First(&user) + db.Where("name = ?", name).First(&user) // $ Alert res = append(res, user) - } + } // $ Source return res } diff --git a/go/ql/test/experimental/CWE-400/DatabaseCallInLoop.qlref b/go/ql/test/experimental/CWE-400/DatabaseCallInLoop.qlref index 63f27c9b41f..945fbc88364 100644 --- a/go/ql/test/experimental/CWE-400/DatabaseCallInLoop.qlref +++ b/go/ql/test/experimental/CWE-400/DatabaseCallInLoop.qlref @@ -1 +1,2 @@ -experimental/CWE-400/DatabaseCallInLoop.ql +query: experimental/CWE-400/DatabaseCallInLoop.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/experimental/CWE-400/test.go b/go/ql/test/experimental/CWE-400/test.go index 725fb541b38..4c0a7f01d2e 100644 --- a/go/ql/test/experimental/CWE-400/test.go +++ b/go/ql/test/experimental/CWE-400/test.go @@ -8,7 +8,7 @@ type User struct { } func runQuery(db *gorm.DB) { - db.Take(nil) + db.Take(nil) // $ Alert } func runRunQuery(db *gorm.DB) { @@ -19,9 +19,9 @@ func main() { var db *gorm.DB for i := 0; i < 10; i++ { runQuery(db) - } + } // $ Source for i := 10; i > 0; i-- { runRunQuery(db) - } + } // $ Source } diff --git a/go/ql/test/experimental/CWE-522-DecompressionBombs/DecompressionBombs.qlref b/go/ql/test/experimental/CWE-522-DecompressionBombs/DecompressionBombs.qlref index 93d41075d5f..367d7bfe2fd 100644 --- a/go/ql/test/experimental/CWE-522-DecompressionBombs/DecompressionBombs.qlref +++ b/go/ql/test/experimental/CWE-522-DecompressionBombs/DecompressionBombs.qlref @@ -1,2 +1,4 @@ query: experimental/CWE-522-DecompressionBombs/DecompressionBombs.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/experimental/CWE-522-DecompressionBombs/test.go b/go/ql/test/experimental/CWE-522-DecompressionBombs/test.go index dc359c387ac..370b24d4d3e 100644 --- a/go/ql/test/experimental/CWE-522-DecompressionBombs/test.go +++ b/go/ql/test/experimental/CWE-522-DecompressionBombs/test.go @@ -56,41 +56,41 @@ func main() { func DecompressHandler(w http.ResponseWriter, request *http.Request) { GZipOpenReaderSafe(request.PostFormValue("test")) ZipOpenReaderSafe(request.PostFormValue("test")) - ZipOpenReader(request.FormValue("filepath")) - ZipNewReader(request.Body) - ZipNewReaderKlauspost(request.Body) - Bzip2Dsnet(request.Body) + ZipOpenReader(request.FormValue("filepath")) // $ Source + ZipNewReader(request.Body) // $ Source + ZipNewReaderKlauspost(request.Body) // $ Source + Bzip2Dsnet(request.Body) // $ Source Bzip2DsnetSafe(request.Body) - Bzip2(request.Body) + Bzip2(request.Body) // $ Source Bzip2Safe(request.Body) - Flate(request.Body) + Flate(request.Body) // $ Source FlateSafe(request.Body) - FlateKlauspost(request.Body) + FlateKlauspost(request.Body) // $ Source FlateKlauspostSafe(request.Body) - FlateDsnet(request.Body) + FlateDsnet(request.Body) // $ Source FlateDsnetSafe(request.Body) - ZlibKlauspost(request.Body) + ZlibKlauspost(request.Body) // $ Source ZlibKlauspostSafe(request.Body) - Zlib(request.Body) + Zlib(request.Body) // $ Source ZlibSafe(request.Body) - Snappy(request.Body) + Snappy(request.Body) // $ Source SnappySafe(request.Body) - SnappyKlauspost(request.Body) + SnappyKlauspost(request.Body) // $ Source SnappyKlauspostSafe(request.Body) - S2(request.Body) + S2(request.Body) // $ Source S2Safe(request.Body) - Gzip(request.Body) + Gzip(request.Body) // $ Source GzipSafe(request.Body) - GZipIoReader(request.Body, "dest") - GzipKlauspost(request.Body) + GZipIoReader(request.Body, "dest") // $ Source + GzipKlauspost(request.Body) // $ Source GzipKlauspostSafe(request.Body) - PzipKlauspost(request.Body) + PzipKlauspost(request.Body) // $ Source PzipKlauspostSafe(request.Body) - Zstd_Klauspost(request.Body) + Zstd_Klauspost(request.Body) // $ Source Zstd_KlauspostSafe(request.Body) - Zstd_DataDog(request.Body) + Zstd_DataDog(request.Body) // $ Source Zstd_DataDogSafe(request.Body) - Xz(request.Body) + Xz(request.Body) // $ Source XzSafe(request.Body) } @@ -131,7 +131,7 @@ func ZipOpenReader(filename string) { for _, f := range zipReader.File { rc, _ := f.Open() for { - result, _ := io.CopyN(os.Stdout, rc, 68) // $ hasValueFlow="rc" + result, _ := io.CopyN(os.Stdout, rc, 68) // $ hasValueFlow="rc" Alert if result == 0 { _ = rc.Close() break @@ -144,7 +144,7 @@ func ZipOpenReader(filename string) { for _, f := range zipKlauspostReader.File { rc, _ := f.Open() for { - result, _ := io.CopyN(os.Stdout, rc, 68) // $ hasValueFlow="rc" + result, _ := io.CopyN(os.Stdout, rc, 68) // $ hasValueFlow="rc" Alert if result == 0 { _ = rc.Close() break @@ -161,7 +161,7 @@ func ZipNewReader(file io.Reader) { for _, file := range zipReader.File { fileWriter := bytes.NewBuffer([]byte{}) fileReaderCloser, _ := file.Open() - result, _ := io.Copy(fileWriter, fileReaderCloser) // $ hasValueFlow="fileReaderCloser" + result, _ := io.Copy(fileWriter, fileReaderCloser) // $ hasValueFlow="fileReaderCloser" Alert fmt.Print(result) } } @@ -173,7 +173,7 @@ func ZipNewReaderKlauspost(file io.Reader) { fileWriter := bytes.NewBuffer([]byte{}) // file.OpenRaw() fileReaderCloser, _ := file.Open() - result, _ := io.Copy(fileWriter, fileReaderCloser) // $ hasValueFlow="fileReaderCloser" + result, _ := io.Copy(fileWriter, fileReaderCloser) // $ hasValueFlow="fileReaderCloser" Alert fmt.Print(result) } } @@ -183,7 +183,7 @@ func Bzip2Dsnet(file io.Reader) { bzip2Reader, _ := bzip2Dsnet.NewReader(file, &bzip2Dsnet.ReaderConfig{}) var out []byte = make([]byte, 70) - bzip2Reader.Read(out) // $ hasValueFlow="bzip2Reader" + bzip2Reader.Read(out) // $ hasValueFlow="bzip2Reader" Alert tarRead = tar.NewReader(bzip2Reader) TarDecompressor(tarRead) @@ -210,7 +210,7 @@ func Bzip2(file io.Reader) { bzip2Reader := bzip2.NewReader(file) var out []byte = make([]byte, 70) - bzip2Reader.Read(out) // $ hasValueFlow="bzip2Reader" + bzip2Reader.Read(out) // $ hasValueFlow="bzip2Reader" Alert tarRead = tar.NewReader(bzip2Reader) TarDecompressor(tarRead) @@ -235,7 +235,7 @@ func Flate(file io.Reader) { flateReader := flate.NewReader(file) var out []byte = make([]byte, 70) - flateReader.Read(out) // $ hasValueFlow="flateReader" + flateReader.Read(out) // $ hasValueFlow="flateReader" Alert tarRead = tar.NewReader(flateReader) TarDecompressor(tarRead) @@ -260,7 +260,7 @@ func FlateKlauspost(file io.Reader) { flateReader := flateKlauspost.NewReader(file) var out []byte = make([]byte, 70) - flateReader.Read(out) // $ hasValueFlow="flateReader" + flateReader.Read(out) // $ hasValueFlow="flateReader" Alert tarRead = tar.NewReader(flateReader) TarDecompressor(tarRead) @@ -285,7 +285,7 @@ func FlateDsnet(file io.Reader) { flateReader, _ := flateDsnet.NewReader(file, &flateDsnet.ReaderConfig{}) var out []byte = make([]byte, 70) - flateReader.Read(out) // $ hasValueFlow="flateReader" + flateReader.Read(out) // $ hasValueFlow="flateReader" Alert tarRead = tar.NewReader(flateReader) TarDecompressor(tarRead) @@ -310,7 +310,7 @@ func ZlibKlauspost(file io.Reader) { zlibReader, _ := zlibKlauspost.NewReader(file) var out []byte = make([]byte, 70) - zlibReader.Read(out) // $ hasValueFlow="zlibReader" + zlibReader.Read(out) // $ hasValueFlow="zlibReader" Alert tarRead = tar.NewReader(zlibReader) TarDecompressor(tarRead) @@ -335,7 +335,7 @@ func Zlib(file io.Reader) { zlibReader, _ := zlib.NewReader(file) var out []byte = make([]byte, 70) - zlibReader.Read(out) // $ hasValueFlow="zlibReader" + zlibReader.Read(out) // $ hasValueFlow="zlibReader" Alert tarRead = tar.NewReader(zlibReader) TarDecompressor(tarRead) @@ -360,8 +360,8 @@ func Snappy(file io.Reader) { snappyReader := snappy.NewReader(file) var out []byte = make([]byte, 70) - snappyReader.Read(out) // $ hasValueFlow="snappyReader" - snappyReader.ReadByte() // $ hasValueFlow="snappyReader" + snappyReader.Read(out) // $ hasValueFlow="snappyReader" Alert + snappyReader.ReadByte() // $ hasValueFlow="snappyReader" Alert tarRead = tar.NewReader(snappyReader) TarDecompressor(tarRead) @@ -386,10 +386,10 @@ func SnappyKlauspost(file io.Reader) { snappyReader := snappyKlauspost.NewReader(file) var out []byte = make([]byte, 70) - snappyReader.Read(out) // $ hasValueFlow="snappyReader" + snappyReader.Read(out) // $ hasValueFlow="snappyReader" Alert var buf bytes.Buffer - snappyReader.DecodeConcurrent(&buf, 2) // $ hasValueFlow="snappyReader" - snappyReader.ReadByte() // $ hasValueFlow="snappyReader" + snappyReader.DecodeConcurrent(&buf, 2) // $ hasValueFlow="snappyReader" Alert + snappyReader.ReadByte() // $ hasValueFlow="snappyReader" Alert tarRead = tar.NewReader(snappyReader) TarDecompressor(tarRead) @@ -414,10 +414,10 @@ func S2(file io.Reader) { s2Reader := s2.NewReader(file) var out []byte = make([]byte, 70) - s2Reader.Read(out) // $ hasValueFlow="s2Reader" - s2Reader.ReadByte() // $ hasValueFlow="s2Reader" + s2Reader.Read(out) // $ hasValueFlow="s2Reader" Alert + s2Reader.ReadByte() // $ hasValueFlow="s2Reader" Alert var buf bytes.Buffer - s2Reader.DecodeConcurrent(&buf, 2) // $ hasValueFlow="s2Reader" + s2Reader.DecodeConcurrent(&buf, 2) // $ hasValueFlow="s2Reader" Alert tarRead = tar.NewReader(s2Reader) TarDecompressor(tarRead) @@ -442,14 +442,14 @@ func GZipIoReader(src io.Reader, dst string) { dstF, _ := os.OpenFile(dst, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755) defer dstF.Close() newSrc := io.Reader(gzipReader) - _, _ = io.Copy(dstF, newSrc) // $ hasValueFlow="newSrc" + _, _ = io.Copy(dstF, newSrc) // $ hasValueFlow="newSrc" Alert } func Gzip(file io.Reader) { var tarRead *tar.Reader gzipReader, _ := gzip.NewReader(file) var out []byte = make([]byte, 70) - gzipReader.Read(out) // $ hasValueFlow="gzipReader" + gzipReader.Read(out) // $ hasValueFlow="gzipReader" Alert tarRead = tar.NewReader(gzipReader) TarDecompressor(tarRead) @@ -474,9 +474,9 @@ func GzipKlauspost(file io.Reader) { gzipReader, _ := gzipKlauspost.NewReader(file) var out []byte = make([]byte, 70) - gzipReader.Read(out) // $ hasValueFlow="gzipReader" + gzipReader.Read(out) // $ hasValueFlow="gzipReader" Alert var buf bytes.Buffer - gzipReader.WriteTo(&buf) // $ hasValueFlow="gzipReader" + gzipReader.WriteTo(&buf) // $ hasValueFlow="gzipReader" Alert tarRead = tar.NewReader(gzipReader) TarDecompressor(tarRead) @@ -501,9 +501,9 @@ func PzipKlauspost(file io.Reader) { pgzipReader, _ := pgzipKlauspost.NewReader(file) var out []byte = make([]byte, 70) - pgzipReader.Read(out) // $ hasValueFlow="pgzipReader" + pgzipReader.Read(out) // $ hasValueFlow="pgzipReader" Alert var buf bytes.Buffer - pgzipReader.WriteTo(&buf) // $ hasValueFlow="pgzipReader" + pgzipReader.WriteTo(&buf) // $ hasValueFlow="pgzipReader" Alert tarRead = tar.NewReader(pgzipReader) TarDecompressor(tarRead) @@ -528,11 +528,11 @@ func Zstd_Klauspost(file io.Reader) { zstdReader, _ := zstdKlauspost.NewReader(file) var out []byte = make([]byte, 70) - zstdReader.Read(out) // $ hasValueFlow="zstdReader" + zstdReader.Read(out) // $ hasValueFlow="zstdReader" Alert var buf bytes.Buffer - zstdReader.WriteTo(&buf) // $ hasValueFlow="zstdReader" + zstdReader.WriteTo(&buf) // $ hasValueFlow="zstdReader" Alert var src []byte - zstdReader.DecodeAll(src, nil) // $ hasValueFlow="zstdReader" + zstdReader.DecodeAll(src, nil) // $ hasValueFlow="zstdReader" Alert tarRead = tar.NewReader(zstdReader) TarDecompressor(tarRead) @@ -557,7 +557,7 @@ func Zstd_DataDog(file io.Reader) { zstdReader := zstdDataDog.NewReader(file) var out []byte = make([]byte, 70) - zstdReader.Read(out) // $ hasValueFlow="zstdReader" + zstdReader.Read(out) // $ hasValueFlow="zstdReader" Alert tarRead = tar.NewReader(zstdReader) TarDecompressor(tarRead) @@ -582,7 +582,7 @@ func Xz(file io.Reader) { xzReader, _ := xz.NewReader(file) var out []byte = make([]byte, 70) - xzReader.Read(out) // $ hasValueFlow="xzReader" + xzReader.Read(out) // $ hasValueFlow="xzReader" Alert tarRead = tar.NewReader(xzReader) fmt.Println(io.SeekStart) @@ -618,7 +618,7 @@ func TarDecompressor(tarRead *tar.Reader) { if cur.Typeflag != tar.TypeReg { continue } - data, _ := io.ReadAll(tarRead) // $ hasValueFlow="tarRead" + data, _ := io.ReadAll(tarRead) // $ hasValueFlow="tarRead" Alert files[cur.Name] = &fstest.MapFile{Data: data} } fmt.Print(files) @@ -626,7 +626,7 @@ func TarDecompressor(tarRead *tar.Reader) { func TarDecompressor2(tarRead *tar.Reader) { var tarOut []byte = make([]byte, 70) - tarRead.Read(tarOut) // $ hasValueFlow="tarRead" + tarRead.Read(tarOut) // $ hasValueFlow="tarRead" Alert fmt.Println("do sth with output:", tarOut) } diff --git a/go/ql/test/experimental/CWE-525/WebCacheDeception.qlref b/go/ql/test/experimental/CWE-525/WebCacheDeception.qlref index 8b0788ef904..9e5d5cc3033 100644 --- a/go/ql/test/experimental/CWE-525/WebCacheDeception.qlref +++ b/go/ql/test/experimental/CWE-525/WebCacheDeception.qlref @@ -1 +1,2 @@ -experimental/CWE-525/WebCacheDeception.ql \ No newline at end of file +query: experimental/CWE-525/WebCacheDeception.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/experimental/CWE-525/WebCacheDeceptionBad.go b/go/ql/test/experimental/CWE-525/WebCacheDeceptionBad.go index 577fbd78c06..978d05588bb 100644 --- a/go/ql/test/experimental/CWE-525/WebCacheDeceptionBad.go +++ b/go/ql/test/experimental/CWE-525/WebCacheDeceptionBad.go @@ -79,7 +79,7 @@ func badRoutingNet() { http.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir("assets/")))) - http.HandleFunc("/adminusers/", ShowAdminPageCache) + http.HandleFunc("/adminusers/", ShowAdminPageCache) // $ Alert err := http.ListenAndServe(":1337", nil) if err != nil { log.Fatal("ListenAndServe: ", err) diff --git a/go/ql/test/experimental/CWE-525/WebCacheDeceptionFiber.go b/go/ql/test/experimental/CWE-525/WebCacheDeceptionFiber.go index 80f396c26df..1126659d76e 100644 --- a/go/ql/test/experimental/CWE-525/WebCacheDeceptionFiber.go +++ b/go/ql/test/experimental/CWE-525/WebCacheDeceptionFiber.go @@ -12,12 +12,12 @@ func badRouting() { log.Println("We are logging in Golang!") // GET /api/register - app.Get("/api/*", func(c *fiber.Ctx) error { + app.Get("/api/*", func(c *fiber.Ctx) error { // $ Alert msg := fmt.Sprintf("✋") return c.SendString(msg) // => ✋ register }) - app.Post("/api/*", func(c *fiber.Ctx) error { + app.Post("/api/*", func(c *fiber.Ctx) error { // $ Alert msg := fmt.Sprintf("✋") return c.SendString(msg) // => ✋ register }) diff --git a/go/ql/test/experimental/CWE-525/WebCacheDeceptionGoChi.go b/go/ql/test/experimental/CWE-525/WebCacheDeceptionGoChi.go index 539dae1dee9..3de5e659138 100644 --- a/go/ql/test/experimental/CWE-525/WebCacheDeceptionGoChi.go +++ b/go/ql/test/experimental/CWE-525/WebCacheDeceptionGoChi.go @@ -10,7 +10,7 @@ import ( func badRoutingChi() { r := chi.NewRouter() r.Use(middleware.Logger) - r.Get("/*", func(w http.ResponseWriter, r *http.Request) { + r.Get("/*", func(w http.ResponseWriter, r *http.Request) { // $ Alert w.Write([]byte("welcome")) }) http.ListenAndServe(":3000", r) diff --git a/go/ql/test/experimental/CWE-525/WebCacheDeceptionHTTPRouter.go b/go/ql/test/experimental/CWE-525/WebCacheDeceptionHTTPRouter.go index 864c6c5e31c..7d1cd0b3d16 100644 --- a/go/ql/test/experimental/CWE-525/WebCacheDeceptionHTTPRouter.go +++ b/go/ql/test/experimental/CWE-525/WebCacheDeceptionHTTPRouter.go @@ -18,7 +18,7 @@ func Hello(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { func badHTTPRouter() { router := httprouter.New() - router.GET("/test/*test", Index) + router.GET("/test/*test", Index) // $ Alert router.GET("/hello/:name", Hello) log.Fatal(http.ListenAndServe(":8082", router)) diff --git a/go/ql/test/experimental/CWE-74/Dsn.go b/go/ql/test/experimental/CWE-74/Dsn.go index 3cdabc7cb3f..56eee4a48ee 100644 --- a/go/ql/test/experimental/CWE-74/Dsn.go +++ b/go/ql/test/experimental/CWE-74/Dsn.go @@ -23,10 +23,10 @@ func good() (interface{}, error) { } func bad() interface{} { - name2 := os.Args[1:] + name2 := os.Args[1:] // $ Source[go/dsn-injection-local] // This is bad. `name` can be something like `test?allowAllFiles=true&` which will allow an attacker to access local files. dbDSN := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8", "username", "password", "127.0.0.1", 3306, name2[0]) - db, _ := sql.Open("mysql", dbDSN) + db, _ := sql.Open("mysql", dbDSN) // $ Alert[go/dsn-injection-local] return db } @@ -44,10 +44,10 @@ func good2(w http.ResponseWriter, req *http.Request) (interface{}, error) { } func bad2(w http.ResponseWriter, req *http.Request) interface{} { - name := req.FormValue("name") + name := req.FormValue("name") // $ Source[go/dsn-injection] // This is bad. `name` can be something like `test?allowAllFiles=true&` which will allow an attacker to access local files. dbDSN := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8", "username", "password", "127.0.0.1", 3306, name) - db, _ := sql.Open("mysql", dbDSN) + db, _ := sql.Open("mysql", dbDSN) // $ Alert[go/dsn-injection] return db } @@ -60,12 +60,12 @@ func (Config) Parse([]string) error { return nil } func RegexFuncModelTest(w http.ResponseWriter, req *http.Request) (interface{}, error) { cfg := NewConfig() - err := cfg.Parse(os.Args[1:]) // This is bad. `name` can be something like `test?allowAllFiles=true&` which will allow an attacker to access local files. + err := cfg.Parse(os.Args[1:]) // $ Source[go/dsn-injection-local] // This is bad. `name` can be something like `test?allowAllFiles=true&` which will allow an attacker to access local files. if err != nil { return nil, err } dbDSN := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8", "username", "password", "127.0.0.1", 3306, cfg.dsn) - db, _ := sql.Open("mysql", dbDSN) + db, _ := sql.Open("mysql", dbDSN) // $ Alert[go/dsn-injection-local] return db, nil } diff --git a/go/ql/test/experimental/CWE-74/DsnInjection.qlref b/go/ql/test/experimental/CWE-74/DsnInjection.qlref index f8e0117d735..1b468898078 100644 --- a/go/ql/test/experimental/CWE-74/DsnInjection.qlref +++ b/go/ql/test/experimental/CWE-74/DsnInjection.qlref @@ -1,2 +1,4 @@ query: experimental/CWE-74/DsnInjection.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/experimental/CWE-74/DsnInjectionLocal.qlref b/go/ql/test/experimental/CWE-74/DsnInjectionLocal.qlref index f2d6116c7f1..f0907dee939 100644 --- a/go/ql/test/experimental/CWE-74/DsnInjectionLocal.qlref +++ b/go/ql/test/experimental/CWE-74/DsnInjectionLocal.qlref @@ -1,2 +1,4 @@ query: experimental/CWE-74/DsnInjectionLocal.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/experimental/CWE-807/SensitiveConditionBypass.qlref b/go/ql/test/experimental/CWE-807/SensitiveConditionBypass.qlref index da2ab35074a..b31f535387e 100644 --- a/go/ql/test/experimental/CWE-807/SensitiveConditionBypass.qlref +++ b/go/ql/test/experimental/CWE-807/SensitiveConditionBypass.qlref @@ -1 +1,2 @@ -experimental/CWE-807/SensitiveConditionBypass.ql +query: experimental/CWE-807/SensitiveConditionBypass.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/experimental/CWE-807/SensitiveConditionBypassBad.go b/go/ql/test/experimental/CWE-807/SensitiveConditionBypassBad.go index bf8e70f88b7..04161f28fa8 100644 --- a/go/ql/test/experimental/CWE-807/SensitiveConditionBypassBad.go +++ b/go/ql/test/experimental/CWE-807/SensitiveConditionBypassBad.go @@ -4,7 +4,7 @@ import "net/http" func example(w http.ResponseWriter, r *http.Request) { test2 := "test" - if r.Header.Get("X-Password") != test2 { + if r.Header.Get("X-Password") != test2 { // $ Alert login() } } diff --git a/go/ql/test/experimental/CWE-807/condition.go b/go/ql/test/experimental/CWE-807/condition.go index ecd6b0a9f2a..d2bef8b335b 100644 --- a/go/ql/test/experimental/CWE-807/condition.go +++ b/go/ql/test/experimental/CWE-807/condition.go @@ -13,7 +13,7 @@ const test = "localhost" // Should alert as authkey is sensitive func ex1(w http.ResponseWriter, r *http.Request) { - if r.Header.Get("Origin") != test { + if r.Header.Get("Origin") != test { // $ Alert authkey := "randomDatta" io.WriteString(w, authkey) } @@ -22,7 +22,7 @@ func ex1(w http.ResponseWriter, r *http.Request) { // Should alert as authkey is sensitive func ex2(w http.ResponseWriter, r *http.Request) { test2 := "test" - if r.Header.Get("Origin") != test2 { + if r.Header.Get("Origin") != test2 { // $ Alert authkey := "randomDatta2" io.WriteString(w, authkey) } @@ -31,7 +31,7 @@ func ex2(w http.ResponseWriter, r *http.Request) { // Should alert as login() is sensitive func ex3(w http.ResponseWriter, r *http.Request) { test2 := "test" - if r.Header.Get("Origin") != test2 { + if r.Header.Get("Origin") != test2 { // $ Alert login() } } diff --git a/go/ql/test/experimental/CWE-840/ConditionalBypass.qlref b/go/ql/test/experimental/CWE-840/ConditionalBypass.qlref index 6d167616055..8c99cf7c285 100644 --- a/go/ql/test/experimental/CWE-840/ConditionalBypass.qlref +++ b/go/ql/test/experimental/CWE-840/ConditionalBypass.qlref @@ -1 +1,2 @@ -experimental/CWE-840/ConditionalBypass.ql +query: experimental/CWE-840/ConditionalBypass.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/experimental/CWE-840/ConditionalBypassBad.go b/go/ql/test/experimental/CWE-840/ConditionalBypassBad.go index b788dee2009..a90b723e8be 100644 --- a/go/ql/test/experimental/CWE-840/ConditionalBypassBad.go +++ b/go/ql/test/experimental/CWE-840/ConditionalBypassBad.go @@ -6,7 +6,7 @@ import ( func exampleHandlerBad(w http.ResponseWriter, r *http.Request) { // BAD: the Origin and Host headers are user controlled - if r.Header.Get("Origin") != "http://"+r.Host { + if r.Header.Get("Origin") != "http://"+r.Host { // $ Alert //do something } } diff --git a/go/ql/test/experimental/CWE-840/condition.go b/go/ql/test/experimental/CWE-840/condition.go index 7b7b7480c10..fa413f32576 100644 --- a/go/ql/test/experimental/CWE-840/condition.go +++ b/go/ql/test/experimental/CWE-840/condition.go @@ -6,14 +6,14 @@ import ( // BAD: taken from https://www.gorillatoolkit.org/pkg/websocket func ex1(w http.ResponseWriter, r *http.Request) { - if r.Header.Get("Origin") != "http://"+r.Host { + if r.Header.Get("Origin") != "http://"+r.Host { // $ Alert //do something } } // BAD: both operands are from remote sources func ex2(w http.ResponseWriter, r *http.Request) { - if r.Header.Get("Origin") != "http://"+r.Header.Get("Header") { + if r.Header.Get("Origin") != "http://"+r.Header.Get("Header") { // $ Alert //do something } } diff --git a/go/ql/test/experimental/InconsistentCode/DeferInLoop.go b/go/ql/test/experimental/InconsistentCode/DeferInLoop.go index 1b57d1855b4..476a72a68f9 100644 --- a/go/ql/test/experimental/InconsistentCode/DeferInLoop.go +++ b/go/ql/test/experimental/InconsistentCode/DeferInLoop.go @@ -5,7 +5,7 @@ import "os" func openFiles(filenames []string) { for _, filename := range filenames { file, err := os.Open(filename) - defer file.Close() + defer file.Close() // $ Alert[go/examples/deferinloop] if err != nil { // handle error } diff --git a/go/ql/test/experimental/InconsistentCode/DeferInLoop.qlref b/go/ql/test/experimental/InconsistentCode/DeferInLoop.qlref index e50bcf4fdf6..f291f77e09e 100644 --- a/go/ql/test/experimental/InconsistentCode/DeferInLoop.qlref +++ b/go/ql/test/experimental/InconsistentCode/DeferInLoop.qlref @@ -1 +1,2 @@ -experimental/InconsistentCode/DeferInLoop.ql +query: experimental/InconsistentCode/DeferInLoop.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/experimental/InconsistentCode/GORMErrorNotChecked.go b/go/ql/test/experimental/InconsistentCode/GORMErrorNotChecked.go index 422e49b5f10..c24f9bad5a7 100644 --- a/go/ql/test/experimental/InconsistentCode/GORMErrorNotChecked.go +++ b/go/ql/test/experimental/InconsistentCode/GORMErrorNotChecked.go @@ -4,6 +4,6 @@ import "gorm.io/gorm" func getUserId(db *gorm.DB, name string) int64 { var user User - db.Where("name = ?", name).First(&user) + db.Where("name = ?", name).First(&user) // $ Alert[go/examples/gorm-error-not-checked] return user.Id } diff --git a/go/ql/test/experimental/InconsistentCode/GORMErrorNotChecked.qlref b/go/ql/test/experimental/InconsistentCode/GORMErrorNotChecked.qlref index b52256ad539..20b8106442b 100644 --- a/go/ql/test/experimental/InconsistentCode/GORMErrorNotChecked.qlref +++ b/go/ql/test/experimental/InconsistentCode/GORMErrorNotChecked.qlref @@ -1 +1,2 @@ -experimental/InconsistentCode/GORMErrorNotChecked.ql +query: experimental/InconsistentCode/GORMErrorNotChecked.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/experimental/InconsistentCode/test.go b/go/ql/test/experimental/InconsistentCode/test.go index 1dc64350bd4..ec893a14e74 100644 --- a/go/ql/test/experimental/InconsistentCode/test.go +++ b/go/ql/test/experimental/InconsistentCode/test.go @@ -3,24 +3,24 @@ package main func test() { var xs []int for _ = range xs { - defer test() // not ok + defer test() // $ Alert[go/examples/deferinloop] // not ok } for _ = range xs { if true { - defer test() // not ok + defer test() // $ Alert[go/examples/deferinloop] // not ok } } for i := 0; i < 10; i++ { - defer test() + defer test() // $ Alert[go/examples/deferinloop] } for true { - defer test() // not ok + defer test() // $ Alert[go/examples/deferinloop] // not ok } for false { - defer test() // fine but caught + defer test() // $ Alert[go/examples/deferinloop] // fine but caught } } diff --git a/go/ql/test/experimental/Unsafe/WrongUsageOfUnsafe.expected b/go/ql/test/experimental/Unsafe/WrongUsageOfUnsafe.expected index 3c7e02eea26..0dfdf1d7c15 100644 --- a/go/ql/test/experimental/Unsafe/WrongUsageOfUnsafe.expected +++ b/go/ql/test/experimental/Unsafe/WrongUsageOfUnsafe.expected @@ -1,3 +1,15 @@ +#select +| WrongUsageOfUnsafe.go:77:16:77:55 | type conversion | WrongUsageOfUnsafe.go:77:27:77:54 | type conversion | WrongUsageOfUnsafe.go:77:16:77:55 | type conversion | $@. | WrongUsageOfUnsafe.go:77:27:77:54 | type conversion | Dangerous array type casting to [8]uint8 from an index expression ([8]uint8)[2] (the destination type is 2 elements longer) | +| WrongUsageOfUnsafe.go:111:16:111:59 | type conversion | WrongUsageOfUnsafe.go:111:31:111:58 | type conversion | WrongUsageOfUnsafe.go:111:16:111:59 | type conversion | $@. | WrongUsageOfUnsafe.go:111:31:111:58 | type conversion | Dangerous array type casting to [17]uint8 from an index expression ([8]uint8)[0] (the destination type is 9 elements longer) | +| WrongUsageOfUnsafe.go:129:16:129:56 | type conversion | WrongUsageOfUnsafe.go:129:31:129:55 | type conversion | WrongUsageOfUnsafe.go:129:16:129:56 | type conversion | $@. | WrongUsageOfUnsafe.go:129:31:129:55 | type conversion | Dangerous array type casting to [17]uint8 from [8]uint8 | +| WrongUsageOfUnsafe.go:149:16:149:56 | type conversion | WrongUsageOfUnsafe.go:149:31:149:55 | type conversion | WrongUsageOfUnsafe.go:149:16:149:56 | type conversion | $@. | WrongUsageOfUnsafe.go:149:31:149:55 | type conversion | Dangerous array type casting to [17]uint8 from [8]uint8 | +| WrongUsageOfUnsafe.go:166:16:166:58 | type conversion | WrongUsageOfUnsafe.go:166:33:166:57 | type conversion | WrongUsageOfUnsafe.go:166:16:166:58 | type conversion | $@. | WrongUsageOfUnsafe.go:166:33:166:57 | type conversion | Dangerous array type casting to [17]string from [8]string | +| WrongUsageOfUnsafe.go:189:16:189:56 | type conversion | WrongUsageOfUnsafe.go:189:31:189:55 | type conversion | WrongUsageOfUnsafe.go:189:16:189:56 | type conversion | $@. | WrongUsageOfUnsafe.go:189:31:189:55 | type conversion | Dangerous type up-casting to [17]uint8 from struct type | +| WrongUsageOfUnsafe.go:211:16:211:61 | type conversion | WrongUsageOfUnsafe.go:211:31:211:60 | type conversion | WrongUsageOfUnsafe.go:211:16:211:61 | type conversion | $@. | WrongUsageOfUnsafe.go:211:31:211:60 | type conversion | Dangerous array type casting to [17]uint8 from [8]uint8 | +| WrongUsageOfUnsafe.go:243:9:243:27 | type conversion | WrongUsageOfUnsafe.go:227:31:227:55 | type conversion | WrongUsageOfUnsafe.go:243:9:243:27 | type conversion | $@. | WrongUsageOfUnsafe.go:227:31:227:55 | type conversion | Dangerous array type casting to [17]uint8 from [8]uint8 | +| WrongUsageOfUnsafe.go:256:16:256:53 | type conversion | WrongUsageOfUnsafe.go:256:28:256:52 | type conversion | WrongUsageOfUnsafe.go:256:16:256:53 | type conversion | $@. | WrongUsageOfUnsafe.go:256:28:256:52 | type conversion | Dangerous array type casting to [4]int64 from [1]int64 | +| WrongUsageOfUnsafe.go:274:16:274:50 | type conversion | WrongUsageOfUnsafe.go:274:25:274:49 | type conversion | WrongUsageOfUnsafe.go:274:16:274:50 | type conversion | $@. | WrongUsageOfUnsafe.go:274:25:274:49 | type conversion | Dangerous numeric type casting to int64 from int8 | +| WrongUsageOfUnsafe.go:292:16:292:48 | type conversion | WrongUsageOfUnsafe.go:292:23:292:47 | type conversion | WrongUsageOfUnsafe.go:292:16:292:48 | type conversion | $@. | WrongUsageOfUnsafe.go:292:23:292:47 | type conversion | Dangerous numeric type casting to int from int8 | edges | WrongUsageOfUnsafe.go:17:24:17:48 | type conversion | WrongUsageOfUnsafe.go:17:13:17:49 | type conversion | provenance | | | WrongUsageOfUnsafe.go:34:24:34:51 | type conversion | WrongUsageOfUnsafe.go:34:13:34:52 | type conversion | provenance | | @@ -48,15 +60,3 @@ nodes | WrongUsageOfUnsafe.go:292:16:292:48 | type conversion | semmle.label | type conversion | | WrongUsageOfUnsafe.go:292:23:292:47 | type conversion | semmle.label | type conversion | subpaths -#select -| WrongUsageOfUnsafe.go:77:16:77:55 | type conversion | WrongUsageOfUnsafe.go:77:27:77:54 | type conversion | WrongUsageOfUnsafe.go:77:16:77:55 | type conversion | $@. | WrongUsageOfUnsafe.go:77:27:77:54 | type conversion | Dangerous array type casting to [8]uint8 from an index expression ([8]uint8)[2] (the destination type is 2 elements longer) | -| WrongUsageOfUnsafe.go:111:16:111:59 | type conversion | WrongUsageOfUnsafe.go:111:31:111:58 | type conversion | WrongUsageOfUnsafe.go:111:16:111:59 | type conversion | $@. | WrongUsageOfUnsafe.go:111:31:111:58 | type conversion | Dangerous array type casting to [17]uint8 from an index expression ([8]uint8)[0] (the destination type is 9 elements longer) | -| WrongUsageOfUnsafe.go:129:16:129:56 | type conversion | WrongUsageOfUnsafe.go:129:31:129:55 | type conversion | WrongUsageOfUnsafe.go:129:16:129:56 | type conversion | $@. | WrongUsageOfUnsafe.go:129:31:129:55 | type conversion | Dangerous array type casting to [17]uint8 from [8]uint8 | -| WrongUsageOfUnsafe.go:149:16:149:56 | type conversion | WrongUsageOfUnsafe.go:149:31:149:55 | type conversion | WrongUsageOfUnsafe.go:149:16:149:56 | type conversion | $@. | WrongUsageOfUnsafe.go:149:31:149:55 | type conversion | Dangerous array type casting to [17]uint8 from [8]uint8 | -| WrongUsageOfUnsafe.go:166:16:166:58 | type conversion | WrongUsageOfUnsafe.go:166:33:166:57 | type conversion | WrongUsageOfUnsafe.go:166:16:166:58 | type conversion | $@. | WrongUsageOfUnsafe.go:166:33:166:57 | type conversion | Dangerous array type casting to [17]string from [8]string | -| WrongUsageOfUnsafe.go:189:16:189:56 | type conversion | WrongUsageOfUnsafe.go:189:31:189:55 | type conversion | WrongUsageOfUnsafe.go:189:16:189:56 | type conversion | $@. | WrongUsageOfUnsafe.go:189:31:189:55 | type conversion | Dangerous type up-casting to [17]uint8 from struct type | -| WrongUsageOfUnsafe.go:211:16:211:61 | type conversion | WrongUsageOfUnsafe.go:211:31:211:60 | type conversion | WrongUsageOfUnsafe.go:211:16:211:61 | type conversion | $@. | WrongUsageOfUnsafe.go:211:31:211:60 | type conversion | Dangerous array type casting to [17]uint8 from [8]uint8 | -| WrongUsageOfUnsafe.go:243:9:243:27 | type conversion | WrongUsageOfUnsafe.go:227:31:227:55 | type conversion | WrongUsageOfUnsafe.go:243:9:243:27 | type conversion | $@. | WrongUsageOfUnsafe.go:227:31:227:55 | type conversion | Dangerous array type casting to [17]uint8 from [8]uint8 | -| WrongUsageOfUnsafe.go:256:16:256:53 | type conversion | WrongUsageOfUnsafe.go:256:28:256:52 | type conversion | WrongUsageOfUnsafe.go:256:16:256:53 | type conversion | $@. | WrongUsageOfUnsafe.go:256:28:256:52 | type conversion | Dangerous array type casting to [4]int64 from [1]int64 | -| WrongUsageOfUnsafe.go:274:16:274:50 | type conversion | WrongUsageOfUnsafe.go:274:25:274:49 | type conversion | WrongUsageOfUnsafe.go:274:16:274:50 | type conversion | $@. | WrongUsageOfUnsafe.go:274:25:274:49 | type conversion | Dangerous numeric type casting to int64 from int8 | -| WrongUsageOfUnsafe.go:292:16:292:48 | type conversion | WrongUsageOfUnsafe.go:292:23:292:47 | type conversion | WrongUsageOfUnsafe.go:292:16:292:48 | type conversion | $@. | WrongUsageOfUnsafe.go:292:23:292:47 | type conversion | Dangerous numeric type casting to int from int8 | diff --git a/go/ql/test/experimental/Unsafe/WrongUsageOfUnsafe.go b/go/ql/test/experimental/Unsafe/WrongUsageOfUnsafe.go index 8599550039a..f20b7289589 100644 --- a/go/ql/test/experimental/Unsafe/WrongUsageOfUnsafe.go +++ b/go/ql/test/experimental/Unsafe/WrongUsageOfUnsafe.go @@ -74,7 +74,7 @@ func badIndexExpr() { // the address of the 3rd element of the `harmless` array, // and continue for 8 bytes, going out of the boundaries of // `harmless` and crossing into the memory occupied by `secret`. - var leaking = (*[8]byte)(unsafe.Pointer(&harmless[2])) // BAD + var leaking = (*[8]byte)(unsafe.Pointer(&harmless[2])) // $ Alert // BAD fmt.Println(string((*leaking)[:])) @@ -108,7 +108,7 @@ func bad0() { // Read before secret, overflowing into secret // (notice we get the pointer to the first byte of harmless) - var leaking = (*[8 + 9]byte)(unsafe.Pointer(&harmless[0])) // BAD + var leaking = (*[8 + 9]byte)(unsafe.Pointer(&harmless[0])) // $ Alert // BAD fmt.Println(string((*leaking)[:])) @@ -126,7 +126,7 @@ func bad1() { // Read before secret, overflowing into secret // (notice we read more than the length of harmless) - var leaking = (*[8 + 9]byte)(unsafe.Pointer(&harmless)) // BAD + var leaking = (*[8 + 9]byte)(unsafe.Pointer(&harmless)) // $ Alert // BAD fmt.Println(string((*leaking)[:])) @@ -146,7 +146,7 @@ func bad2() { // Read before secret, overflowing into secret // (notice we read more than the length of harmless) - var leaking = (*[8 + 9]byte)(unsafe.Pointer(&harmless)) // BAD + var leaking = (*[8 + 9]byte)(unsafe.Pointer(&harmless)) // $ Alert // BAD fmt.Println(string((*leaking)[:])) @@ -163,7 +163,7 @@ func bad3() { // Read before secret, overflowing into secret // (notice we read more than the length of harmless) - var leaking = (*[8 + 9]string)(unsafe.Pointer(&harmless)) // BAD + var leaking = (*[8 + 9]string)(unsafe.Pointer(&harmless)) // $ Alert // BAD fmt.Println(*leaking) fmt.Println([17]string((*leaking))) @@ -186,7 +186,7 @@ func bad4() { // Read before secret, overflowing into secret // (notice we read more than the length of harmless) - var leaking = (*[8 + 9]byte)(unsafe.Pointer(&harmless)) // BAD + var leaking = (*[8 + 9]byte)(unsafe.Pointer(&harmless)) // $ Alert // BAD fmt.Println(string((*leaking)[:])) @@ -208,7 +208,7 @@ func bad5() { // Read before secret, overflowing into secret // (notice we read more than the length of harmless) - var leaking = (*[8 + 9]byte)(unsafe.Pointer(&harmless.Data)) // BAD + var leaking = (*[8 + 9]byte)(unsafe.Pointer(&harmless.Data)) // $ Alert // BAD fmt.Println(string(leaking[:])) @@ -224,7 +224,7 @@ func bad6() { secret := [9]byte{'s', 'e', 'n', 's', 'i', 't', 'i', 'v', 'e'} // Read before secret: - var leaking = buffer_request(unsafe.Pointer(&harmless)) // BAD (see inside buffer_request func) + var leaking = buffer_request(unsafe.Pointer(&harmless)) // $ Source // BAD (see inside buffer_request func) fmt.Println((string)(leaking[:])) @@ -240,7 +240,7 @@ func buffer_request(req unsafe.Pointer) [8 + 9]byte { // will be read, the read will also contain pieces of // data from `secret`. var buf [8 + 9]byte - buf = *(*[8 + 9]byte)(req) // BAD (from above func) + buf = *(*[8 + 9]byte)(req) // $ Alert // BAD (from above func) return buf } func bad7() { @@ -253,7 +253,7 @@ func bad7() { // (notice we read more than the length of harmless); // the leaking array will not contain letters, // but integers representing bytes from `secret`. - var leaking = (*[4]int64)(unsafe.Pointer(&harmless)) // BAD + var leaking = (*[4]int64)(unsafe.Pointer(&harmless)) // $ Alert // BAD fmt.Println(*leaking) @@ -271,7 +271,7 @@ func bad8() { // Read before secret, overflowing into secret // (notice we read more than the length of harmless); // the leaking data will contain some bits from `secret`. - var leaking = (*int64)(unsafe.Pointer(&harmless)) // BAD + var leaking = (*int64)(unsafe.Pointer(&harmless)) // $ Alert // BAD fmt.Println(*leaking) @@ -289,7 +289,7 @@ func bad9() { // Read before secret, overflowing into secret // (notice we read more than the length of harmless); // the leaking data will contain some bits from `secret`. - var leaking = (*int)(unsafe.Pointer(&harmless)) // BAD + var leaking = (*int)(unsafe.Pointer(&harmless)) // $ Alert // BAD fmt.Println(*leaking) diff --git a/go/ql/test/experimental/Unsafe/WrongUsageOfUnsafe.qlref b/go/ql/test/experimental/Unsafe/WrongUsageOfUnsafe.qlref index 2f5c54707c7..5496859ca2e 100644 --- a/go/ql/test/experimental/Unsafe/WrongUsageOfUnsafe.qlref +++ b/go/ql/test/experimental/Unsafe/WrongUsageOfUnsafe.qlref @@ -1 +1,2 @@ -experimental/Unsafe/WrongUsageOfUnsafe.ql +query: experimental/Unsafe/WrongUsageOfUnsafe.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/library-tests/semmle/go/frameworks/BeegoOrm/SqlInjection.qlref b/go/ql/test/library-tests/semmle/go/frameworks/BeegoOrm/SqlInjection.qlref index b6916bd2cd4..e1918157744 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/BeegoOrm/SqlInjection.qlref +++ b/go/ql/test/library-tests/semmle/go/frameworks/BeegoOrm/SqlInjection.qlref @@ -1,2 +1,4 @@ query: Security/CWE-089/SqlInjection.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/library-tests/semmle/go/frameworks/BeegoOrm/StoredXss.qlref b/go/ql/test/library-tests/semmle/go/frameworks/BeegoOrm/StoredXss.qlref index 66b7d67dd8f..f47ad25ca9c 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/BeegoOrm/StoredXss.qlref +++ b/go/ql/test/library-tests/semmle/go/frameworks/BeegoOrm/StoredXss.qlref @@ -1,2 +1,4 @@ query: Security/CWE-079/StoredXss.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/library-tests/semmle/go/frameworks/BeegoOrm/test.go b/go/ql/test/library-tests/semmle/go/frameworks/BeegoOrm/test.go index cce152e57ef..5dacd494c05 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/BeegoOrm/test.go +++ b/go/ql/test/library-tests/semmle/go/frameworks/BeegoOrm/test.go @@ -8,61 +8,61 @@ import ( // BAD: using untrusted data in SQL queries func testDbMethods(bdb *orm.DB, untrustedSource *http.Request) { - untrusted := untrustedSource.UserAgent() + untrusted := untrustedSource.UserAgent() // $ Source[go/sql-injection] - bdb.Exec(untrusted) // $ querystring=untrusted - bdb.ExecContext(nil, untrusted) // $ querystring=untrusted - bdb.Prepare(untrusted) // $ querystring=untrusted - bdb.PrepareContext(nil, untrusted) // $ querystring=untrusted - bdb.Query(untrusted) // $ querystring=untrusted - bdb.QueryContext(nil, untrusted) // $ querystring=untrusted - bdb.QueryRow(untrusted) // $ querystring=untrusted - bdb.QueryRowContext(nil, untrusted) // $ querystring=untrusted + bdb.Exec(untrusted) // $ querystring=untrusted Alert[go/sql-injection] + bdb.ExecContext(nil, untrusted) // $ querystring=untrusted Alert[go/sql-injection] + bdb.Prepare(untrusted) // $ querystring=untrusted Alert[go/sql-injection] + bdb.PrepareContext(nil, untrusted) // $ querystring=untrusted Alert[go/sql-injection] + bdb.Query(untrusted) // $ querystring=untrusted Alert[go/sql-injection] + bdb.QueryContext(nil, untrusted) // $ querystring=untrusted Alert[go/sql-injection] + bdb.QueryRow(untrusted) // $ querystring=untrusted Alert[go/sql-injection] + bdb.QueryRowContext(nil, untrusted) // $ querystring=untrusted Alert[go/sql-injection] } // BAD: using untrusted data to build SQL queries (QueryBuilder does not sanitize its arguments) func testQueryBuilderMethods(qb orm.QueryBuilder, untrustedSource *http.Request) { - untrusted := untrustedSource.UserAgent() - untrusted2 := untrustedSource.UserAgent() + untrusted := untrustedSource.UserAgent() // $ Source[go/sql-injection] + untrusted2 := untrustedSource.UserAgent() // $ Source[go/sql-injection] - qb.Select(untrusted) // $ querystring=untrusted - qb.From(untrusted) // $ querystring=untrusted - qb.InnerJoin(untrusted) // $ querystring=untrusted - qb.LeftJoin(untrusted) // $ querystring=untrusted - qb.RightJoin(untrusted) // $ querystring=untrusted - qb.On(untrusted) // $ querystring=untrusted - qb.Where(untrusted) // $ querystring=untrusted - qb.And(untrusted) // $ querystring=untrusted - qb.Or(untrusted) // $ querystring=untrusted - qb.In(untrusted) // $ querystring=untrusted - qb.OrderBy(untrusted) // $ querystring=untrusted - qb.GroupBy(untrusted) // $ querystring=untrusted - qb.Having(untrusted) // $ querystring=untrusted - qb.Update(untrusted) // $ querystring=untrusted - qb.Set(untrusted) // $ querystring=untrusted - qb.Delete(untrusted) // $ querystring=untrusted - qb.InsertInto(untrusted, untrusted2) // $ querystring=untrusted querystring=untrusted2 - qb.Values(untrusted) // $ querystring=untrusted - qb.Subquery(untrusted, untrusted2) // $ querystring=untrusted querystring=untrusted2 + qb.Select(untrusted) // $ querystring=untrusted Alert[go/sql-injection] + qb.From(untrusted) // $ querystring=untrusted Alert[go/sql-injection] + qb.InnerJoin(untrusted) // $ querystring=untrusted Alert[go/sql-injection] + qb.LeftJoin(untrusted) // $ querystring=untrusted Alert[go/sql-injection] + qb.RightJoin(untrusted) // $ querystring=untrusted Alert[go/sql-injection] + qb.On(untrusted) // $ querystring=untrusted Alert[go/sql-injection] + qb.Where(untrusted) // $ querystring=untrusted Alert[go/sql-injection] + qb.And(untrusted) // $ querystring=untrusted Alert[go/sql-injection] + qb.Or(untrusted) // $ querystring=untrusted Alert[go/sql-injection] + qb.In(untrusted) // $ querystring=untrusted Alert[go/sql-injection] + qb.OrderBy(untrusted) // $ querystring=untrusted Alert[go/sql-injection] + qb.GroupBy(untrusted) // $ querystring=untrusted Alert[go/sql-injection] + qb.Having(untrusted) // $ querystring=untrusted Alert[go/sql-injection] + qb.Update(untrusted) // $ querystring=untrusted Alert[go/sql-injection] + qb.Set(untrusted) // $ querystring=untrusted Alert[go/sql-injection] + qb.Delete(untrusted) // $ querystring=untrusted Alert[go/sql-injection] + qb.InsertInto(untrusted, untrusted2) // $ querystring=untrusted querystring=untrusted2 Alert[go/sql-injection] + qb.Values(untrusted) // $ querystring=untrusted Alert[go/sql-injection] + qb.Subquery(untrusted, untrusted2) // $ querystring=untrusted querystring=untrusted2 Alert[go/sql-injection] } func testOrmerRaw(ormer orm.Ormer, untrustedSource *http.Request) { - untrusted := untrustedSource.UserAgent() + untrusted := untrustedSource.UserAgent() // $ Source[go/sql-injection] untrusted2 := untrustedSource.UserAgent() - ormer.Raw(untrusted, untrusted2) // $ querystring=untrusted // BAD: using an untrusted string as a query + ormer.Raw(untrusted, untrusted2) // $ querystring=untrusted Alert[go/sql-injection] // BAD: using an untrusted string as a query ormer.Raw("FROM ? SELECT ?", untrusted, untrusted2) // $ querystring="FROM ? SELECT ?" // GOOD: untrusted string used in argument context } func testFilterRaw(querySeter orm.QuerySeter, untrustedSource *http.Request) { - untrusted := untrustedSource.UserAgent() - querySeter.FilterRaw(untrusted, "safe") // $ querystring="safe" // GOOD: untrusted used as a column name - querySeter.FilterRaw("safe", untrusted) // $ querystring=untrusted // BAD: untrusted used as a SQL fragment + untrusted := untrustedSource.UserAgent() // $ Source[go/sql-injection] + querySeter.FilterRaw(untrusted, "safe") // $ querystring="safe" // GOOD: untrusted used as a column name + querySeter.FilterRaw("safe", untrusted) // $ querystring=untrusted Alert[go/sql-injection] // BAD: untrusted used as a SQL fragment } func testConditionRaw(cond orm.Condition, untrustedSource *http.Request) { - untrusted := untrustedSource.UserAgent() - cond.Raw(untrusted, "safe") // $ querystring="safe" // GOOD: untrusted used as a column name - cond.Raw("safe", untrusted) // $ querystring=untrusted // BAD: untrusted used as a SQL fragment + untrusted := untrustedSource.UserAgent() // $ Source[go/sql-injection] + cond.Raw(untrusted, "safe") // $ querystring="safe" // GOOD: untrusted used as a column name + cond.Raw("safe", untrusted) // $ querystring=untrusted Alert[go/sql-injection] // BAD: untrusted used as a SQL fragment } type SubStruct struct { @@ -77,90 +77,90 @@ type MyStruct struct { // BAD: (possible stored XSS) retrieving data from a database then writing to an HTTP response func testOrmerReads(ormer orm.Ormer, sink http.ResponseWriter) { obj := MyStruct{} - ormer.Read(&obj) - sink.Write([]byte(obj.field)) - sink.Write([]byte(obj.substructs[0].field)) + ormer.Read(&obj) // $ Source[go/stored-xss] + sink.Write([]byte(obj.field)) // $ Alert[go/stored-xss] + sink.Write([]byte(obj.substructs[0].field)) // $ Alert[go/stored-xss] obj2 := MyStruct{} - ormer.ReadForUpdate(&obj2) - sink.Write([]byte(obj2.field)) + ormer.ReadForUpdate(&obj2) // $ Source[go/stored-xss] + sink.Write([]byte(obj2.field)) // $ Alert[go/stored-xss] obj3 := MyStruct{} - ormer.ReadOrCreate(&obj3, "arg") - sink.Write([]byte(obj3.field)) + ormer.ReadOrCreate(&obj3, "arg") // $ Source[go/stored-xss] + sink.Write([]byte(obj3.field)) // $ Alert[go/stored-xss] } // BAD: (possible stored XSS) retrieving data from a database then writing to an HTTP response func testFieldReads(textField *orm.TextField, jsonField *orm.JSONField, jsonbField *orm.JsonbField, sink http.ResponseWriter) { - sink.Write([]byte(textField.Value())) - sink.Write([]byte(textField.RawValue().(string))) - sink.Write([]byte(textField.String())) - sink.Write([]byte(jsonField.Value())) - sink.Write([]byte(jsonField.RawValue().(string))) - sink.Write([]byte(jsonField.String())) - sink.Write([]byte(jsonbField.Value())) - sink.Write([]byte(jsonbField.RawValue().(string))) - sink.Write([]byte(jsonbField.String())) + sink.Write([]byte(textField.Value())) // $ Alert[go/stored-xss] + sink.Write([]byte(textField.RawValue().(string))) // $ Alert[go/stored-xss] + sink.Write([]byte(textField.String())) // $ Alert[go/stored-xss] + sink.Write([]byte(jsonField.Value())) // $ Alert[go/stored-xss] + sink.Write([]byte(jsonField.RawValue().(string))) // $ Alert[go/stored-xss] + sink.Write([]byte(jsonField.String())) // $ Alert[go/stored-xss] + sink.Write([]byte(jsonbField.Value())) // $ Alert[go/stored-xss] + sink.Write([]byte(jsonbField.RawValue().(string))) // $ Alert[go/stored-xss] + sink.Write([]byte(jsonbField.String())) // $ Alert[go/stored-xss] } // BAD: (possible stored XSS) retrieving data from a database then writing to an HTTP response func testQuerySeterReads(qs orm.QuerySeter, sink http.ResponseWriter) { var objs []*MyStruct - qs.All(&objs) - sink.Write([]byte(objs[0].field)) + qs.All(&objs) // $ Source[go/stored-xss] + sink.Write([]byte(objs[0].field)) // $ Alert[go/stored-xss] var obj MyStruct - qs.One(&obj) - sink.Write([]byte(obj.field)) + qs.One(&obj) // $ Source[go/stored-xss] + sink.Write([]byte(obj.field)) // $ Alert[go/stored-xss] var allMaps []orm.Params - qs.Values(&allMaps) - sink.Write([]byte(allMaps[0]["field"].(string))) + qs.Values(&allMaps) // $ Source[go/stored-xss] + sink.Write([]byte(allMaps[0]["field"].(string))) // $ Alert[go/stored-xss] var allLists []orm.ParamsList - qs.ValuesList(&allLists) - sink.Write([]byte(allLists[0][0].(string))) + qs.ValuesList(&allLists) // $ Source[go/stored-xss] + sink.Write([]byte(allLists[0][0].(string))) // $ Alert[go/stored-xss] var oneList orm.ParamsList - qs.ValuesFlat(&oneList, "colname") - sink.Write([]byte(oneList[0].(string))) + qs.ValuesFlat(&oneList, "colname") // $ Source[go/stored-xss] + sink.Write([]byte(oneList[0].(string))) // $ Alert[go/stored-xss] var oneRowMap orm.Params - qs.RowsToMap(&oneRowMap, "key", "value") - sink.Write([]byte(oneRowMap["field"].(string))) + qs.RowsToMap(&oneRowMap, "key", "value") // $ Source[go/stored-xss] + sink.Write([]byte(oneRowMap["field"].(string))) // $ Alert[go/stored-xss] var oneRowStruct MyStruct - qs.RowsToStruct(&oneRowStruct, "key", "value") - sink.Write([]byte(oneRowStruct.field)) + qs.RowsToStruct(&oneRowStruct, "key", "value") // $ Source[go/stored-xss] + sink.Write([]byte(oneRowStruct.field)) // $ Alert[go/stored-xss] } // BAD: (possible stored XSS) retrieving data from a database then writing to an HTTP response func testRawSeterReads(rs orm.RawSeter, sink http.ResponseWriter) { var allMaps []orm.Params - rs.Values(&allMaps) - sink.Write([]byte(allMaps[0]["field"].(string))) + rs.Values(&allMaps) // $ Source[go/stored-xss] + sink.Write([]byte(allMaps[0]["field"].(string))) // $ Alert[go/stored-xss] var allLists []orm.ParamsList - rs.ValuesList(&allLists) - sink.Write([]byte(allLists[0][0].(string))) + rs.ValuesList(&allLists) // $ Source[go/stored-xss] + sink.Write([]byte(allLists[0][0].(string))) // $ Alert[go/stored-xss] var oneList orm.ParamsList - rs.ValuesFlat(&oneList, "colname") - sink.Write([]byte(oneList[0].(string))) + rs.ValuesFlat(&oneList, "colname") // $ Source[go/stored-xss] + sink.Write([]byte(oneList[0].(string))) // $ Alert[go/stored-xss] var oneRowMap orm.Params - rs.RowsToMap(&oneRowMap, "key", "value") - sink.Write([]byte(oneRowMap["field"].(string))) + rs.RowsToMap(&oneRowMap, "key", "value") // $ Source[go/stored-xss] + sink.Write([]byte(oneRowMap["field"].(string))) // $ Alert[go/stored-xss] var oneRowStruct MyStruct - rs.RowsToStruct(&oneRowStruct, "key", "value") - sink.Write([]byte(oneRowStruct.field)) + rs.RowsToStruct(&oneRowStruct, "key", "value") // $ Source[go/stored-xss] + sink.Write([]byte(oneRowStruct.field)) // $ Alert[go/stored-xss] var strField string - rs.QueryRow(&strField) - sink.Write([]byte(strField)) + rs.QueryRow(&strField) // $ Source[go/stored-xss] + sink.Write([]byte(strField)) // $ Alert[go/stored-xss] var strFields []string - rs.QueryRows(&strFields) - sink.Write([]byte(strFields[0])) + rs.QueryRows(&strFields) // $ Source[go/stored-xss] + sink.Write([]byte(strFields[0])) // $ Alert[go/stored-xss] } diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Chi/ReflectedXss.qlref b/go/ql/test/library-tests/semmle/go/frameworks/Chi/ReflectedXss.qlref index 754513d72bb..e6b791f39fc 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Chi/ReflectedXss.qlref +++ b/go/ql/test/library-tests/semmle/go/frameworks/Chi/ReflectedXss.qlref @@ -1,2 +1,4 @@ query: Security/CWE-079/ReflectedXss.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Chi/test.go b/go/ql/test/library-tests/semmle/go/frameworks/Chi/test.go index f02e0cdfb15..aeb33fe8af0 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Chi/test.go +++ b/go/ql/test/library-tests/semmle/go/frameworks/Chi/test.go @@ -10,7 +10,7 @@ var hidden string func hideUserData(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - hidden = r.URL.Path + hidden = r.URL.Path // $ Source next.ServeHTTP(w, r) }) } @@ -18,10 +18,10 @@ func hideUserData(next http.Handler) http.Handler { func main() { r := chi.NewRouter() r.With(hideUserData).Get("/", func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte(hidden)) - w.Write([]byte(chi.URLParam(r, "someParam"))) - w.Write([]byte(chi.URLParamFromCtx(r.Context(), "someKey"))) - w.Write([]byte(chi.RouteContext(r.Context()).URLParam("someOtherKey"))) + w.Write([]byte(hidden)) // $ Alert + w.Write([]byte(chi.URLParam(r, "someParam"))) // $ Alert + w.Write([]byte(chi.URLParamFromCtx(r.Context(), "someKey"))) // $ Alert + w.Write([]byte(chi.RouteContext(r.Context()).URLParam("someOtherKey"))) // $ Alert }) http.ListenAndServe(":3000", r) } diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Echo/OpenRedirect.qlref b/go/ql/test/library-tests/semmle/go/frameworks/Echo/OpenRedirect.qlref index 867dd766561..13add930f51 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Echo/OpenRedirect.qlref +++ b/go/ql/test/library-tests/semmle/go/frameworks/Echo/OpenRedirect.qlref @@ -1,2 +1,4 @@ query: Security/CWE-601/OpenUrlRedirect.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Echo/ReflectedXss.qlref b/go/ql/test/library-tests/semmle/go/frameworks/Echo/ReflectedXss.qlref index 754513d72bb..e6b791f39fc 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Echo/ReflectedXss.qlref +++ b/go/ql/test/library-tests/semmle/go/frameworks/Echo/ReflectedXss.qlref @@ -1,2 +1,4 @@ query: Security/CWE-079/ReflectedXss.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Echo/TaintedPath.qlref b/go/ql/test/library-tests/semmle/go/frameworks/Echo/TaintedPath.qlref index 78ce25b1921..6eb2e94892f 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Echo/TaintedPath.qlref +++ b/go/ql/test/library-tests/semmle/go/frameworks/Echo/TaintedPath.qlref @@ -1,2 +1,4 @@ query: Security/CWE-022/TaintedPath.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Echo/test.go b/go/ql/test/library-tests/semmle/go/frameworks/Echo/test.go index 4a9f4e161f6..2435d91c6d7 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Echo/test.go +++ b/go/ql/test/library-tests/semmle/go/frameworks/Echo/test.go @@ -12,81 +12,81 @@ import ( // All are XSS vulnerabilities, except as specifically noted. func testParam(ctx echo.Context) error { - param := ctx.Param("someParam") - ctx.HTML(200, param) + param := ctx.Param("someParam") // $ Source[go/reflected-xss] + ctx.HTML(200, param) // $ Alert[go/reflected-xss] return nil } func testParamValues(ctx echo.Context) error { - param := ctx.ParamValues()[0] - ctx.HTML(200, param) + param := ctx.ParamValues()[0] // $ Source[go/reflected-xss] + ctx.HTML(200, param) // $ Alert[go/reflected-xss] return nil } func testQueryParam(ctx echo.Context) error { - param := ctx.QueryParam("someParam") - ctx.HTML(200, param) + param := ctx.QueryParam("someParam") // $ Source[go/reflected-xss] + ctx.HTML(200, param) // $ Alert[go/reflected-xss] return nil } func testQueryParams(ctx echo.Context) error { - param := ctx.QueryParams()["someParam"][0] - ctx.HTML(200, param) + param := ctx.QueryParams()["someParam"][0] // $ Source[go/reflected-xss] + ctx.HTML(200, param) // $ Alert[go/reflected-xss] return nil } func testQueryString(ctx echo.Context) error { - qstr := ctx.QueryString() - ctx.HTML(200, qstr) + qstr := ctx.QueryString() // $ Source[go/reflected-xss] + ctx.HTML(200, qstr) // $ Alert[go/reflected-xss] return nil } func testFormValue(ctx echo.Context) error { - val := ctx.FormValue("someField") - ctx.HTML(200, val) + val := ctx.FormValue("someField") // $ Source[go/reflected-xss] + ctx.HTML(200, val) // $ Alert[go/reflected-xss] return nil } func testFormParams(ctx echo.Context) error { - params, _ := ctx.FormParams() - ctx.HTML(200, params["someField"][0]) + params, _ := ctx.FormParams() // $ Source[go/reflected-xss] + ctx.HTML(200, params["someField"][0]) // $ Alert[go/reflected-xss] return nil } func testFormFile(ctx echo.Context) error { - fileHeader, _ := ctx.FormFile("someFilename") + fileHeader, _ := ctx.FormFile("someFilename") // $ Source[go/reflected-xss] file, _ := fileHeader.Open() buffer := make([]byte, 100) file.Read(buffer) - ctx.HTMLBlob(200, buffer) + ctx.HTMLBlob(200, buffer) // $ Alert[go/reflected-xss] return nil } func testMultipartFormValue(ctx echo.Context) error { - form, _ := ctx.MultipartForm() - ctx.HTML(200, form.Value["someField"][0]) + form, _ := ctx.MultipartForm() // $ Source[go/reflected-xss] + ctx.HTML(200, form.Value["someField"][0]) // $ Alert[go/reflected-xss] return nil } func testMultipartFormFile(ctx echo.Context) error { - form, _ := ctx.MultipartForm() + form, _ := ctx.MultipartForm() // $ Source[go/reflected-xss] fileHeader := form.File["someFilename"][0] file, _ := fileHeader.Open() buffer := make([]byte, 100) file.Read(buffer) - ctx.HTMLBlob(200, buffer) + ctx.HTMLBlob(200, buffer) // $ Alert[go/reflected-xss] return nil } func testCookie(ctx echo.Context) error { - val, _ := ctx.Cookie("someKey") - ctx.HTML(200, val.Value) + val, _ := ctx.Cookie("someKey") // $ Source[go/reflected-xss] + ctx.HTML(200, val.Value) // $ Alert[go/reflected-xss] return nil } func testCookies(ctx echo.Context) error { - cookies := ctx.Cookies() - ctx.HTML(200, cookies[0].Value) + cookies := ctx.Cookies() // $ Source[go/reflected-xss] + ctx.HTML(200, cookies[0].Value) // $ Alert[go/reflected-xss] return nil } @@ -96,8 +96,8 @@ type myStruct struct { func testBind(ctx echo.Context) error { data := myStruct{} - ctx.Bind(&data) - ctx.HTML(200, data.s) + ctx.Bind(&data) // $ Source[go/reflected-xss] + ctx.HTML(200, data.s) // $ Alert[go/reflected-xss] return nil } @@ -110,8 +110,8 @@ func testGetSetEmpty(ctx echo.Context) error { } func testGetSet(ctx echo.Context) error { - ctx.Set("someKey", ctx.Param("someParam")) - ctx.HTML(200, ctx.Get("someKey").(string)) // BAD, the context is tainted + ctx.Set("someKey", ctx.Param("someParam")) // $ Source[go/reflected-xss] + ctx.HTML(200, ctx.Get("someKey").(string)) // $ Alert[go/reflected-xss] // BAD, the context is tainted return nil } @@ -121,20 +121,20 @@ func testGetSet(ctx echo.Context) error { // All are XSS vulnerabilities, except as specifically noted. func testHTML(ctx echo.Context) error { - param := ctx.Param("someParam") - ctx.HTML(200, param) + param := ctx.Param("someParam") // $ Source[go/reflected-xss] + ctx.HTML(200, param) // $ Alert[go/reflected-xss] return nil } func testHTMLBlob(ctx echo.Context) error { - param := ctx.Param("someParam") - ctx.HTMLBlob(200, []byte(param)) + param := ctx.Param("someParam") // $ Source[go/reflected-xss] + ctx.HTMLBlob(200, []byte(param)) // $ Alert[go/reflected-xss] return nil } func testBlob(ctx echo.Context) error { - param := ctx.Param("someParam") - ctx.Blob(200, "text/html", []byte(param)) // BAD, the content-type is HTML + param := ctx.Param("someParam") // $ Source[go/reflected-xss] + ctx.Blob(200, "text/html", []byte(param)) // $ Alert[go/reflected-xss] // BAD, the content-type is HTML return nil } @@ -145,9 +145,9 @@ func testBlobSafe(ctx echo.Context) error { } func testStream(ctx echo.Context) error { - param := ctx.Param("someParam") + param := ctx.Param("someParam") // $ Source[go/reflected-xss] reader := strings.NewReader(param) - ctx.Stream(200, "text/html", reader) // BAD, the content-type is HTML + ctx.Stream(200, "text/html", reader) // $ Alert[go/reflected-xss] // BAD, the content-type is HTML return nil } @@ -161,28 +161,28 @@ func testStreamSafe(ctx echo.Context) error { // Section: testing output methods defined on Response (XSS vulnerability) func testResponseWrite(ctx echo.Context) error { - param := ctx.Param("someParam") - ctx.Response().Write([]byte(param)) + param := ctx.Param("someParam") // $ Source[go/reflected-xss] + ctx.Response().Write([]byte(param)) // $ Alert[go/reflected-xss] return nil } // Section: test detecting an open redirect using the Context.Redirect function: func testRedirect(ctx echo.Context) error { - param := ctx.Param("someParam") - ctx.Redirect(301, param) + param := ctx.Param("someParam") // $ Source[go/unvalidated-url-redirection] + ctx.Redirect(301, param) // $ Alert[go/unvalidated-url-redirection] return nil } func testLocalRedirects(ctx echo.Context) error { - param := ctx.Param("someParam") + param := ctx.Param("someParam") // $ Source[go/unvalidated-url-redirection] param2 := param param3 := param // Gratuitous copy because sanitization of uses propagates to subsequent uses // GOOD: local redirects are unproblematic ctx.Redirect(301, "/local"+param) // BAD: this could be a non-local redirect - ctx.Redirect(301, "/"+param2) + ctx.Redirect(301, "/"+param2) // $ Alert[go/unvalidated-url-redirection] // GOOD: localhost redirects are unproblematic ctx.Redirect(301, "//localhost/"+param3) return nil @@ -221,12 +221,12 @@ func testNonExploitableFields(ctx echo.Context) error { func fsOpsTest() { e := echo.New() e.GET("/", func(c echo.Context) error { - filepath := c.QueryParam("filePath") - return c.File(filepath) // $ FileSystemAccess=filepath + filepath := c.QueryParam("filePath") // $ Source[go/path-injection] + return c.File(filepath) // $ FileSystemAccess=filepath Alert[go/path-injection] }) e.GET("/attachment", func(c echo.Context) error { - filepath := c.QueryParam("filePath") - return c.Attachment(filepath, "file name in response") // $ FileSystemAccess=filepath + filepath := c.QueryParam("filePath") // $ Source[go/path-injection] + return c.Attachment(filepath, "file name in response") // $ FileSystemAccess=filepath Alert[go/path-injection] }) _ = e.Start(":1323") } diff --git a/go/ql/test/library-tests/semmle/go/frameworks/GoMicro/LogInjection.expected b/go/ql/test/library-tests/semmle/go/frameworks/GoMicro/LogInjection.expected index 703066d6449..4ec65220a52 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/GoMicro/LogInjection.expected +++ b/go/ql/test/library-tests/semmle/go/frameworks/GoMicro/LogInjection.expected @@ -1,8 +1,8 @@ +#select +| main.go:21:28:21:31 | name | main.go:18:46:18:48 | definition of req | main.go:21:28:21:31 | name | This log entry depends on a $@. | main.go:18:46:18:48 | definition of req | user-provided value | edges | main.go:18:46:18:48 | definition of req | main.go:21:28:21:31 | name | provenance | | nodes | main.go:18:46:18:48 | definition of req | semmle.label | definition of req | | main.go:21:28:21:31 | name | semmle.label | name | subpaths -#select -| main.go:21:28:21:31 | name | main.go:18:46:18:48 | definition of req | main.go:21:28:21:31 | name | This log entry depends on a $@. | main.go:18:46:18:48 | definition of req | user-provided value | diff --git a/go/ql/test/library-tests/semmle/go/frameworks/GoMicro/LogInjection.qlref b/go/ql/test/library-tests/semmle/go/frameworks/GoMicro/LogInjection.qlref index 1837c628c33..fc8a61c453d 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/GoMicro/LogInjection.qlref +++ b/go/ql/test/library-tests/semmle/go/frameworks/GoMicro/LogInjection.qlref @@ -1 +1,2 @@ -Security/CWE-117/LogInjection.ql +query: Security/CWE-117/LogInjection.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/library-tests/semmle/go/frameworks/GoMicro/main.go b/go/ql/test/library-tests/semmle/go/frameworks/GoMicro/main.go index 3eaacef9822..5acaded1e7a 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/GoMicro/main.go +++ b/go/ql/test/library-tests/semmle/go/frameworks/GoMicro/main.go @@ -15,10 +15,10 @@ import ( type Greeter struct{} -func (g *Greeter) Hello(ctx context.Context, req *pb.Request, rsp *pb.Response) error { // $ serverRequest="definition of req" +func (g *Greeter) Hello(ctx context.Context, req *pb.Request, rsp *pb.Response) error { // $ serverRequest="definition of req" Source // var access name := req.Name - fmt.Println("Name :: %s", name) + fmt.Println("Name :: %s", name) // $ Alert return nil } diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Revel/CONSISTENCY/DataFlowConsistency.expected b/go/ql/test/library-tests/semmle/go/frameworks/Revel/CONSISTENCY/DataFlowConsistency.expected index 0fd726cd886..999379f9298 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Revel/CONSISTENCY/DataFlowConsistency.expected +++ b/go/ql/test/library-tests/semmle/go/frameworks/Revel/CONSISTENCY/DataFlowConsistency.expected @@ -1,28 +1,28 @@ reverseRead -| EndToEnd.go:30:35:30:35 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | -| EndToEnd.go:30:35:30:42 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | -| EndToEnd.go:36:18:36:18 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | -| EndToEnd.go:36:18:36:25 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | -| EndToEnd.go:44:18:44:18 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | -| EndToEnd.go:44:18:44:25 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | -| EndToEnd.go:51:20:51:20 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | -| EndToEnd.go:51:20:51:27 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | -| EndToEnd.go:58:18:58:18 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | -| EndToEnd.go:58:18:58:25 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | -| EndToEnd.go:64:26:64:26 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | -| EndToEnd.go:64:26:64:33 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | -| EndToEnd.go:69:22:69:22 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | -| EndToEnd.go:69:22:69:29 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | -| EndToEnd.go:74:22:74:22 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | -| EndToEnd.go:74:22:74:29 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | -| EndToEnd.go:79:35:79:35 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | -| EndToEnd.go:79:35:79:42 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | -| EndToEnd.go:84:22:84:22 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | -| EndToEnd.go:84:22:84:29 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | -| EndToEnd.go:89:21:89:21 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | -| EndToEnd.go:89:21:89:28 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | -| EndToEnd.go:94:20:94:20 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | -| EndToEnd.go:94:20:94:27 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:31:35:31:35 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:31:35:31:42 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:37:18:37:18 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:37:18:37:25 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:45:18:45:18 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:45:18:45:25 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:52:20:52:20 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:52:20:52:27 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:59:18:59:18 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:59:18:59:25 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:65:26:65:26 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:65:26:65:33 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:70:22:70:22 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:70:22:70:29 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:75:22:75:22 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:75:22:75:29 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:80:35:80:35 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:80:35:80:42 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:85:22:85:22 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:85:22:85:29 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:90:21:90:21 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:90:21:90:28 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:95:20:95:20 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | +| EndToEnd.go:95:20:95:27 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | | Revel.go:26:7:26:7 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | | Revel.go:27:7:27:7 | implicit read of field Controller | Origin of readStep is missing a PostUpdateNode. | | Revel.go:27:7:27:14 | implicit dereference | Origin of readStep is missing a PostUpdateNode. | diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Revel/EndToEnd.go b/go/ql/test/library-tests/semmle/go/frameworks/Revel/EndToEnd.go index 69fc2c52c4a..0e60981e13d 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Revel/EndToEnd.go +++ b/go/ql/test/library-tests/semmle/go/frameworks/Revel/EndToEnd.go @@ -3,10 +3,11 @@ package main import ( "bytes" "errors" - staticControllers "github.com/revel/modules/static/app/controllers" - "github.com/revel/revel" "os" "time" + + staticControllers "github.com/revel/modules/static/app/controllers" + "github.com/revel/revel" ) // Use typical inheritence pattern, per github.com/revel/examples/booking: @@ -33,8 +34,8 @@ func (c MyRoute) Handler1() revel.Result { func (c MyRoute) Handler2() revel.Result { // BAD: the RenderBinary function copies an `io.Reader` to the user's browser. buf := &bytes.Buffer{} - buf.WriteString(c.Params.Form.Get("someField")) - return c.RenderBinary(buf, "index.html", revel.Inline, time.Now()) // $ responsebody='buf' + buf.WriteString(c.Params.Form.Get("someField")) // $ Source[go/reflected-xss] + return c.RenderBinary(buf, "index.html", revel.Inline, time.Now()) // $ responsebody='buf' Alert[go/reflected-xss] } func (c MyRoute) Handler3() revel.Result { @@ -55,18 +56,18 @@ func (c MyRoute) Handler4() revel.Result { func (c MyRoute) Handler5() revel.Result { // BAD: returning an arbitrary file (but this is detected at the os.Open call, not // due to modelling Revel) - f, _ := os.Open(c.Params.Form.Get("someField")) + f, _ := os.Open(c.Params.Form.Get("someField")) // $ Alert[go/path-injection] return c.RenderFile(f, revel.Inline) } func (c MyRoute) Handler6() revel.Result { // BAD: returning an arbitrary file (detected as a user-controlled file-op, not XSS) - return c.RenderFileName(c.Params.Form.Get("someField"), revel.Inline) + return c.RenderFileName(c.Params.Form.Get("someField"), revel.Inline) // $ Alert[go/path-injection] } func (c MyRoute) Handler7() revel.Result { // BAD: straightforward XSS - return c.RenderHTML(c.Params.Form.Get("someField")) // $ responsebody='call to Get' + return c.RenderHTML(c.Params.Form.Get("someField")) // $ responsebody='call to Get' Alert[go/reflected-xss] } func (c MyRoute) Handler8() revel.Result { @@ -91,5 +92,5 @@ func (c MyRoute) Handler11() revel.Result { func (c MyRoute) Handler12() revel.Result { // BAD: open redirect - return c.Redirect(c.Params.Form.Get("someField")) + return c.Redirect(c.Params.Form.Get("someField")) // $ Alert[go/unvalidated-url-redirection] } diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Revel/OpenRedirect.expected b/go/ql/test/library-tests/semmle/go/frameworks/Revel/OpenRedirect.expected index d3f52f4f9c6..3c889cd177c 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Revel/OpenRedirect.expected +++ b/go/ql/test/library-tests/semmle/go/frameworks/Revel/OpenRedirect.expected @@ -1,19 +1,19 @@ #select -| EndToEnd.go:94:20:94:49 | call to Get | EndToEnd.go:94:20:94:27 | selection of Params | EndToEnd.go:94:20:94:49 | call to Get | This path to an untrusted URL redirection depends on a $@. | EndToEnd.go:94:20:94:27 | selection of Params | user-provided value | +| EndToEnd.go:95:20:95:49 | call to Get | EndToEnd.go:95:20:95:27 | selection of Params | EndToEnd.go:95:20:95:49 | call to Get | This path to an untrusted URL redirection depends on a $@. | EndToEnd.go:95:20:95:27 | selection of Params | user-provided value | edges -| EndToEnd.go:94:20:94:27 | implicit dereference | EndToEnd.go:94:20:94:27 | selection of Params [postupdate] | provenance | Config | -| EndToEnd.go:94:20:94:27 | implicit dereference | EndToEnd.go:94:20:94:32 | selection of Form | provenance | Config | -| EndToEnd.go:94:20:94:27 | selection of Params | EndToEnd.go:94:20:94:27 | implicit dereference | provenance | Src:MaD:2 Config | -| EndToEnd.go:94:20:94:27 | selection of Params | EndToEnd.go:94:20:94:32 | selection of Form | provenance | Src:MaD:2 Config | -| EndToEnd.go:94:20:94:27 | selection of Params [postupdate] | EndToEnd.go:94:20:94:27 | implicit dereference | provenance | Config | -| EndToEnd.go:94:20:94:32 | selection of Form | EndToEnd.go:94:20:94:49 | call to Get | provenance | Config Sink:MaD:1 | +| EndToEnd.go:95:20:95:27 | implicit dereference | EndToEnd.go:95:20:95:27 | selection of Params [postupdate] | provenance | Config | +| EndToEnd.go:95:20:95:27 | implicit dereference | EndToEnd.go:95:20:95:32 | selection of Form | provenance | Config | +| EndToEnd.go:95:20:95:27 | selection of Params | EndToEnd.go:95:20:95:27 | implicit dereference | provenance | Src:MaD:2 Config | +| EndToEnd.go:95:20:95:27 | selection of Params | EndToEnd.go:95:20:95:32 | selection of Form | provenance | Src:MaD:2 Config | +| EndToEnd.go:95:20:95:27 | selection of Params [postupdate] | EndToEnd.go:95:20:95:27 | implicit dereference | provenance | Config | +| EndToEnd.go:95:20:95:32 | selection of Form | EndToEnd.go:95:20:95:49 | call to Get | provenance | Config Sink:MaD:1 | models | 1 | Sink: group:revel; Controller; true; Redirect; ; ; Argument[0]; url-redirection; manual | | 2 | Source: group:revel; Controller; true; Params; ; ; ; remote; manual | nodes -| EndToEnd.go:94:20:94:27 | implicit dereference | semmle.label | implicit dereference | -| EndToEnd.go:94:20:94:27 | selection of Params | semmle.label | selection of Params | -| EndToEnd.go:94:20:94:27 | selection of Params [postupdate] | semmle.label | selection of Params [postupdate] | -| EndToEnd.go:94:20:94:32 | selection of Form | semmle.label | selection of Form | -| EndToEnd.go:94:20:94:49 | call to Get | semmle.label | call to Get | +| EndToEnd.go:95:20:95:27 | implicit dereference | semmle.label | implicit dereference | +| EndToEnd.go:95:20:95:27 | selection of Params | semmle.label | selection of Params | +| EndToEnd.go:95:20:95:27 | selection of Params [postupdate] | semmle.label | selection of Params [postupdate] | +| EndToEnd.go:95:20:95:32 | selection of Form | semmle.label | selection of Form | +| EndToEnd.go:95:20:95:49 | call to Get | semmle.label | call to Get | subpaths diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Revel/OpenRedirect.qlref b/go/ql/test/library-tests/semmle/go/frameworks/Revel/OpenRedirect.qlref index 867dd766561..13add930f51 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Revel/OpenRedirect.qlref +++ b/go/ql/test/library-tests/semmle/go/frameworks/Revel/OpenRedirect.qlref @@ -1,2 +1,4 @@ query: Security/CWE-601/OpenUrlRedirect.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Revel/ReflectedXss.expected b/go/ql/test/library-tests/semmle/go/frameworks/Revel/ReflectedXss.expected index 9ea4016a7e4..0de532aa186 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Revel/ReflectedXss.expected +++ b/go/ql/test/library-tests/semmle/go/frameworks/Revel/ReflectedXss.expected @@ -1,16 +1,16 @@ #select -| EndToEnd.go:37:24:37:26 | buf | EndToEnd.go:36:18:36:25 | selection of Params | EndToEnd.go:37:24:37:26 | buf | Cross-site scripting vulnerability due to $@. | EndToEnd.go:36:18:36:25 | selection of Params | user-provided value | EndToEnd.go:0:0:0:0 | EndToEnd.go | | -| EndToEnd.go:69:22:69:51 | call to Get | EndToEnd.go:69:22:69:29 | selection of Params | EndToEnd.go:69:22:69:51 | call to Get | Cross-site scripting vulnerability due to $@. | EndToEnd.go:69:22:69:29 | selection of Params | user-provided value | EndToEnd.go:0:0:0:0 | EndToEnd.go | | +| EndToEnd.go:38:24:38:26 | buf | EndToEnd.go:37:18:37:25 | selection of Params | EndToEnd.go:38:24:38:26 | buf | Cross-site scripting vulnerability due to $@. | EndToEnd.go:37:18:37:25 | selection of Params | user-provided value | EndToEnd.go:0:0:0:0 | EndToEnd.go | | +| EndToEnd.go:70:22:70:51 | call to Get | EndToEnd.go:70:22:70:29 | selection of Params | EndToEnd.go:70:22:70:51 | call to Get | Cross-site scripting vulnerability due to $@. | EndToEnd.go:70:22:70:29 | selection of Params | user-provided value | EndToEnd.go:0:0:0:0 | EndToEnd.go | | | Revel.go:70:22:70:35 | selection of Query | Revel.go:70:22:70:29 | selection of Params | Revel.go:70:22:70:35 | selection of Query | Cross-site scripting vulnerability due to $@. The value is $@. | Revel.go:70:22:70:29 | selection of Params | user-provided value | views/myAppController/rawRead.html:1:1:2:9 | {{raw .Foo}}\n{{.Bar}}\n | instantiated as a raw template | | examples/booking/app/init.go:36:44:36:53 | selection of Path | examples/booking/app/init.go:36:44:36:48 | selection of URL | examples/booking/app/init.go:36:44:36:53 | selection of Path | Cross-site scripting vulnerability due to $@. | examples/booking/app/init.go:36:44:36:48 | selection of URL | user-provided value | examples/booking/app/init.go:0:0:0:0 | examples/booking/app/init.go | | | examples/booking/app/init.go:40:49:40:58 | selection of Path | examples/booking/app/init.go:40:49:40:53 | selection of URL | examples/booking/app/init.go:40:49:40:58 | selection of Path | Cross-site scripting vulnerability due to $@. | examples/booking/app/init.go:40:49:40:53 | selection of URL | user-provided value | examples/booking/app/init.go:0:0:0:0 | examples/booking/app/init.go | | edges -| EndToEnd.go:36:2:36:4 | buf [postupdate] | EndToEnd.go:37:24:37:26 | buf | provenance | | -| EndToEnd.go:36:18:36:25 | selection of Params | EndToEnd.go:36:18:36:30 | selection of Form | provenance | Src:MaD:1 | -| EndToEnd.go:36:18:36:30 | selection of Form | EndToEnd.go:36:18:36:47 | call to Get | provenance | MaD:4 | -| EndToEnd.go:36:18:36:47 | call to Get | EndToEnd.go:36:2:36:4 | buf [postupdate] | provenance | MaD:3 | -| EndToEnd.go:69:22:69:29 | selection of Params | EndToEnd.go:69:22:69:34 | selection of Form | provenance | Src:MaD:1 | -| EndToEnd.go:69:22:69:34 | selection of Form | EndToEnd.go:69:22:69:51 | call to Get | provenance | MaD:4 | +| EndToEnd.go:37:2:37:4 | buf [postupdate] | EndToEnd.go:38:24:38:26 | buf | provenance | | +| EndToEnd.go:37:18:37:25 | selection of Params | EndToEnd.go:37:18:37:30 | selection of Form | provenance | Src:MaD:1 | +| EndToEnd.go:37:18:37:30 | selection of Form | EndToEnd.go:37:18:37:47 | call to Get | provenance | MaD:4 | +| EndToEnd.go:37:18:37:47 | call to Get | EndToEnd.go:37:2:37:4 | buf [postupdate] | provenance | MaD:3 | +| EndToEnd.go:70:22:70:29 | selection of Params | EndToEnd.go:70:22:70:34 | selection of Form | provenance | Src:MaD:1 | +| EndToEnd.go:70:22:70:34 | selection of Form | EndToEnd.go:70:22:70:51 | call to Get | provenance | MaD:4 | | Revel.go:70:22:70:29 | selection of Params | Revel.go:70:22:70:35 | selection of Query | provenance | Src:MaD:1 | | examples/booking/app/init.go:36:44:36:48 | selection of URL | examples/booking/app/init.go:36:44:36:53 | selection of Path | provenance | Src:MaD:2 | | examples/booking/app/init.go:40:49:40:53 | selection of URL | examples/booking/app/init.go:40:49:40:58 | selection of Path | provenance | Src:MaD:2 | @@ -20,14 +20,14 @@ models | 3 | Summary: io; StringWriter; true; WriteString; ; ; Argument[0]; Argument[receiver]; taint; manual | | 4 | Summary: net/url; Values; true; Get; ; ; Argument[receiver]; ReturnValue; taint; manual | nodes -| EndToEnd.go:36:2:36:4 | buf [postupdate] | semmle.label | buf [postupdate] | -| EndToEnd.go:36:18:36:25 | selection of Params | semmle.label | selection of Params | -| EndToEnd.go:36:18:36:30 | selection of Form | semmle.label | selection of Form | -| EndToEnd.go:36:18:36:47 | call to Get | semmle.label | call to Get | -| EndToEnd.go:37:24:37:26 | buf | semmle.label | buf | -| EndToEnd.go:69:22:69:29 | selection of Params | semmle.label | selection of Params | -| EndToEnd.go:69:22:69:34 | selection of Form | semmle.label | selection of Form | -| EndToEnd.go:69:22:69:51 | call to Get | semmle.label | call to Get | +| EndToEnd.go:37:2:37:4 | buf [postupdate] | semmle.label | buf [postupdate] | +| EndToEnd.go:37:18:37:25 | selection of Params | semmle.label | selection of Params | +| EndToEnd.go:37:18:37:30 | selection of Form | semmle.label | selection of Form | +| EndToEnd.go:37:18:37:47 | call to Get | semmle.label | call to Get | +| EndToEnd.go:38:24:38:26 | buf | semmle.label | buf | +| EndToEnd.go:70:22:70:29 | selection of Params | semmle.label | selection of Params | +| EndToEnd.go:70:22:70:34 | selection of Form | semmle.label | selection of Form | +| EndToEnd.go:70:22:70:51 | call to Get | semmle.label | call to Get | | Revel.go:70:22:70:29 | selection of Params | semmle.label | selection of Params | | Revel.go:70:22:70:35 | selection of Query | semmle.label | selection of Query | | examples/booking/app/init.go:36:44:36:48 | selection of URL | semmle.label | selection of URL | diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Revel/ReflectedXss.qlref b/go/ql/test/library-tests/semmle/go/frameworks/Revel/ReflectedXss.qlref index 754513d72bb..e6b791f39fc 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Revel/ReflectedXss.qlref +++ b/go/ql/test/library-tests/semmle/go/frameworks/Revel/ReflectedXss.qlref @@ -1,2 +1,4 @@ query: Security/CWE-079/ReflectedXss.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Revel/Revel.go b/go/ql/test/library-tests/semmle/go/frameworks/Revel/Revel.go index f09dcd6fa58..219e1dddb4c 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Revel/Revel.go +++ b/go/ql/test/library-tests/semmle/go/frameworks/Revel/Revel.go @@ -67,7 +67,7 @@ func (c myAppController) accessingParamsJSONIsUnsafe() { func (c myAppController) rawRead() { // $ responsebody='argument corresponding to c' c.ViewArgs["Foo"] = "

raw HTML

" // $ responsebody='"

raw HTML

"' c.ViewArgs["Bar"] = "

not raw HTML

" - c.ViewArgs["Foo"] = c.Params.Query // $ responsebody='selection of Query' + c.ViewArgs["Foo"] = c.Params.Query // $ responsebody='selection of Query' Alert[go/reflected-xss] c.Render() } diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Revel/TaintedPath.expected b/go/ql/test/library-tests/semmle/go/frameworks/Revel/TaintedPath.expected index 7337f636c47..e007da1c95d 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Revel/TaintedPath.expected +++ b/go/ql/test/library-tests/semmle/go/frameworks/Revel/TaintedPath.expected @@ -1,21 +1,21 @@ #select -| EndToEnd.go:58:18:58:47 | call to Get | EndToEnd.go:58:18:58:25 | selection of Params | EndToEnd.go:58:18:58:47 | call to Get | This path depends on a $@. | EndToEnd.go:58:18:58:25 | selection of Params | user-provided value | -| EndToEnd.go:64:26:64:55 | call to Get | EndToEnd.go:64:26:64:33 | selection of Params | EndToEnd.go:64:26:64:55 | call to Get | This path depends on a $@. | EndToEnd.go:64:26:64:33 | selection of Params | user-provided value | +| EndToEnd.go:59:18:59:47 | call to Get | EndToEnd.go:59:18:59:25 | selection of Params | EndToEnd.go:59:18:59:47 | call to Get | This path depends on a $@. | EndToEnd.go:59:18:59:25 | selection of Params | user-provided value | +| EndToEnd.go:65:26:65:55 | call to Get | EndToEnd.go:65:26:65:33 | selection of Params | EndToEnd.go:65:26:65:55 | call to Get | This path depends on a $@. | EndToEnd.go:65:26:65:33 | selection of Params | user-provided value | edges -| EndToEnd.go:58:18:58:25 | selection of Params | EndToEnd.go:58:18:58:30 | selection of Form | provenance | Src:MaD:3 | -| EndToEnd.go:58:18:58:30 | selection of Form | EndToEnd.go:58:18:58:47 | call to Get | provenance | MaD:4 Sink:MaD:2 | -| EndToEnd.go:64:26:64:33 | selection of Params | EndToEnd.go:64:26:64:38 | selection of Form | provenance | Src:MaD:3 | -| EndToEnd.go:64:26:64:38 | selection of Form | EndToEnd.go:64:26:64:55 | call to Get | provenance | MaD:4 Sink:MaD:1 | +| EndToEnd.go:59:18:59:25 | selection of Params | EndToEnd.go:59:18:59:30 | selection of Form | provenance | Src:MaD:3 | +| EndToEnd.go:59:18:59:30 | selection of Form | EndToEnd.go:59:18:59:47 | call to Get | provenance | MaD:4 Sink:MaD:2 | +| EndToEnd.go:65:26:65:33 | selection of Params | EndToEnd.go:65:26:65:38 | selection of Form | provenance | Src:MaD:3 | +| EndToEnd.go:65:26:65:38 | selection of Form | EndToEnd.go:65:26:65:55 | call to Get | provenance | MaD:4 Sink:MaD:1 | models | 1 | Sink: group:revel; Controller; true; RenderFileName; ; ; Argument[0]; path-injection; manual | | 2 | Sink: os; ; false; Open; ; ; Argument[0]; path-injection; manual | | 3 | Source: group:revel; Controller; true; Params; ; ; ; remote; manual | | 4 | Summary: net/url; Values; true; Get; ; ; Argument[receiver]; ReturnValue; taint; manual | nodes -| EndToEnd.go:58:18:58:25 | selection of Params | semmle.label | selection of Params | -| EndToEnd.go:58:18:58:30 | selection of Form | semmle.label | selection of Form | -| EndToEnd.go:58:18:58:47 | call to Get | semmle.label | call to Get | -| EndToEnd.go:64:26:64:33 | selection of Params | semmle.label | selection of Params | -| EndToEnd.go:64:26:64:38 | selection of Form | semmle.label | selection of Form | -| EndToEnd.go:64:26:64:55 | call to Get | semmle.label | call to Get | +| EndToEnd.go:59:18:59:25 | selection of Params | semmle.label | selection of Params | +| EndToEnd.go:59:18:59:30 | selection of Form | semmle.label | selection of Form | +| EndToEnd.go:59:18:59:47 | call to Get | semmle.label | call to Get | +| EndToEnd.go:65:26:65:33 | selection of Params | semmle.label | selection of Params | +| EndToEnd.go:65:26:65:38 | selection of Form | semmle.label | selection of Form | +| EndToEnd.go:65:26:65:55 | call to Get | semmle.label | call to Get | subpaths diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Revel/TaintedPath.qlref b/go/ql/test/library-tests/semmle/go/frameworks/Revel/TaintedPath.qlref index 78ce25b1921..6eb2e94892f 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Revel/TaintedPath.qlref +++ b/go/ql/test/library-tests/semmle/go/frameworks/Revel/TaintedPath.qlref @@ -1,2 +1,4 @@ query: Security/CWE-022/TaintedPath.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Revel/examples/booking/app/init.go b/go/ql/test/library-tests/semmle/go/frameworks/Revel/examples/booking/app/init.go index 2f7fef73fc2..ca9232ec7c7 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Revel/examples/booking/app/init.go +++ b/go/ql/test/library-tests/semmle/go/frameworks/Revel/examples/booking/app/init.go @@ -33,11 +33,11 @@ func init() { switch event { case revel.ENGINE_BEFORE_INITIALIZED: revel.AddHTTPMux("/this/is/a/test", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - fmt.Fprintln(w, "Hi there, it worked", r.URL.Path) // $ responsebody='selection of Path' responsebody='"Hi there, it worked"' + fmt.Fprintln(w, "Hi there, it worked", r.URL.Path) // $ responsebody='selection of Path' responsebody='"Hi there, it worked"' Alert[go/reflected-xss] w.WriteHeader(200) })) revel.AddHTTPMux("/this/is/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - fmt.Fprintln(w, "Hi there, shorter prefix", r.URL.Path) // $ responsebody='selection of Path' responsebody='"Hi there, shorter prefix"' + fmt.Fprintln(w, "Hi there, shorter prefix", r.URL.Path) // $ responsebody='selection of Path' responsebody='"Hi there, shorter prefix"' Alert[go/reflected-xss] w.WriteHeader(200) })) } diff --git a/go/ql/test/library-tests/semmle/go/frameworks/XNetHtml/ReflectedXss.qlref b/go/ql/test/library-tests/semmle/go/frameworks/XNetHtml/ReflectedXss.qlref index 754513d72bb..e6b791f39fc 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/XNetHtml/ReflectedXss.qlref +++ b/go/ql/test/library-tests/semmle/go/frameworks/XNetHtml/ReflectedXss.qlref @@ -1,2 +1,4 @@ query: Security/CWE-079/ReflectedXss.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/library-tests/semmle/go/frameworks/XNetHtml/SqlInjection.qlref b/go/ql/test/library-tests/semmle/go/frameworks/XNetHtml/SqlInjection.qlref index b6916bd2cd4..e1918157744 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/XNetHtml/SqlInjection.qlref +++ b/go/ql/test/library-tests/semmle/go/frameworks/XNetHtml/SqlInjection.qlref @@ -1,2 +1,4 @@ query: Security/CWE-089/SqlInjection.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/library-tests/semmle/go/frameworks/XNetHtml/test.go b/go/ql/test/library-tests/semmle/go/frameworks/XNetHtml/test.go index a89167e126c..6b8a02a1fb3 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/XNetHtml/test.go +++ b/go/ql/test/library-tests/semmle/go/frameworks/XNetHtml/test.go @@ -9,50 +9,50 @@ import ( func test(request *http.Request, writer http.ResponseWriter) { - param1 := request.URL.Query().Get("param1") + param1 := request.URL.Query().Get("param1") // $ Source[go/reflected-xss] writer.Write([]byte(html.EscapeString(param1))) // GOOD: escaped. - writer.Write([]byte(html.UnescapeString(param1))) // BAD: unescaped. + writer.Write([]byte(html.UnescapeString(param1))) // $ Alert[go/reflected-xss] // BAD: unescaped. - node, _ := html.Parse(request.Body) - writer.Write([]byte(node.Data)) // BAD: writing unescaped HTML data + node, _ := html.Parse(request.Body) // $ Source[go/reflected-xss] + writer.Write([]byte(node.Data)) // $ Alert[go/reflected-xss] // BAD: writing unescaped HTML data - node2, _ := html.ParseWithOptions(request.Body) - writer.Write([]byte(node2.Data)) // BAD: writing unescaped HTML data + node2, _ := html.ParseWithOptions(request.Body) // $ Source[go/reflected-xss] + writer.Write([]byte(node2.Data)) // $ Alert[go/reflected-xss] // BAD: writing unescaped HTML data - nodes, _ := html.ParseFragment(request.Body, nil) - writer.Write([]byte(nodes[0].Data)) // BAD: writing unescaped HTML data + nodes, _ := html.ParseFragment(request.Body, nil) // $ Source[go/reflected-xss] + writer.Write([]byte(nodes[0].Data)) // $ Alert[go/reflected-xss] // BAD: writing unescaped HTML data - nodes2, _ := html.ParseFragmentWithOptions(request.Body, nil) - writer.Write([]byte(nodes2[0].Data)) // BAD: writing unescaped HTML data + nodes2, _ := html.ParseFragmentWithOptions(request.Body, nil) // $ Source[go/reflected-xss] + writer.Write([]byte(nodes2[0].Data)) // $ Alert[go/reflected-xss] // BAD: writing unescaped HTML data - html.Render(writer, node) // BAD: rendering untrusted HTML to `writer` + html.Render(writer, node) // $ Alert[go/reflected-xss] // BAD: rendering untrusted HTML to `writer` - tokenizer := html.NewTokenizer(request.Body) - writer.Write(tokenizer.Buffered()) // BAD: writing unescaped HTML data - writer.Write(tokenizer.Raw()) // BAD: writing unescaped HTML data + tokenizer := html.NewTokenizer(request.Body) // $ Source[go/reflected-xss] + writer.Write(tokenizer.Buffered()) // $ Alert[go/reflected-xss] // BAD: writing unescaped HTML data + writer.Write(tokenizer.Raw()) // $ Alert[go/reflected-xss] // BAD: writing unescaped HTML data _, value, _ := tokenizer.TagAttr() - writer.Write(value) // BAD: writing unescaped HTML data - writer.Write(tokenizer.Text()) // BAD: writing unescaped HTML data - writer.Write([]byte(tokenizer.Token().Data)) // BAD: writing unescaped HTML data + writer.Write(value) // $ Alert[go/reflected-xss] // BAD: writing unescaped HTML data + writer.Write(tokenizer.Text()) // $ Alert[go/reflected-xss] // BAD: writing unescaped HTML data + writer.Write([]byte(tokenizer.Token().Data)) // $ Alert[go/reflected-xss] // BAD: writing unescaped HTML data - tokenizerFragment := html.NewTokenizerFragment(request.Body, "some context") - writer.Write(tokenizerFragment.Buffered()) // BAD: writing unescaped HTML data + tokenizerFragment := html.NewTokenizerFragment(request.Body, "some context") // $ Source[go/reflected-xss] + writer.Write(tokenizerFragment.Buffered()) // $ Alert[go/reflected-xss] // BAD: writing unescaped HTML data var cleanNode html.Node - taintedNode, _ := html.Parse(request.Body) + taintedNode, _ := html.Parse(request.Body) // $ Source[go/reflected-xss] cleanNode.AppendChild(taintedNode) - html.Render(writer, &cleanNode) // BAD: writing unescaped HTML data + html.Render(writer, &cleanNode) // $ Alert[go/reflected-xss] // BAD: writing unescaped HTML data var cleanNode2 html.Node - taintedNode2, _ := html.Parse(request.Body) + taintedNode2, _ := html.Parse(request.Body) // $ Source[go/reflected-xss] cleanNode2.InsertBefore(taintedNode2, &cleanNode2) - html.Render(writer, &cleanNode2) // BAD: writing unescaped HTML data + html.Render(writer, &cleanNode2) // $ Alert[go/reflected-xss] // BAD: writing unescaped HTML data } func sqlTest(request *http.Request, db *sql.DB) { // Ensure EscapeString is a taint propagator for non-XSS queries, e.g. SQL injection: - cookie, _ := request.Cookie("SomeCookie") - db.Query(html.EscapeString(cookie.Value)) + cookie, _ := request.Cookie("SomeCookie") // $ Source[go/sql-injection] + db.Query(html.EscapeString(cookie.Value)) // $ Alert[go/sql-injection] } diff --git a/go/ql/test/query-tests/InconsistentCode/ConstantLengthComparison/ConstantLengthComparison.go b/go/ql/test/query-tests/InconsistentCode/ConstantLengthComparison/ConstantLengthComparison.go index cec41e2dab2..a1a6b1f309e 100644 --- a/go/ql/test/query-tests/InconsistentCode/ConstantLengthComparison/ConstantLengthComparison.go +++ b/go/ql/test/query-tests/InconsistentCode/ConstantLengthComparison/ConstantLengthComparison.go @@ -2,7 +2,7 @@ package main func isPrefixOf(xs, ys []int) bool { for i := 0; i < len(xs); i++ { - if len(ys) == 0 || xs[i] != ys[i] { // NOT OK + if len(ys) == 0 || xs[i] != ys[i] { // $ Alert // NOT OK return false } } diff --git a/go/ql/test/query-tests/InconsistentCode/ConstantLengthComparison/ConstantLengthComparison.qlref b/go/ql/test/query-tests/InconsistentCode/ConstantLengthComparison/ConstantLengthComparison.qlref index 315838df15f..edd5d2d1d43 100644 --- a/go/ql/test/query-tests/InconsistentCode/ConstantLengthComparison/ConstantLengthComparison.qlref +++ b/go/ql/test/query-tests/InconsistentCode/ConstantLengthComparison/ConstantLengthComparison.qlref @@ -1 +1,2 @@ -InconsistentCode/ConstantLengthComparison.ql +query: InconsistentCode/ConstantLengthComparison.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/InconsistentCode/InconsistentLoopOrientation/InconsistentLoopOrientation.go b/go/ql/test/query-tests/InconsistentCode/InconsistentLoopOrientation/InconsistentLoopOrientation.go index 077015ced99..cda530aec6a 100644 --- a/go/ql/test/query-tests/InconsistentCode/InconsistentLoopOrientation/InconsistentLoopOrientation.go +++ b/go/ql/test/query-tests/InconsistentCode/InconsistentLoopOrientation/InconsistentLoopOrientation.go @@ -7,7 +7,7 @@ func zeroOutExceptBad(a []int, lower int, upper int) { } // zero out everything above index `upper` - for i := upper + 1; i < len(a); i-- { // NOT OK + for i := upper + 1; i < len(a); i-- { // $ Alert // NOT OK a[i] = 0 } } diff --git a/go/ql/test/query-tests/InconsistentCode/InconsistentLoopOrientation/InconsistentLoopOrientation.qlref b/go/ql/test/query-tests/InconsistentCode/InconsistentLoopOrientation/InconsistentLoopOrientation.qlref index 62ab35e2257..336261fde23 100644 --- a/go/ql/test/query-tests/InconsistentCode/InconsistentLoopOrientation/InconsistentLoopOrientation.qlref +++ b/go/ql/test/query-tests/InconsistentCode/InconsistentLoopOrientation/InconsistentLoopOrientation.qlref @@ -1 +1,2 @@ -InconsistentCode/InconsistentLoopOrientation.ql +query: InconsistentCode/InconsistentLoopOrientation.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/InconsistentCode/InconsistentLoopOrientation/main.go b/go/ql/test/query-tests/InconsistentCode/InconsistentLoopOrientation/main.go index ede1c5878fb..4cb6e1feac7 100644 --- a/go/ql/test/query-tests/InconsistentCode/InconsistentLoopOrientation/main.go +++ b/go/ql/test/query-tests/InconsistentCode/InconsistentLoopOrientation/main.go @@ -6,12 +6,12 @@ func f1(i int) { } func f2(i int, s string) { - for j := i + 1; j < len(s); j-- { // NOT OK + for j := i + 1; j < len(s); j-- { // $ Alert // NOT OK } } func f3(s string) { - for i, l := 0, len(s); i > l; i++ { // NOT OK + for i, l := 0, len(s); i > l; i++ { // $ Alert // NOT OK } } @@ -22,7 +22,7 @@ func f4(lower int, a []int) { } func f5(upper int, a []int) { - for i := upper + 1; i < len(a); i-- { // NOT OK + for i := upper + 1; i < len(a); i-- { // $ Alert // NOT OK a[i] = 0 } } diff --git a/go/ql/test/query-tests/InconsistentCode/LengthComparisonOffByOne/LengthComparisonOffByOne.go b/go/ql/test/query-tests/InconsistentCode/LengthComparisonOffByOne/LengthComparisonOffByOne.go index 7db63c62bfe..965178e2cdc 100644 --- a/go/ql/test/query-tests/InconsistentCode/LengthComparisonOffByOne/LengthComparisonOffByOne.go +++ b/go/ql/test/query-tests/InconsistentCode/LengthComparisonOffByOne/LengthComparisonOffByOne.go @@ -5,9 +5,9 @@ import "strings" func containsBad(searchName string, names string) bool { values := strings.Split(names, ",") // BAD: index could be equal to length - for i := 0; i <= len(values); i++ { + for i := 0; i <= len(values); i++ { // $ Alert // When i = length, this access will be out of bounds - if values[i] == searchName { + if values[i] == searchName { // $ Source return true } } diff --git a/go/ql/test/query-tests/InconsistentCode/LengthComparisonOffByOne/LengthComparisonOffByOne.qlref b/go/ql/test/query-tests/InconsistentCode/LengthComparisonOffByOne/LengthComparisonOffByOne.qlref index 8692ba8a17d..ddd036de50a 100644 --- a/go/ql/test/query-tests/InconsistentCode/LengthComparisonOffByOne/LengthComparisonOffByOne.qlref +++ b/go/ql/test/query-tests/InconsistentCode/LengthComparisonOffByOne/LengthComparisonOffByOne.qlref @@ -1 +1,2 @@ -InconsistentCode/LengthComparisonOffByOne.ql +query: InconsistentCode/LengthComparisonOffByOne.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/InconsistentCode/LengthComparisonOffByOne/main.go b/go/ql/test/query-tests/InconsistentCode/LengthComparisonOffByOne/main.go index 3a426dc554d..01e849c0f2f 100644 --- a/go/ql/test/query-tests/InconsistentCode/LengthComparisonOffByOne/main.go +++ b/go/ql/test/query-tests/InconsistentCode/LengthComparisonOffByOne/main.go @@ -3,8 +3,8 @@ package main import "regexp" func f1(i int, a []int) int { - if i <= len(a) { // NOT OK - return a[i] + if i <= len(a) { // $ Alert // NOT OK + return a[i] // $ Source } return -1 } @@ -26,8 +26,8 @@ func f3(i int, a []int) int { } func f4(i int, a []int) int { - if len(a) > 0 { // NOT OK - return a[1] + if len(a) > 0 { // $ Alert // NOT OK + return a[1] // $ Source } return -1 } diff --git a/go/ql/test/query-tests/InconsistentCode/MissingErrorCheck/MissingErrorCheck.qlref b/go/ql/test/query-tests/InconsistentCode/MissingErrorCheck/MissingErrorCheck.qlref index 519bdd54e68..c70c6a57526 100644 --- a/go/ql/test/query-tests/InconsistentCode/MissingErrorCheck/MissingErrorCheck.qlref +++ b/go/ql/test/query-tests/InconsistentCode/MissingErrorCheck/MissingErrorCheck.qlref @@ -1 +1,2 @@ -InconsistentCode/MissingErrorCheck.ql +query: InconsistentCode/MissingErrorCheck.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/InconsistentCode/MissingErrorCheck/tests.go b/go/ql/test/query-tests/InconsistentCode/MissingErrorCheck/tests.go index da60b272bbe..1f45bbbf4e2 100644 --- a/go/ql/test/query-tests/InconsistentCode/MissingErrorCheck/tests.go +++ b/go/ql/test/query-tests/InconsistentCode/MissingErrorCheck/tests.go @@ -58,7 +58,7 @@ func missingCheckMayFail(fname string) { result, err := os.Open(fname) - fmt.Printf("Opened: %v\n", *result) // NOT OK + fmt.Printf("Opened: %v\n", *result) // $ Alert // NOT OK fmt.Printf("%v\n", err) // use err } @@ -240,7 +240,7 @@ func mishandlesMyError(input int) { result, err := returnsMyError(input) - fmt.Printf("Got: %d\n", *result) // NOT OK + fmt.Printf("Got: %d\n", *result) // $ Alert // NOT OK fmt.Printf("%v\n", err) // use err } diff --git a/go/ql/test/query-tests/InconsistentCode/MistypedExponentiation/MistypedExponentiation.go b/go/ql/test/query-tests/InconsistentCode/MistypedExponentiation/MistypedExponentiation.go index f6e3108f581..0ae2c8a0afb 100644 --- a/go/ql/test/query-tests/InconsistentCode/MistypedExponentiation/MistypedExponentiation.go +++ b/go/ql/test/query-tests/InconsistentCode/MistypedExponentiation/MistypedExponentiation.go @@ -3,5 +3,5 @@ package main import "fmt" func test() { - fmt.Println(2 ^ 32) // should be 1 << 32 + fmt.Println(2 ^ 32) // $ Alert // should be 1 << 32 } diff --git a/go/ql/test/query-tests/InconsistentCode/MistypedExponentiation/MistypedExponentiation.qlref b/go/ql/test/query-tests/InconsistentCode/MistypedExponentiation/MistypedExponentiation.qlref index bd96eb93eb4..40b505ceca2 100644 --- a/go/ql/test/query-tests/InconsistentCode/MistypedExponentiation/MistypedExponentiation.qlref +++ b/go/ql/test/query-tests/InconsistentCode/MistypedExponentiation/MistypedExponentiation.qlref @@ -1 +1,2 @@ -InconsistentCode/MistypedExponentiation.ql +query: InconsistentCode/MistypedExponentiation.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/InconsistentCode/MistypedExponentiation/main.go b/go/ql/test/query-tests/InconsistentCode/MistypedExponentiation/main.go index b8b4be44847..5aa436eb08f 100644 --- a/go/ql/test/query-tests/InconsistentCode/MistypedExponentiation/main.go +++ b/go/ql/test/query-tests/InconsistentCode/MistypedExponentiation/main.go @@ -12,13 +12,13 @@ func main() { expectingResponse := 1 << 5 power := 10 - fmt.Println(3 ^ 5) // Not OK + fmt.Println(3 ^ 5) // $ Alert // Not OK fmt.Println(0755 ^ 2423) // OK - fmt.Println(2 ^ 32) // Not OK - fmt.Println(10 ^ 5) // Not OK - fmt.Println(10 ^ exp) // Not OK + fmt.Println(2 ^ 32) // $ Alert // Not OK + fmt.Println(10 ^ 5) // $ Alert // Not OK + fmt.Println(10 ^ exp) // $ Alert // Not OK fmt.Println(253 ^ expectingResponse) // OK - fmt.Println(2 ^ power) // Not OK + fmt.Println(2 ^ power) // $ Alert // Not OK mask := (((1 << 10) - 1) ^ 7) // OK diff --git a/go/ql/test/query-tests/InconsistentCode/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.go b/go/ql/test/query-tests/InconsistentCode/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.go index ee6987ec931..bee4b5921b0 100644 --- a/go/ql/test/query-tests/InconsistentCode/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.go +++ b/go/ql/test/query-tests/InconsistentCode/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.go @@ -3,5 +3,5 @@ package main // autoformat-ignore (otherwise gofmt will fix the spacing to reflect precedence) func isBitSetBad(x int, pos uint) bool { - return x & 1<> 1; + return x+x >> 1; // $ Alert } func ok3(x int) int { diff --git a/go/ql/test/query-tests/InconsistentCode/WrappedErrorAlwaysNil/WrappedErrorAlwaysNil.go b/go/ql/test/query-tests/InconsistentCode/WrappedErrorAlwaysNil/WrappedErrorAlwaysNil.go index 70ccce77ba7..d5901800cbb 100644 --- a/go/ql/test/query-tests/InconsistentCode/WrappedErrorAlwaysNil/WrappedErrorAlwaysNil.go +++ b/go/ql/test/query-tests/InconsistentCode/WrappedErrorAlwaysNil/WrappedErrorAlwaysNil.go @@ -28,7 +28,7 @@ func test1(input string) error { } if ok2, _ := f2(input); !ok2 { // BAD: Wrapped error is always nil - return errors.Wrap(err, "") + return errors.Wrap(err, "") // $ Alert } return nil } @@ -38,13 +38,13 @@ func test2(err error) { errors.Wrap(err, "") // BAD: Wrapped error is always nil - errors.Wrap(nil, "") + errors.Wrap(nil, "") // $ Alert err = nil // BAD: Wrapped error is always nil - errors.Wrap(err, "") + errors.Wrap(err, "") // $ Alert var localErr error = nil // BAD: Wrapped error is always nil - errors.Wrap(localErr, "") + errors.Wrap(localErr, "") // $ Alert } diff --git a/go/ql/test/query-tests/InconsistentCode/WrappedErrorAlwaysNil/WrappedErrorAlwaysNil.qlref b/go/ql/test/query-tests/InconsistentCode/WrappedErrorAlwaysNil/WrappedErrorAlwaysNil.qlref index bad618814a1..03f9d3ebda1 100644 --- a/go/ql/test/query-tests/InconsistentCode/WrappedErrorAlwaysNil/WrappedErrorAlwaysNil.qlref +++ b/go/ql/test/query-tests/InconsistentCode/WrappedErrorAlwaysNil/WrappedErrorAlwaysNil.qlref @@ -1 +1,2 @@ -InconsistentCode/WrappedErrorAlwaysNil.ql +query: InconsistentCode/WrappedErrorAlwaysNil.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/RedundantCode/CompareIdenticalValues/CompareIdenticalValues.go b/go/ql/test/query-tests/RedundantCode/CompareIdenticalValues/CompareIdenticalValues.go index b096cdf5cec..594d8cfcca1 100644 --- a/go/ql/test/query-tests/RedundantCode/CompareIdenticalValues/CompareIdenticalValues.go +++ b/go/ql/test/query-tests/RedundantCode/CompareIdenticalValues/CompareIdenticalValues.go @@ -6,7 +6,7 @@ type Rectangle struct { func (r *Rectangle) containsBad(x, y int) bool { return r.x <= x && - y <= y && // NOT OK + y <= y && // $ Alert // NOT OK x <= r.x+r.width && y <= r.y+r.height } diff --git a/go/ql/test/query-tests/RedundantCode/CompareIdenticalValues/CompareIdenticalValues.qlref b/go/ql/test/query-tests/RedundantCode/CompareIdenticalValues/CompareIdenticalValues.qlref index 7c3ac7ace2b..e9d5bb357fd 100644 --- a/go/ql/test/query-tests/RedundantCode/CompareIdenticalValues/CompareIdenticalValues.qlref +++ b/go/ql/test/query-tests/RedundantCode/CompareIdenticalValues/CompareIdenticalValues.qlref @@ -1 +1,2 @@ -RedundantCode/CompareIdenticalValues.ql +query: RedundantCode/CompareIdenticalValues.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/RedundantCode/CompareIdenticalValues/tst.go b/go/ql/test/query-tests/RedundantCode/CompareIdenticalValues/tst.go index 935e71bab99..fbe842b669c 100644 --- a/go/ql/test/query-tests/RedundantCode/CompareIdenticalValues/tst.go +++ b/go/ql/test/query-tests/RedundantCode/CompareIdenticalValues/tst.go @@ -3,7 +3,7 @@ package main import "fmt" func foo(x int) bool { - return x == x // NOT OK + return x == x // $ Alert // NOT OK } func isNaN(x float32) bool { @@ -57,5 +57,5 @@ func baz2() bool { func baz3() bool { var y counter y.bimp() - return y == 0 // NOT OK + return y == 0 // $ Alert // NOT OK } diff --git a/go/ql/test/query-tests/RedundantCode/CompareIdenticalValues/vp.go b/go/ql/test/query-tests/RedundantCode/CompareIdenticalValues/vp.go index 64e070e660e..9087a589500 100644 --- a/go/ql/test/query-tests/RedundantCode/CompareIdenticalValues/vp.go +++ b/go/ql/test/query-tests/RedundantCode/CompareIdenticalValues/vp.go @@ -13,5 +13,5 @@ type t struct { } func (x *t) foo(other t) bool { - return x.GetLength() != x.GetLength() + return x.GetLength() != x.GetLength() // $ Alert } diff --git a/go/ql/test/query-tests/RedundantCode/DeadStoreOfField/DeadStoreOfField.go b/go/ql/test/query-tests/RedundantCode/DeadStoreOfField/DeadStoreOfField.go index b74b7312a7f..7e1328e5a33 100644 --- a/go/ql/test/query-tests/RedundantCode/DeadStoreOfField/DeadStoreOfField.go +++ b/go/ql/test/query-tests/RedundantCode/DeadStoreOfField/DeadStoreOfField.go @@ -5,5 +5,5 @@ type counter struct { } func (w counter) reset() { - w.val = 0 // NOT OK + w.val = 0 // $ Alert // NOT OK } diff --git a/go/ql/test/query-tests/RedundantCode/DeadStoreOfField/DeadStoreOfField.qlref b/go/ql/test/query-tests/RedundantCode/DeadStoreOfField/DeadStoreOfField.qlref index 90aa8beb7ad..1fa9500a954 100644 --- a/go/ql/test/query-tests/RedundantCode/DeadStoreOfField/DeadStoreOfField.qlref +++ b/go/ql/test/query-tests/RedundantCode/DeadStoreOfField/DeadStoreOfField.qlref @@ -1 +1,2 @@ -RedundantCode/DeadStoreOfField.ql +query: RedundantCode/DeadStoreOfField.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/RedundantCode/DeadStoreOfLocal/DeadStoreOfLocal.qlref b/go/ql/test/query-tests/RedundantCode/DeadStoreOfLocal/DeadStoreOfLocal.qlref index 9acb5d81615..5e4405270c0 100644 --- a/go/ql/test/query-tests/RedundantCode/DeadStoreOfLocal/DeadStoreOfLocal.qlref +++ b/go/ql/test/query-tests/RedundantCode/DeadStoreOfLocal/DeadStoreOfLocal.qlref @@ -1 +1,2 @@ -RedundantCode/DeadStoreOfLocal.ql +query: RedundantCode/DeadStoreOfLocal.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/RedundantCode/DeadStoreOfLocal/main.go b/go/ql/test/query-tests/RedundantCode/DeadStoreOfLocal/main.go index 31062a18f98..ee7b9214a66 100644 --- a/go/ql/test/query-tests/RedundantCode/DeadStoreOfLocal/main.go +++ b/go/ql/test/query-tests/RedundantCode/DeadStoreOfLocal/main.go @@ -22,7 +22,7 @@ func main() { } func deadParameter(x int) bool { // we don't want to flag x here - x = deadStore() // but we do want to flag this + x = deadStore() // $ Alert // but we do want to flag this return true } diff --git a/go/ql/test/query-tests/RedundantCode/DeadStoreOfLocal/testdata.go b/go/ql/test/query-tests/RedundantCode/DeadStoreOfLocal/testdata.go index dad31ebd1ae..da7d6db82c3 100644 --- a/go/ql/test/query-tests/RedundantCode/DeadStoreOfLocal/testdata.go +++ b/go/ql/test/query-tests/RedundantCode/DeadStoreOfLocal/testdata.go @@ -29,12 +29,12 @@ func _() { func _() { var x int _ = x - x = deadStore() // BAD + x = deadStore() // $ Alert // BAD } func _() { var x int - x = deadStore() // BAD + x = deadStore() // $ Alert // BAD x = 0 _ = x } @@ -58,13 +58,13 @@ func _() { } func _() { - x := deadStore2() // BAD + x := deadStore2() // $ Alert // BAD x = "def" _ = x } func _() { - x := deadStore() // BAD + x := deadStore() // $ Alert // BAD x = 0 _ = x } @@ -96,18 +96,18 @@ func _() { } func _() { - x := deadStore() // BAD + x := deadStore() // $ Alert // BAD if b { - x = deadStore() // BAD + x = deadStore() // $ Alert // BAD } x = 0 _ = x } func _() { - x := deadStore() // BAD + x := deadStore() // $ Alert // BAD for b { - x = deadStore() // BAD + x = deadStore() // $ Alert // BAD } x = 0 _ = x @@ -125,13 +125,13 @@ func _() { } func _() { - x := deadStore() // BAD + x := deadStore() // $ Alert // BAD if b { - x = deadStore() // BAD - x = deadStore() // BAD + x = deadStore() // $ Alert // BAD + x = deadStore() // $ Alert // BAD } if b { - x = deadStore() // BAD + x = deadStore() // $ Alert // BAD } x = 0 _ = x @@ -140,7 +140,7 @@ func _() { func _() { x := 0 if b { - x = deadStore() // BAD + x = deadStore() // $ Alert // BAD x = 0 } if b { @@ -161,7 +161,7 @@ func _() { x := 0 for { _ = x - x = deadStore() // BAD + x = deadStore() // $ Alert // BAD x = 0 } } @@ -169,7 +169,7 @@ func _() { func _() { x := 0 for { - x += deadStore() // BAD + x += deadStore() // $ Alert // BAD x = 0 } } @@ -177,7 +177,7 @@ func _() { func _() { x := 0 for { - x++ // BAD + x++ // $ Alert // BAD x = 0 } } @@ -198,7 +198,7 @@ func _() { func _() { x := struct{ f int }{42} _ = x.f - x = struct{ f int }{23} + x = struct{ f int }{23} // $ Alert } func _() { @@ -259,13 +259,13 @@ func _() (x int) { } func _() (x int) { - x = deadStore() // BAD + x = deadStore() // $ Alert // BAD x = 0 return } func _() (x int) { - x = deadStore() // BAD + x = deadStore() // $ Alert // BAD return 0 } @@ -306,7 +306,7 @@ func _(a float32, b float32) (x int) { func _(a float32, b float32) (x int) { x = 1 - a /= b + a /= b // $ Alert return 2 } @@ -318,7 +318,7 @@ func _(a int, b int) (x int) { func _(a int, b int) (x int) { x = 1 - a %= b + a %= b // $ Alert return 2 } @@ -384,7 +384,7 @@ func _() { case true: _ = x default: - x = deadStore() // BAD + x = deadStore() // $ Alert // BAD fallthrough case b: } @@ -429,16 +429,16 @@ func _() { var ch chan int select { case ch <- 0: - x = deadStore() // BAD + x = deadStore() // $ Alert // BAD case <-ch: - x = deadStore() // BAD + x = deadStore() // $ Alert // BAD default: _ = x } } func _() { - x := deadStore() // BAD + x := deadStore() // $ Alert // BAD var ch chan int select { case ch <- 0: @@ -485,7 +485,7 @@ func _() { func _() { var x int if b { - x = deadStore() // BAD + x = deadStore() // $ Alert // BAD } if x = 0; b { @@ -539,7 +539,7 @@ func _() { func _() { x := 0 for x < 0 { - x = deadStore() // BAD + x = deadStore() // $ Alert // BAD if b { break } @@ -577,7 +577,7 @@ func _() { var x int for { if b { - x = deadStore() // BAD + x = deadStore() // $ Alert // BAD break } _ = x @@ -626,7 +626,7 @@ func _(v1, v2 int32) (int32, int32) { func _(v1, v2 int32) (int32, int32) { if v1 > v2 { - v1, _ = v2, v1 + v1, _ = v2, v1 // $ Alert } v1, v2 = 0, 0 return v1, v2 diff --git a/go/ql/test/query-tests/RedundantCode/DuplicateBranches/DuplicateBranches.go b/go/ql/test/query-tests/RedundantCode/DuplicateBranches/DuplicateBranches.go index f4bc36b63fe..1f163c2867f 100644 --- a/go/ql/test/query-tests/RedundantCode/DuplicateBranches/DuplicateBranches.go +++ b/go/ql/test/query-tests/RedundantCode/DuplicateBranches/DuplicateBranches.go @@ -1,7 +1,7 @@ package main func abs(x int) int { - if x >= 0 { + if x >= 0 { // $ Alert return x } else { return x diff --git a/go/ql/test/query-tests/RedundantCode/DuplicateBranches/DuplicateBranches.qlref b/go/ql/test/query-tests/RedundantCode/DuplicateBranches/DuplicateBranches.qlref index 3eb10d9d91f..a32bc6c31f1 100644 --- a/go/ql/test/query-tests/RedundantCode/DuplicateBranches/DuplicateBranches.qlref +++ b/go/ql/test/query-tests/RedundantCode/DuplicateBranches/DuplicateBranches.qlref @@ -1 +1,2 @@ -RedundantCode/DuplicateBranches.ql +query: RedundantCode/DuplicateBranches.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/RedundantCode/DuplicateBranches/main.go b/go/ql/test/query-tests/RedundantCode/DuplicateBranches/main.go index 0a524b094a7..9e367783550 100644 --- a/go/ql/test/query-tests/RedundantCode/DuplicateBranches/main.go +++ b/go/ql/test/query-tests/RedundantCode/DuplicateBranches/main.go @@ -3,7 +3,7 @@ package main import "fmt" func bad(x int) { - if x < 0 { // NOT OK + if x < 0 { // $ Alert // NOT OK fmt.Println("x is negative") } else { fmt.Println("x is negative") diff --git a/go/ql/test/query-tests/RedundantCode/DuplicateCondition/DuplicateCondition.go b/go/ql/test/query-tests/RedundantCode/DuplicateCondition/DuplicateCondition.go index a93bb546c42..2ad4ad8e0e4 100644 --- a/go/ql/test/query-tests/RedundantCode/DuplicateCondition/DuplicateCondition.go +++ b/go/ql/test/query-tests/RedundantCode/DuplicateCondition/DuplicateCondition.go @@ -1,9 +1,9 @@ package main func controller(msg string) { - if msg == "start" { + if msg == "start" { // $ Source start() - } else if msg == "start" { // NOT OK + } else if msg == "start" { // $ Alert // NOT OK stop() } else { panic("Message not understood.") diff --git a/go/ql/test/query-tests/RedundantCode/DuplicateCondition/DuplicateCondition.qlref b/go/ql/test/query-tests/RedundantCode/DuplicateCondition/DuplicateCondition.qlref index a6069ea94ad..36bb8140f1a 100644 --- a/go/ql/test/query-tests/RedundantCode/DuplicateCondition/DuplicateCondition.qlref +++ b/go/ql/test/query-tests/RedundantCode/DuplicateCondition/DuplicateCondition.qlref @@ -1 +1,2 @@ -RedundantCode/DuplicateCondition.ql +query: RedundantCode/DuplicateCondition.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/RedundantCode/DuplicateCondition/tst.go b/go/ql/test/query-tests/RedundantCode/DuplicateCondition/tst.go index 912f13fef7e..60e88d978f6 100644 --- a/go/ql/test/query-tests/RedundantCode/DuplicateCondition/tst.go +++ b/go/ql/test/query-tests/RedundantCode/DuplicateCondition/tst.go @@ -5,8 +5,8 @@ func check(x int) bool { } func main() { - if ok := check(42); ok { - } else if ok { // NOT OK + if ok := check(42); ok { // $ Source + } else if ok { // $ Alert // NOT OK } else if ok := check(23); ok { // OK } } diff --git a/go/ql/test/query-tests/RedundantCode/DuplicateSwitchCase/DuplicateSwitchCase.go b/go/ql/test/query-tests/RedundantCode/DuplicateSwitchCase/DuplicateSwitchCase.go index 1c902c1328b..d2b1d320f33 100644 --- a/go/ql/test/query-tests/RedundantCode/DuplicateSwitchCase/DuplicateSwitchCase.go +++ b/go/ql/test/query-tests/RedundantCode/DuplicateSwitchCase/DuplicateSwitchCase.go @@ -4,7 +4,7 @@ func controller(msg string) { switch { case msg == "start": start() - case msg == "start": + case msg == "start": // $ Alert stop() default: panic("Message not understood.") diff --git a/go/ql/test/query-tests/RedundantCode/DuplicateSwitchCase/DuplicateSwitchCase.qlref b/go/ql/test/query-tests/RedundantCode/DuplicateSwitchCase/DuplicateSwitchCase.qlref index 570b78b5054..005bb508043 100644 --- a/go/ql/test/query-tests/RedundantCode/DuplicateSwitchCase/DuplicateSwitchCase.qlref +++ b/go/ql/test/query-tests/RedundantCode/DuplicateSwitchCase/DuplicateSwitchCase.qlref @@ -1 +1,2 @@ -RedundantCode/DuplicateSwitchCase.ql +query: RedundantCode/DuplicateSwitchCase.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/RedundantCode/DuplicateSwitchCase/tst.go b/go/ql/test/query-tests/RedundantCode/DuplicateSwitchCase/tst.go index c927cd3d686..235be408143 100644 --- a/go/ql/test/query-tests/RedundantCode/DuplicateSwitchCase/tst.go +++ b/go/ql/test/query-tests/RedundantCode/DuplicateSwitchCase/tst.go @@ -6,7 +6,7 @@ func check(x int) { case x < 42: - case x < 23: // NOT OK + case x < 23: // $ Alert // NOT OK } } diff --git a/go/ql/test/query-tests/RedundantCode/ExprHasNoEffect/ExprHasNoEffect.go b/go/ql/test/query-tests/RedundantCode/ExprHasNoEffect/ExprHasNoEffect.go index 3c8b85f1e67..3b647bc2a8a 100644 --- a/go/ql/test/query-tests/RedundantCode/ExprHasNoEffect/ExprHasNoEffect.go +++ b/go/ql/test/query-tests/RedundantCode/ExprHasNoEffect/ExprHasNoEffect.go @@ -10,6 +10,6 @@ func (t Timestamp) addDays(d int) Timestamp { func test(t Timestamp) { fmt.Printf("Before: %s\n", t) - t.addDays(7) + t.addDays(7) // $ Alert fmt.Printf("After: %s\n", t) } diff --git a/go/ql/test/query-tests/RedundantCode/ExprHasNoEffect/ExprHasNoEffect.qlref b/go/ql/test/query-tests/RedundantCode/ExprHasNoEffect/ExprHasNoEffect.qlref index d13ada43194..bb442613246 100644 --- a/go/ql/test/query-tests/RedundantCode/ExprHasNoEffect/ExprHasNoEffect.qlref +++ b/go/ql/test/query-tests/RedundantCode/ExprHasNoEffect/ExprHasNoEffect.qlref @@ -1 +1,2 @@ -RedundantCode/ExprHasNoEffect.ql +query: RedundantCode/ExprHasNoEffect.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/RedundantCode/ExprHasNoEffect/main.go b/go/ql/test/query-tests/RedundantCode/ExprHasNoEffect/main.go index e9c18030df5..960260b1fce 100644 --- a/go/ql/test/query-tests/RedundantCode/ExprHasNoEffect/main.go +++ b/go/ql/test/query-tests/RedundantCode/ExprHasNoEffect/main.go @@ -23,10 +23,10 @@ func div(x int, y int) int { } func main() { - f1(42) // NOT OK + f1(42) // $ Alert // NOT OK f2(42) // OK - f1(f2(42)) // NOT OK - abs(-2) // NOT OK + f1(f2(42)) // $ Alert // NOT OK + abs(-2) // $ Alert // NOT OK div(1, 0) // OK dostuff() // OK cleanup() // OK diff --git a/go/ql/test/query-tests/RedundantCode/ImpossibleInterfaceNilCheck/ImpossibleInterfaceNilCheck.go b/go/ql/test/query-tests/RedundantCode/ImpossibleInterfaceNilCheck/ImpossibleInterfaceNilCheck.go index 00b015d3814..f0013365e1f 100644 --- a/go/ql/test/query-tests/RedundantCode/ImpossibleInterfaceNilCheck/ImpossibleInterfaceNilCheck.go +++ b/go/ql/test/query-tests/RedundantCode/ImpossibleInterfaceNilCheck/ImpossibleInterfaceNilCheck.go @@ -6,7 +6,7 @@ func niceFetch(url string) { var s string var e error s, e = fetch(url) - if e != nil { + if e != nil { // $ Alert fmt.Printf("Unable to fetch URL: %v\n", e) } else { fmt.Printf("URL contents: %s\n", s) diff --git a/go/ql/test/query-tests/RedundantCode/ImpossibleInterfaceNilCheck/ImpossibleInterfaceNilCheck.qlref b/go/ql/test/query-tests/RedundantCode/ImpossibleInterfaceNilCheck/ImpossibleInterfaceNilCheck.qlref index d858724be57..0049d67433a 100644 --- a/go/ql/test/query-tests/RedundantCode/ImpossibleInterfaceNilCheck/ImpossibleInterfaceNilCheck.qlref +++ b/go/ql/test/query-tests/RedundantCode/ImpossibleInterfaceNilCheck/ImpossibleInterfaceNilCheck.qlref @@ -1 +1,2 @@ -RedundantCode/ImpossibleInterfaceNilCheck.ql +query: RedundantCode/ImpossibleInterfaceNilCheck.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/RedundantCode/ImpossibleInterfaceNilCheck/tst.go b/go/ql/test/query-tests/RedundantCode/ImpossibleInterfaceNilCheck/tst.go index 81584045c13..e7716a7584a 100644 --- a/go/ql/test/query-tests/RedundantCode/ImpossibleInterfaceNilCheck/tst.go +++ b/go/ql/test/query-tests/RedundantCode/ImpossibleInterfaceNilCheck/tst.go @@ -7,7 +7,7 @@ func test1() { var y interface{} = x fmt.Println(x == nil) fmt.Println(x == y) - fmt.Println(y == nil) // NOT OK + fmt.Println(y == nil) // $ Alert // NOT OK } func test2() { diff --git a/go/ql/test/query-tests/RedundantCode/NegativeLengthCheck/NegativeLengthCheck.go b/go/ql/test/query-tests/RedundantCode/NegativeLengthCheck/NegativeLengthCheck.go index 6ebdb224ee1..9c7460b9432 100644 --- a/go/ql/test/query-tests/RedundantCode/NegativeLengthCheck/NegativeLengthCheck.go +++ b/go/ql/test/query-tests/RedundantCode/NegativeLengthCheck/NegativeLengthCheck.go @@ -1,7 +1,7 @@ package main func getFirst(xs []int) int { - if len(xs) < 0 { + if len(xs) < 0 { // $ Alert panic("No elements provided") } return xs[0] diff --git a/go/ql/test/query-tests/RedundantCode/NegativeLengthCheck/NegativeLengthCheck.qlref b/go/ql/test/query-tests/RedundantCode/NegativeLengthCheck/NegativeLengthCheck.qlref index d3e9be220bf..de3ae728414 100644 --- a/go/ql/test/query-tests/RedundantCode/NegativeLengthCheck/NegativeLengthCheck.qlref +++ b/go/ql/test/query-tests/RedundantCode/NegativeLengthCheck/NegativeLengthCheck.qlref @@ -1 +1,2 @@ -RedundantCode/NegativeLengthCheck.ql +query: RedundantCode/NegativeLengthCheck.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/RedundantCode/NegativeLengthCheck/main.go b/go/ql/test/query-tests/RedundantCode/NegativeLengthCheck/main.go index f43f4851c5f..9b145e293e2 100644 --- a/go/ql/test/query-tests/RedundantCode/NegativeLengthCheck/main.go +++ b/go/ql/test/query-tests/RedundantCode/NegativeLengthCheck/main.go @@ -3,7 +3,7 @@ package main import "os" func main() { - if len(os.Args) < 0 { // NOT OK + if len(os.Args) < 0 { // $ Alert // NOT OK println("No arguments provided.") } @@ -11,21 +11,21 @@ func main() { println("No arguments provided.") } - if cap(os.Args) < 0 { // NOT OK + if cap(os.Args) < 0 { // $ Alert // NOT OK println("Out of space!") } - if len(os.Args) <= -1 { // NOT OK + if len(os.Args) <= -1 { // $ Alert // NOT OK println("No arguments provided.") } - if len(os.Args) == -1 { // NOT OK + if len(os.Args) == -1 { // $ Alert // NOT OK println("No arguments provided.") } } func checkNegative(x uint) bool { - return x < 0 // NOT OK + return x < 0 // $ Alert // NOT OK } func checkNonPositive(x uint) bool { diff --git a/go/ql/test/query-tests/RedundantCode/RedundantExpr/RedundantExpr.go b/go/ql/test/query-tests/RedundantCode/RedundantExpr/RedundantExpr.go index 033f3883b0a..283d0552be8 100644 --- a/go/ql/test/query-tests/RedundantCode/RedundantExpr/RedundantExpr.go +++ b/go/ql/test/query-tests/RedundantCode/RedundantExpr/RedundantExpr.go @@ -1,5 +1,5 @@ package main func avg(x, y float64) float64 { - return (x + x) / 2 + return (x + x) / 2 // $ Alert } diff --git a/go/ql/test/query-tests/RedundantCode/RedundantExpr/RedundantExpr.qlref b/go/ql/test/query-tests/RedundantCode/RedundantExpr/RedundantExpr.qlref index 23a5db7b419..f9c95d27835 100644 --- a/go/ql/test/query-tests/RedundantCode/RedundantExpr/RedundantExpr.qlref +++ b/go/ql/test/query-tests/RedundantCode/RedundantExpr/RedundantExpr.qlref @@ -1 +1,2 @@ -RedundantCode/RedundantExpr.ql +query: RedundantCode/RedundantExpr.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/RedundantCode/RedundantExpr/tst.go b/go/ql/test/query-tests/RedundantCode/RedundantExpr/tst.go index e4106fb7bfa..1a0d38eb2fe 100644 --- a/go/ql/test/query-tests/RedundantCode/RedundantExpr/tst.go +++ b/go/ql/test/query-tests/RedundantCode/RedundantExpr/tst.go @@ -1,12 +1,12 @@ package main func foo(x int) int { - return x - x /* NOT OK */ + (x & x) /* NOT OK */ + return x - x /* NOT OK */ + (x & x) /* NOT OK */ // $ Alert } func bar(b bool, x float32) float32 { if b { - return (x + x) / 2 // NOT OK + return (x + x) / 2 // $ Alert // NOT OK } else { return (x * x) / 2 // OK } diff --git a/go/ql/test/query-tests/RedundantCode/RedundantRecover/RedundantRecover.qlref b/go/ql/test/query-tests/RedundantCode/RedundantRecover/RedundantRecover.qlref index c8997068734..3f91b000a4c 100644 --- a/go/ql/test/query-tests/RedundantCode/RedundantRecover/RedundantRecover.qlref +++ b/go/ql/test/query-tests/RedundantCode/RedundantRecover/RedundantRecover.qlref @@ -1 +1,2 @@ -RedundantCode/RedundantRecover.ql +query: RedundantCode/RedundantRecover.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/RedundantCode/RedundantRecover/RedundantRecover1.go b/go/ql/test/query-tests/RedundantCode/RedundantRecover/RedundantRecover1.go index d058dd0dfde..3a9cc3f9cc2 100644 --- a/go/ql/test/query-tests/RedundantCode/RedundantRecover/RedundantRecover1.go +++ b/go/ql/test/query-tests/RedundantCode/RedundantRecover/RedundantRecover1.go @@ -3,7 +3,7 @@ package main import "fmt" func callRecover1() { - if recover() != nil { + if recover() != nil { // $ Alert fmt.Printf("recovered") } } diff --git a/go/ql/test/query-tests/RedundantCode/RedundantRecover/RedundantRecover2.go b/go/ql/test/query-tests/RedundantCode/RedundantRecover/RedundantRecover2.go index 4365cb7c9fe..2627373ad27 100644 --- a/go/ql/test/query-tests/RedundantCode/RedundantRecover/RedundantRecover2.go +++ b/go/ql/test/query-tests/RedundantCode/RedundantRecover/RedundantRecover2.go @@ -1,6 +1,6 @@ package main func fun2() { - defer recover() + defer recover() // $ Alert panic("2") } diff --git a/go/ql/test/query-tests/RedundantCode/RedundantRecover/tst.go b/go/ql/test/query-tests/RedundantCode/RedundantRecover/tst.go index 0533a060931..c9bebbd4bfe 100644 --- a/go/ql/test/query-tests/RedundantCode/RedundantRecover/tst.go +++ b/go/ql/test/query-tests/RedundantCode/RedundantRecover/tst.go @@ -5,7 +5,7 @@ import "fmt" func callRecover3() { // This will have no effect because panics do not propagate down the stack, // only back up the stack - if recover() != nil { + if recover() != nil { // $ Alert fmt.Printf("recovered") } } diff --git a/go/ql/test/query-tests/RedundantCode/SelfAssignment/SelfAssignment.go b/go/ql/test/query-tests/RedundantCode/SelfAssignment/SelfAssignment.go index ab2e585e198..00b971db61a 100644 --- a/go/ql/test/query-tests/RedundantCode/SelfAssignment/SelfAssignment.go +++ b/go/ql/test/query-tests/RedundantCode/SelfAssignment/SelfAssignment.go @@ -9,5 +9,5 @@ func (r *Rect) setWidth(width int) { } func (r *Rect) setHeight(height int) { - height = height + height = height // $ Alert } diff --git a/go/ql/test/query-tests/RedundantCode/SelfAssignment/SelfAssignment.qlref b/go/ql/test/query-tests/RedundantCode/SelfAssignment/SelfAssignment.qlref index 3eebdc5dc73..fcdd1725603 100644 --- a/go/ql/test/query-tests/RedundantCode/SelfAssignment/SelfAssignment.qlref +++ b/go/ql/test/query-tests/RedundantCode/SelfAssignment/SelfAssignment.qlref @@ -1 +1,2 @@ -RedundantCode/SelfAssignment.ql +query: RedundantCode/SelfAssignment.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/RedundantCode/SelfAssignment/tst.go b/go/ql/test/query-tests/RedundantCode/SelfAssignment/tst.go index 31a556ce551..fef980cdc15 100644 --- a/go/ql/test/query-tests/RedundantCode/SelfAssignment/tst.go +++ b/go/ql/test/query-tests/RedundantCode/SelfAssignment/tst.go @@ -2,5 +2,5 @@ package main func main() { x := 42 - x = x // NOT OK + x = x // $ Alert // NOT OK } diff --git a/go/ql/test/query-tests/RedundantCode/ShiftOutOfRange/ShiftOutOfRange.go b/go/ql/test/query-tests/RedundantCode/ShiftOutOfRange/ShiftOutOfRange.go index aaa05763ce2..64d1383393d 100644 --- a/go/ql/test/query-tests/RedundantCode/ShiftOutOfRange/ShiftOutOfRange.go +++ b/go/ql/test/query-tests/RedundantCode/ShiftOutOfRange/ShiftOutOfRange.go @@ -1,7 +1,7 @@ package main func shift(base int32) int32 { - return base << 40 + return base << 40 // $ Alert } var x1 = shift(1) diff --git a/go/ql/test/query-tests/RedundantCode/ShiftOutOfRange/ShiftOutOfRange.qlref b/go/ql/test/query-tests/RedundantCode/ShiftOutOfRange/ShiftOutOfRange.qlref index 223322f9776..2920410dfeb 100644 --- a/go/ql/test/query-tests/RedundantCode/ShiftOutOfRange/ShiftOutOfRange.qlref +++ b/go/ql/test/query-tests/RedundantCode/ShiftOutOfRange/ShiftOutOfRange.qlref @@ -1 +1,2 @@ -RedundantCode/ShiftOutOfRange.ql +query: RedundantCode/ShiftOutOfRange.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/RedundantCode/ShiftOutOfRange/main.go b/go/ql/test/query-tests/RedundantCode/ShiftOutOfRange/main.go index 4afb91d1750..22d68cc6bac 100644 --- a/go/ql/test/query-tests/RedundantCode/ShiftOutOfRange/main.go +++ b/go/ql/test/query-tests/RedundantCode/ShiftOutOfRange/main.go @@ -1,15 +1,15 @@ package main func bad1(x uint8) uint8 { - return x << 8 // NOT OK + return x << 8 // $ Alert // NOT OK } func bad2(y int32) int32 { - return y >> 33 // NOT OK + return y >> 33 // $ Alert // NOT OK } func bad3(z int) int { - return z << 64 // NOT OK + return z << 64 // $ Alert // NOT OK } func good1(x uint8) uint8 { diff --git a/go/ql/test/query-tests/RedundantCode/UnreachableStatement/UnreachableStatement.go b/go/ql/test/query-tests/RedundantCode/UnreachableStatement/UnreachableStatement.go index 10250238158..a11218b99e1 100644 --- a/go/ql/test/query-tests/RedundantCode/UnreachableStatement/UnreachableStatement.go +++ b/go/ql/test/query-tests/RedundantCode/UnreachableStatement/UnreachableStatement.go @@ -2,7 +2,7 @@ package main func mul(xs []int) int { res := 1 - for i := 0; i < len(xs); i++ { + for i := 0; i < len(xs); i++ { // $ Alert x := xs[i] res *= x if res == 0 { diff --git a/go/ql/test/query-tests/RedundantCode/UnreachableStatement/UnreachableStatement.qlref b/go/ql/test/query-tests/RedundantCode/UnreachableStatement/UnreachableStatement.qlref index 645ea622227..a705d9b8cff 100644 --- a/go/ql/test/query-tests/RedundantCode/UnreachableStatement/UnreachableStatement.qlref +++ b/go/ql/test/query-tests/RedundantCode/UnreachableStatement/UnreachableStatement.qlref @@ -1 +1,2 @@ -RedundantCode/UnreachableStatement.ql +query: RedundantCode/UnreachableStatement.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/RedundantCode/UnreachableStatement/main.go b/go/ql/test/query-tests/RedundantCode/UnreachableStatement/main.go index 7903ef1ef84..cc26b717f60 100644 --- a/go/ql/test/query-tests/RedundantCode/UnreachableStatement/main.go +++ b/go/ql/test/query-tests/RedundantCode/UnreachableStatement/main.go @@ -10,16 +10,16 @@ func reachable() {} func test1() { return - unreachable() // NOT OK + unreachable() // $ Alert // NOT OK } func test2() { select {} - unreachable() // NOT OK + unreachable() // $ Alert // NOT OK } func test3() { - for i := 0; i < 10; unreachable() { // NOT OK + for i := 0; i < 10; unreachable() { // $ Alert // NOT OK return } } @@ -27,7 +27,7 @@ func test3() { func test4() { for true { } - unreachable() // NOT OK + unreachable() // $ Alert // NOT OK } func test5(cond bool) { @@ -46,15 +46,15 @@ func test6(cond bool) { } reachable() } - unreachable() // NOT OK + unreachable() // $ Alert // NOT OK } func test7(cond bool) { for true { continue - unreachable() // NOT OK + unreachable() // $ Alert // NOT OK } - unreachable() // NOT OK + unreachable() // $ Alert // NOT OK } func test8() { @@ -138,25 +138,25 @@ func test16() *mystruct { select {} // Flagged, as `return nil` is possible and preferable when the // return site is unreachable. - return &mystruct{0, true} + return &mystruct{0, true} // $ Alert } func test17() int { select {} // Flagged, as a nontrivial unreachable return - return test10(1) + return test10(1) // $ Alert } func test18() bool { select {} // Flagged, as a nontrivial unreachable return - return test10(1) == 1 + return test10(1) == 1 // $ Alert } func test19() mystruct { select {} // Flagged, as a nontrivial unreachable return - return mystruct{test10(1), test10(2) == 2} + return mystruct{test10(1), test10(2) == 2} // $ Alert } func main() {} diff --git a/go/ql/test/query-tests/Security/CWE-020/IncompleteHostnameRegexp/IncompleteHostnameRegexp.go b/go/ql/test/query-tests/Security/CWE-020/IncompleteHostnameRegexp/IncompleteHostnameRegexp.go index 073c8555efc..3f290ccf983 100644 --- a/go/ql/test/query-tests/Security/CWE-020/IncompleteHostnameRegexp/IncompleteHostnameRegexp.go +++ b/go/ql/test/query-tests/Security/CWE-020/IncompleteHostnameRegexp/IncompleteHostnameRegexp.go @@ -8,8 +8,8 @@ import ( func checkRedirect(req *http.Request, via []*http.Request) error { // BAD: the host of `req.URL` may be controlled by an attacker - re := "^((www|beta).)?example.com/" - if matched, _ := regexp.MatchString(re, req.URL.Host); matched { + re := "^((www|beta).)?example.com/" // $ Alert + if matched, _ := regexp.MatchString(re, req.URL.Host); matched { // $ Sink return nil } return errors.New("Invalid redirect") diff --git a/go/ql/test/query-tests/Security/CWE-020/IncompleteHostnameRegexp/IncompleteHostnameRegexp.qlref b/go/ql/test/query-tests/Security/CWE-020/IncompleteHostnameRegexp/IncompleteHostnameRegexp.qlref index 88d20f52eee..0a6dac4bded 100644 --- a/go/ql/test/query-tests/Security/CWE-020/IncompleteHostnameRegexp/IncompleteHostnameRegexp.qlref +++ b/go/ql/test/query-tests/Security/CWE-020/IncompleteHostnameRegexp/IncompleteHostnameRegexp.qlref @@ -1,2 +1,4 @@ query: Security/CWE-020/IncompleteHostnameRegexp.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-020/IncompleteHostnameRegexp/main.go b/go/ql/test/query-tests/Security/CWE-020/IncompleteHostnameRegexp/main.go index 7eda0d7255a..d677cab50d4 100644 --- a/go/ql/test/query-tests/Security/CWE-020/IncompleteHostnameRegexp/main.go +++ b/go/ql/test/query-tests/Security/CWE-020/IncompleteHostnameRegexp/main.go @@ -37,30 +37,30 @@ func proxy() { HandleConnect(goproxy.AlwaysReject) // OK (rejecting all requests) proxy.OnRequest(goproxy.ReqHostMatches(regexp.MustCompile("^test1.github.com$"))). DoFunc(reject) // OK (rejecting all requests) - proxy.OnRequest(goproxy.ReqHostMatches(regexp.MustCompile("^test2.github.com$"))). - DoFunc(sometimesReject) // NOT OK (sometimes accepts requests) + proxy.OnRequest(goproxy.ReqHostMatches(regexp.MustCompile("^test2.github.com$"))). // $ Alert + DoFunc(sometimesReject) // NOT OK (sometimes accepts requests) } func main() { - regexp.Match(`https://www.example.com`, []byte("")) // NOT OK + regexp.Match(`https://www.example.com`, []byte("")) // $ Alert // NOT OK regexp.Match(`https://www\.example\.com`, []byte("")) // OK } -const sourceConst = `https://www.example.com` +const sourceConst = `https://www.example.com` // $ Alert const firstHalfConst = `https://www.example.` func concatenateStrings() { firstHalf := `https://www.example.` regexp.Match(firstHalf+`com`, []byte("")) // MISSING: NOT OK - regexp.Match(firstHalfConst+`com`, []byte("")) // NOT OK + regexp.Match(firstHalfConst+`com`, []byte("")) // $ Alert // NOT OK - regexp.Match(`https://www.example.`+`com`, []byte("")) // NOT OK + regexp.Match(`https://www.example.`+`com`, []byte("")) // $ Alert // NOT OK } func avoidDuplicateResults() { localVar1 := sourceConst localVar2 := localVar1 localVar3 := localVar2 - regexp.Match(localVar3, []byte("")) // NOT OK + regexp.Match(localVar3, []byte("")) // $ Sink // NOT OK } diff --git a/go/ql/test/query-tests/Security/CWE-020/IncompleteUrlSchemeCheck/IncompleteUrlSchemeCheck.go b/go/ql/test/query-tests/Security/CWE-020/IncompleteUrlSchemeCheck/IncompleteUrlSchemeCheck.go index f38261a032d..69221d5c212 100644 --- a/go/ql/test/query-tests/Security/CWE-020/IncompleteUrlSchemeCheck/IncompleteUrlSchemeCheck.go +++ b/go/ql/test/query-tests/Security/CWE-020/IncompleteUrlSchemeCheck/IncompleteUrlSchemeCheck.go @@ -4,7 +4,7 @@ import "net/url" func sanitizeUrl(urlstr string) string { u, err := url.Parse(urlstr) - if err != nil || u.Scheme == "javascript" { + if err != nil || u.Scheme == "javascript" { // $ Alert return "about:blank" } return urlstr diff --git a/go/ql/test/query-tests/Security/CWE-020/IncompleteUrlSchemeCheck/IncompleteUrlSchemeCheck.qlref b/go/ql/test/query-tests/Security/CWE-020/IncompleteUrlSchemeCheck/IncompleteUrlSchemeCheck.qlref index b27571781b3..0c088087e99 100644 --- a/go/ql/test/query-tests/Security/CWE-020/IncompleteUrlSchemeCheck/IncompleteUrlSchemeCheck.qlref +++ b/go/ql/test/query-tests/Security/CWE-020/IncompleteUrlSchemeCheck/IncompleteUrlSchemeCheck.qlref @@ -1 +1,2 @@ -Security/CWE-020/IncompleteUrlSchemeCheck.ql +query: Security/CWE-020/IncompleteUrlSchemeCheck.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-020/IncompleteUrlSchemeCheck/main.go b/go/ql/test/query-tests/Security/CWE-020/IncompleteUrlSchemeCheck/main.go index ebe18f142f8..8b96f7c0af8 100644 --- a/go/ql/test/query-tests/Security/CWE-020/IncompleteUrlSchemeCheck/main.go +++ b/go/ql/test/query-tests/Security/CWE-020/IncompleteUrlSchemeCheck/main.go @@ -14,7 +14,7 @@ func test(urlstr string) { urlstr = strings.NewReplacer("\n", "", "\r", "", "\t", "", "\u0000", "").Replace(urlstr) urlstr = strings.ToLower(urlstr) - if strings.HasPrefix(urlstr, "javascript:") || strings.HasPrefix(urlstr, "data:") { // NOT OK + if strings.HasPrefix(urlstr, "javascript:") || strings.HasPrefix(urlstr, "data:") { // $ Alert // NOT OK return } } diff --git a/go/ql/test/query-tests/Security/CWE-020/MissingRegexpAnchor/MissingRegexpAnchor.go b/go/ql/test/query-tests/Security/CWE-020/MissingRegexpAnchor/MissingRegexpAnchor.go index 60cb9d5b6bb..6e7a567cb8c 100644 --- a/go/ql/test/query-tests/Security/CWE-020/MissingRegexpAnchor/MissingRegexpAnchor.go +++ b/go/ql/test/query-tests/Security/CWE-020/MissingRegexpAnchor/MissingRegexpAnchor.go @@ -8,7 +8,7 @@ import ( func checkRedirect2(req *http.Request, via []*http.Request) error { // BAD: the host of `req.URL` may be controlled by an attacker - re := "https?://www\\.example\\.com/" + re := "https?://www\\.example\\.com/" // $ Alert if matched, _ := regexp.MatchString(re, req.URL.String()); matched { return nil } diff --git a/go/ql/test/query-tests/Security/CWE-020/MissingRegexpAnchor/MissingRegexpAnchor.qlref b/go/ql/test/query-tests/Security/CWE-020/MissingRegexpAnchor/MissingRegexpAnchor.qlref index b03fcd14a59..ba73933077f 100644 --- a/go/ql/test/query-tests/Security/CWE-020/MissingRegexpAnchor/MissingRegexpAnchor.qlref +++ b/go/ql/test/query-tests/Security/CWE-020/MissingRegexpAnchor/MissingRegexpAnchor.qlref @@ -1 +1,2 @@ -Security/CWE-020/MissingRegexpAnchor.ql +query: Security/CWE-020/MissingRegexpAnchor.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-020/MissingRegexpAnchor/main.go b/go/ql/test/query-tests/Security/CWE-020/MissingRegexpAnchor/main.go index efd10b7a6e2..8674e2f2f38 100644 --- a/go/ql/test/query-tests/Security/CWE-020/MissingRegexpAnchor/main.go +++ b/go/ql/test/query-tests/Security/CWE-020/MissingRegexpAnchor/main.go @@ -6,36 +6,36 @@ import ( func main() { regexp.Match(`^a|`, []byte("")) // OK - regexp.Match(`^a|b`, []byte("")) // NOT OK + regexp.Match(`^a|b`, []byte("")) // $ Alert // NOT OK regexp.Match(`a|^b`, []byte("")) // OK regexp.Match(`^a|^b`, []byte("")) // OK - regexp.Match(`^a|b|c`, []byte("")) // NOT OK + regexp.Match(`^a|b|c`, []byte("")) // $ Alert // NOT OK regexp.Match(`a|^b|c`, []byte("")) // OK regexp.Match(`a|b|^c`, []byte("")) // OK regexp.Match(`^a|^b|c`, []byte("")) // OK regexp.Match(`(^a)|b`, []byte("")) // OK - regexp.Match(`^a|(b)`, []byte("")) // NOT OK + regexp.Match(`^a|(b)`, []byte("")) // $ Alert // NOT OK regexp.Match(`^a|(^b)`, []byte("")) // OK - regexp.Match(`^(a)|(b)`, []byte("")) // NOT OK + regexp.Match(`^(a)|(b)`, []byte("")) // $ Alert // NOT OK - regexp.Match(`a|b$`, []byte("")) // NOT OK + regexp.Match(`a|b$`, []byte("")) // $ Alert // NOT OK regexp.Match(`a$|b`, []byte("")) // OK regexp.Match(`a$|b$`, []byte("")) // OK - regexp.Match(`a|b|c$`, []byte("")) // NOT OK + regexp.Match(`a|b|c$`, []byte("")) // $ Alert // NOT OK regexp.Match(`a|b$|c`, []byte("")) // OK regexp.Match(`a$|b|c`, []byte("")) // OK regexp.Match(`a|b$|c$`, []byte("")) // OK regexp.Match(`a|(b$)`, []byte("")) // OK - regexp.Match(`(a)|b$`, []byte("")) // NOT OK + regexp.Match(`(a)|b$`, []byte("")) // $ Alert // NOT OK regexp.Match(`(a$)|b$`, []byte("")) // OK - regexp.Match(`(a)|(b)$`, []byte("")) // NOT OK + regexp.Match(`(a)|(b)$`, []byte("")) // $ Alert // NOT OK - regexp.Match(`https?://good.com`, []byte("http://evil.com/?http://good.com")) // NOT OK + regexp.Match(`https?://good.com`, []byte("http://evil.com/?http://good.com")) // $ Alert // NOT OK regexp.Match(`^https?://good.com`, []byte("http://evil.com/?http://good.com")) // OK - regexp.Match(`www\.example\.com`, []byte("")) // NOT OK + regexp.Match(`www\.example\.com`, []byte("")) // $ Alert // NOT OK regexp.Match(`^www\.example\.com`, []byte("")) // OK regexp.Match(`\Awww\.example\.com`, []byte("")) // OK regexp.Match(`www\.example\.com$`, []byte("")) // OK diff --git a/go/ql/test/query-tests/Security/CWE-020/SuspiciousCharacterInRegexp/SuspiciousCharacterInRegexp.go b/go/ql/test/query-tests/Security/CWE-020/SuspiciousCharacterInRegexp/SuspiciousCharacterInRegexp.go index d9f2199fd52..4194d79c262 100644 --- a/go/ql/test/query-tests/Security/CWE-020/SuspiciousCharacterInRegexp/SuspiciousCharacterInRegexp.go +++ b/go/ql/test/query-tests/Security/CWE-020/SuspiciousCharacterInRegexp/SuspiciousCharacterInRegexp.go @@ -3,7 +3,7 @@ package main import "regexp" func broken(hostNames []byte) string { - var hostRe = regexp.MustCompile("\bforbidden.host.org") + var hostRe = regexp.MustCompile("\bforbidden.host.org") // $ Alert if hostRe.Match(hostNames) { return "Must not target forbidden.host.org" } else { diff --git a/go/ql/test/query-tests/Security/CWE-020/SuspiciousCharacterInRegexp/SuspiciousCharacterInRegexp.qlref b/go/ql/test/query-tests/Security/CWE-020/SuspiciousCharacterInRegexp/SuspiciousCharacterInRegexp.qlref index 727f3528b23..17c2ba019cb 100644 --- a/go/ql/test/query-tests/Security/CWE-020/SuspiciousCharacterInRegexp/SuspiciousCharacterInRegexp.qlref +++ b/go/ql/test/query-tests/Security/CWE-020/SuspiciousCharacterInRegexp/SuspiciousCharacterInRegexp.qlref @@ -1 +1,2 @@ -Security/CWE-020/SuspiciousCharacterInRegexp.ql +query: Security/CWE-020/SuspiciousCharacterInRegexp.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-020/SuspiciousCharacterInRegexp/test.go b/go/ql/test/query-tests/Security/CWE-020/SuspiciousCharacterInRegexp/test.go index ff3da9b8496..a872de93073 100644 --- a/go/ql/test/query-tests/Security/CWE-020/SuspiciousCharacterInRegexp/test.go +++ b/go/ql/test/query-tests/Security/CWE-020/SuspiciousCharacterInRegexp/test.go @@ -4,23 +4,23 @@ import "regexp" func main() { // many backslashes - regexp.MustCompile("\a") // BAD + regexp.MustCompile("\a") // $ Alert // BAD regexp.MustCompile("\\a") - regexp.MustCompile("\\\a") // BAD - regexp.MustCompile("x\\\a") // BAD + regexp.MustCompile("\\\a") // $ Alert // BAD + regexp.MustCompile("x\\\a") // $ Alert // BAD regexp.MustCompile("\\\\a") - regexp.MustCompile("\\\\\a") // BAD + regexp.MustCompile("\\\\\a") // $ Alert // BAD regexp.MustCompile("\\\\\\a") - regexp.MustCompile("\\\\\\\a") // BAD + regexp.MustCompile("\\\\\\\a") // $ Alert // BAD regexp.MustCompile("\\\\\\\\a") - regexp.MustCompile("\\\\\\\\\a") // BAD + regexp.MustCompile("\\\\\\\\\a") // $ Alert // BAD regexp.MustCompile("\\\\\\\\\\a") // BAD: probably a mistake: - regexp.MustCompile("hello\aworld") - regexp.MustCompile("hello\\\aworld") - regexp.MustCompile("hello\bworld") - regexp.MustCompile("hello\\\bworld") + regexp.MustCompile("hello\aworld") // $ Alert + regexp.MustCompile("hello\\\aworld") // $ Alert + regexp.MustCompile("hello\bworld") // $ Alert + regexp.MustCompile("hello\\\bworld") // $ Alert // GOOD: more likely deliberate: regexp.MustCompile("hello\\aworld") regexp.MustCompile("hello\x07world") diff --git a/go/ql/test/query-tests/Security/CWE-022/GorillaMuxDefault/TaintedPath.qlref b/go/ql/test/query-tests/Security/CWE-022/GorillaMuxDefault/TaintedPath.qlref index 1e9166dd1ca..688f7b5136f 100644 --- a/go/ql/test/query-tests/Security/CWE-022/GorillaMuxDefault/TaintedPath.qlref +++ b/go/ql/test/query-tests/Security/CWE-022/GorillaMuxDefault/TaintedPath.qlref @@ -1,2 +1,4 @@ query: Security/CWE-022/TaintedPath.ql -postprocess: utils/test//PrettyPrintModels.ql \ No newline at end of file +postprocess: + - utils/test//PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-022/GorillaMuxSkipClean/MuxClean.go b/go/ql/test/query-tests/Security/CWE-022/GorillaMuxSkipClean/MuxClean.go index cb3b5d2a7b8..2767b5e6b5a 100644 --- a/go/ql/test/query-tests/Security/CWE-022/GorillaMuxSkipClean/MuxClean.go +++ b/go/ql/test/query-tests/Security/CWE-022/GorillaMuxSkipClean/MuxClean.go @@ -10,8 +10,8 @@ import ( // BAD: Gorilla's `Vars` is not a sanitizer as `Router.SkipClean` has been called func GorillaHandler(w http.ResponseWriter, r *http.Request) { - not_tainted_path := mux.Vars(r)["id"] - data, _ := ioutil.ReadFile(filepath.Join("/home/user/", not_tainted_path)) + not_tainted_path := mux.Vars(r)["id"] // $ Source + data, _ := ioutil.ReadFile(filepath.Join("/home/user/", not_tainted_path)) // $ Alert w.Write(data) } diff --git a/go/ql/test/query-tests/Security/CWE-022/GorillaMuxSkipClean/TaintedPath.qlref b/go/ql/test/query-tests/Security/CWE-022/GorillaMuxSkipClean/TaintedPath.qlref index 1e9166dd1ca..688f7b5136f 100644 --- a/go/ql/test/query-tests/Security/CWE-022/GorillaMuxSkipClean/TaintedPath.qlref +++ b/go/ql/test/query-tests/Security/CWE-022/GorillaMuxSkipClean/TaintedPath.qlref @@ -1,2 +1,4 @@ query: Security/CWE-022/TaintedPath.ql -postprocess: utils/test//PrettyPrintModels.ql \ No newline at end of file +postprocess: + - utils/test//PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-022/TaintedPath.go b/go/ql/test/query-tests/Security/CWE-022/TaintedPath.go index 65da5caecd2..812b56f7c94 100644 --- a/go/ql/test/query-tests/Security/CWE-022/TaintedPath.go +++ b/go/ql/test/query-tests/Security/CWE-022/TaintedPath.go @@ -12,14 +12,14 @@ import ( ) func handler(w http.ResponseWriter, r *http.Request) { - tainted_path := r.URL.Query()["path"][0] + tainted_path := r.URL.Query()["path"][0] // $ Source[go/path-injection] // BAD: This could read any file on the file system - data, _ := ioutil.ReadFile(tainted_path) + data, _ := ioutil.ReadFile(tainted_path) // $ Alert[go/path-injection] w.Write(data) // BAD: This could still read any file on the file system - data, _ = ioutil.ReadFile(filepath.Join("/home/user/", tainted_path)) + data, _ = ioutil.ReadFile(filepath.Join("/home/user/", tainted_path)) // $ Alert[go/path-injection] w.Write(data) // GOOD: This can only read inside the provided safe path @@ -71,7 +71,7 @@ func handler(w http.ResponseWriter, r *http.Request) { // BAD: Sanitized by path.Clean with a prepended '/' forcing interpretation // as an absolute path, however is not sufficient for Windows paths. - data, _ = ioutil.ReadFile(path.Clean("/" + tainted_path)) + data, _ = ioutil.ReadFile(path.Clean("/" + tainted_path)) // $ Alert[go/path-injection] w.Write(data) // GOOD: Multipart.Form.FileHeader.Filename sanitized by filepath.Base when calling ParseMultipartForm diff --git a/go/ql/test/query-tests/Security/CWE-022/TaintedPath.qlref b/go/ql/test/query-tests/Security/CWE-022/TaintedPath.qlref index 78ce25b1921..6eb2e94892f 100644 --- a/go/ql/test/query-tests/Security/CWE-022/TaintedPath.qlref +++ b/go/ql/test/query-tests/Security/CWE-022/TaintedPath.qlref @@ -1,2 +1,4 @@ query: Security/CWE-022/TaintedPath.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-022/UnsafeUnzipSymlink.go b/go/ql/test/query-tests/Security/CWE-022/UnsafeUnzipSymlink.go index 8a3016f9c31..66a8763a2b0 100644 --- a/go/ql/test/query-tests/Security/CWE-022/UnsafeUnzipSymlink.go +++ b/go/ql/test/query-tests/Security/CWE-022/UnsafeUnzipSymlink.go @@ -28,7 +28,7 @@ func unzipSymlinkBad(f io.Reader, target string) { break } if isRel(header.Linkname, target) && isRel(header.Name, target) { - os.Symlink(header.Linkname, header.Name) + os.Symlink(header.Linkname, header.Name) // $ Alert[go/unsafe-unzip-symlink] } } } @@ -40,7 +40,7 @@ func unzipSymlinkBadZip(f io.ReaderAt, target string) { linkNameBytes, _ := ioutil.ReadAll(linkData) linkName := string(linkNameBytes) if isRel(linkName, target) && isRel(header.Name, target) { - os.Symlink(linkName, header.Name) + os.Symlink(linkName, header.Name) // $ Alert[go/unsafe-unzip-symlink] } } } @@ -109,7 +109,7 @@ func getNextHeader(f *tar.Reader) (*tar.Header, error) { } func writeSymlink(linkName, fileName string) { - os.Symlink(linkName, fileName) + os.Symlink(linkName, fileName) // $ Sink[go/unsafe-unzip-symlink] } // BAD: a variant of `unzipSymlinkBad` where the tar-read and symlink @@ -123,7 +123,7 @@ func unzipSymlinkBadFactored(f io.Reader, target string) { break } if isRel(header.Linkname, target) && isRel(header.Name, target) { - writeSymlink(header.Linkname, header.Name) + writeSymlink(header.Linkname, header.Name) // $ Alert[go/unsafe-unzip-symlink] } } } diff --git a/go/ql/test/query-tests/Security/CWE-022/UnsafeUnzipSymlink.qlref b/go/ql/test/query-tests/Security/CWE-022/UnsafeUnzipSymlink.qlref index a40aa6194e1..5971b073735 100644 --- a/go/ql/test/query-tests/Security/CWE-022/UnsafeUnzipSymlink.qlref +++ b/go/ql/test/query-tests/Security/CWE-022/UnsafeUnzipSymlink.qlref @@ -1,2 +1,4 @@ query: Security/CWE-022/UnsafeUnzipSymlink.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-022/UnsafeUnzipSymlinkGood.go b/go/ql/test/query-tests/Security/CWE-022/UnsafeUnzipSymlinkGood.go index dde03db263d..d662246a9c2 100644 --- a/go/ql/test/query-tests/Security/CWE-022/UnsafeUnzipSymlinkGood.go +++ b/go/ql/test/query-tests/Security/CWE-022/UnsafeUnzipSymlinkGood.go @@ -58,7 +58,7 @@ func isRelGoodReadlink(candidate, target string) bool { if filepath.IsAbs(candidate) { return false } - realpath, err := os.Readlink(filepath.Join(target, candidate)) + realpath, err := os.Readlink(filepath.Join(target, candidate)) // $ Sink[go/zipslip] if err != nil { return false } @@ -69,7 +69,7 @@ func isRelGoodReadlink(candidate, target string) bool { func unzipSymlinkGoodReadlink(f io.Reader, target string) { r := tar.NewReader(f) for { - header, err := r.Next() + header, err := r.Next() // $ Alert[go/zipslip] if err != nil { break } diff --git a/go/ql/test/query-tests/Security/CWE-022/ZipSlip.go b/go/ql/test/query-tests/Security/CWE-022/ZipSlip.go index 1628eabbef9..936c3c8e9a2 100644 --- a/go/ql/test/query-tests/Security/CWE-022/ZipSlip.go +++ b/go/ql/test/query-tests/Security/CWE-022/ZipSlip.go @@ -11,6 +11,6 @@ func unzip(f string) { for _, f := range r.File { p, _ := filepath.Abs(f.Name) // BAD: This could overwrite any file on the file system - ioutil.WriteFile(p, []byte("present"), 0666) - } + ioutil.WriteFile(p, []byte("present"), 0666) // $ Sink[go/zipslip] + } // $ Alert[go/zipslip] } diff --git a/go/ql/test/query-tests/Security/CWE-022/ZipSlip.qlref b/go/ql/test/query-tests/Security/CWE-022/ZipSlip.qlref index da30bbaf10d..39acfb7ca4a 100644 --- a/go/ql/test/query-tests/Security/CWE-022/ZipSlip.qlref +++ b/go/ql/test/query-tests/Security/CWE-022/ZipSlip.qlref @@ -1,2 +1,4 @@ query: Security/CWE-022/ZipSlip.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-022/tarslip.go b/go/ql/test/query-tests/Security/CWE-022/tarslip.go index 37b3a32715c..f7e01ff0565 100644 --- a/go/ql/test/query-tests/Security/CWE-022/tarslip.go +++ b/go/ql/test/query-tests/Security/CWE-022/tarslip.go @@ -12,8 +12,8 @@ import ( func untarBad(reader io.Reader, prefix string) { tarReader := tar.NewReader(reader) - header, _ := tarReader.Next() - os.MkdirAll(path.Dir(header.Name), 0755) // NOT OK + header, _ := tarReader.Next() // $ Alert[go/zipslip] + os.MkdirAll(path.Dir(header.Name), 0755) // $ Sink[go/zipslip] // NOT OK } func untarGood(reader io.Reader, prefix string) { diff --git a/go/ql/test/query-tests/Security/CWE-022/tst.go b/go/ql/test/query-tests/Security/CWE-022/tst.go index 599faccf0f1..4cf3a77c4c8 100644 --- a/go/ql/test/query-tests/Security/CWE-022/tst.go +++ b/go/ql/test/query-tests/Security/CWE-022/tst.go @@ -26,7 +26,7 @@ func unzip2(f string, root string) { if err == nil { ioutil.WriteFile(filepath.Join(root, relpath), []byte("present"), 0666) // OK } - ioutil.WriteFile(path, []byte("present"), 0666) // NOT OK + ioutil.WriteFile(path, []byte("present"), 0666) // $ Sink[go/zipslip] // NOT OK if containedIn(path, root) { ioutil.WriteFile(path, []byte("present"), 0666) // OK } @@ -40,7 +40,7 @@ func unzip2(f string, root string) { if containedIn(f.Name, root) { ioutil.WriteFile(f.Name, []byte("present"), 0666) // OK } - } + } // $ Alert[go/zipslip] } func containedIn(f string, root string) bool { diff --git a/go/ql/test/query-tests/Security/CWE-078/ArgumentInjection.go b/go/ql/test/query-tests/Security/CWE-078/ArgumentInjection.go index d38d4662542..7519916afe0 100644 --- a/go/ql/test/query-tests/Security/CWE-078/ArgumentInjection.go +++ b/go/ql/test/query-tests/Security/CWE-078/ArgumentInjection.go @@ -6,7 +6,7 @@ import ( ) func handler2(req *http.Request) { - path := req.URL.Query()["path"][0] - cmd := exec.Command("rsync", path, "/tmp") + path := req.URL.Query()["path"][0] // $ Source[go/command-injection] + cmd := exec.Command("rsync", path, "/tmp") // $ Alert[go/command-injection] cmd.Run() } diff --git a/go/ql/test/query-tests/Security/CWE-078/CommandInjection.go b/go/ql/test/query-tests/Security/CWE-078/CommandInjection.go index ff046f24084..a8af53b7fc5 100644 --- a/go/ql/test/query-tests/Security/CWE-078/CommandInjection.go +++ b/go/ql/test/query-tests/Security/CWE-078/CommandInjection.go @@ -6,7 +6,7 @@ import ( ) func handler(req *http.Request) { - cmdName := req.URL.Query()["cmd"][0] - cmd := exec.Command(cmdName) + cmdName := req.URL.Query()["cmd"][0] // $ Source[go/command-injection] + cmd := exec.Command(cmdName) // $ Alert[go/command-injection] cmd.Run() } diff --git a/go/ql/test/query-tests/Security/CWE-078/CommandInjection.qlref b/go/ql/test/query-tests/Security/CWE-078/CommandInjection.qlref index 2b07372975f..b1836a682e3 100644 --- a/go/ql/test/query-tests/Security/CWE-078/CommandInjection.qlref +++ b/go/ql/test/query-tests/Security/CWE-078/CommandInjection.qlref @@ -1,2 +1,4 @@ query: Security/CWE-078/CommandInjection.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-078/CommandInjection2.go b/go/ql/test/query-tests/Security/CWE-078/CommandInjection2.go index 943a3f72f05..975ff72d177 100644 --- a/go/ql/test/query-tests/Security/CWE-078/CommandInjection2.go +++ b/go/ql/test/query-tests/Security/CWE-078/CommandInjection2.go @@ -10,9 +10,9 @@ import ( ) func handlerExample(req *http.Request) { - imageName := req.URL.Query()["imageName"][0] + imageName := req.URL.Query()["imageName"][0] // $ Source[go/command-injection] outputPath := "/tmp/output.svg" - cmd := exec.Command("sh", "-c", fmt.Sprintf("imagetool %s > %s", imageName, outputPath)) // NOT OK - correctly flagged + cmd := exec.Command("sh", "-c", fmt.Sprintf("imagetool %s > %s", imageName, outputPath)) // $ Alert[go/command-injection] // NOT OK - correctly flagged cmd.Run() // ... } @@ -38,10 +38,10 @@ func handlerExample2(req *http.Request) { } func handlerExample3(req *http.Request) { - imageName := req.URL.Query()["imageName"][0] + imageName := req.URL.Query()["imageName"][0] // $ Source[go/command-injection] outputPath := "/tmp/output.svg" - cmd := exec.Command("sh", "-c", fmt.Sprintf("imagetool %s > %s", imageName, outputPath)) // NOT OK - correctly flagged + cmd := exec.Command("sh", "-c", fmt.Sprintf("imagetool %s > %s", imageName, outputPath)) // $ Alert[go/command-injection] // NOT OK - correctly flagged cmd.Run() // Validate the imageName with a regular expression diff --git a/go/ql/test/query-tests/Security/CWE-078/GitSubcommands.go b/go/ql/test/query-tests/Security/CWE-078/GitSubcommands.go index 5e72e5825af..80322dcd27b 100644 --- a/go/ql/test/query-tests/Security/CWE-078/GitSubcommands.go +++ b/go/ql/test/query-tests/Security/CWE-078/GitSubcommands.go @@ -8,13 +8,13 @@ import ( // BAD: using git subcommands that are vulnerable to arbitrary remote command execution func gitSubcommandsBad(req *http.Request) { - tainted := req.URL.Query()["cmd"][0] + tainted := req.URL.Query()["cmd"][0] // $ Source[go/command-injection] - exec.Command("git", "clone", tainted) - exec.Command("git", "fetch", tainted) - exec.Command("git", "pull", tainted) - exec.Command("git", "ls-remote", tainted) - exec.Command("git", "fetch-pack", tainted) + exec.Command("git", "clone", tainted) // $ Alert[go/command-injection] + exec.Command("git", "fetch", tainted) // $ Alert[go/command-injection] + exec.Command("git", "pull", tainted) // $ Alert[go/command-injection] + exec.Command("git", "ls-remote", tainted) // $ Alert[go/command-injection] + exec.Command("git", "fetch-pack", tainted) // $ Alert[go/command-injection] } // GOOD: using a sampling of git subcommands that are not vulnerable to arbitrary remote command execution @@ -30,11 +30,11 @@ func gitSubcommandsGood(req *http.Request) { // BAD: using git subcommands that are vulnerable to arbitrary remote command execution func gitSubcommandsGood2(req *http.Request) { - tainted := req.URL.Query()["cmd"][0] + tainted := req.URL.Query()["cmd"][0] // $ Source[go/command-injection] if !strings.HasPrefix(tainted, "--") { exec.Command("git", "clone", tainted) // GOOD, `tainted` cannot start with "--" } else { - exec.Command("git", "clone", tainted) // BAD, `tainted` can start with "--" + exec.Command("git", "clone", tainted) // $ Alert[go/command-injection] // BAD, `tainted` can start with "--" } } diff --git a/go/ql/test/query-tests/Security/CWE-078/SanitizingDoubleDash.go b/go/ql/test/query-tests/Security/CWE-078/SanitizingDoubleDash.go index 0428df55086..9a8692319bb 100644 --- a/go/ql/test/query-tests/Security/CWE-078/SanitizingDoubleDash.go +++ b/go/ql/test/query-tests/Security/CWE-078/SanitizingDoubleDash.go @@ -6,12 +6,12 @@ import ( ) func testDoubleDashSanitizes(req *http.Request) { - tainted := req.URL.Query()["cmd"][0] + tainted := req.URL.Query()["cmd"][0] // $ Source[go/command-injection] // BAD: no sanitizing "--" preceding tainted data { arrayLit := [1]string{tainted} - exec.Command("git", arrayLit[:]...) + exec.Command("git", arrayLit[:]...) // $ Alert[go/command-injection] } // GOOD: sanitizing "--" preceding tainted data @@ -37,7 +37,7 @@ func testDoubleDashSanitizes(req *http.Request) { { arrayLit := []string{} arrayLit = append(arrayLit, tainted, "--") - exec.Command("git", arrayLit...) + exec.Command("git", arrayLit...) // $ Alert[go/command-injection] } // GOOD: sanitizing "--" preceding tainted data, built in two steps @@ -51,7 +51,7 @@ func testDoubleDashSanitizes(req *http.Request) { { arrayLit := []string{tainted} arrayLit = append(arrayLit, "--") - exec.Command("git", arrayLit...) + exec.Command("git", arrayLit...) // $ Alert[go/command-injection] } // GOOD: sanitizing "--" preceding tainted data, built in three steps @@ -67,7 +67,7 @@ func testDoubleDashSanitizes(req *http.Request) { arrayLit := []string{"something else"} arrayLit = append(arrayLit, tainted) arrayLit = append(arrayLit, "--") - exec.Command("git", arrayLit...) + exec.Command("git", arrayLit...) // $ Alert[go/command-injection] } // GOOD: sanitizing "--" preceding tainted data, used directly in a Command @@ -77,7 +77,7 @@ func testDoubleDashSanitizes(req *http.Request) { // BAD: sanitizing "--" comes after tainted data, used directly in a Command { - exec.Command("git", tainted, "--") + exec.Command("git", tainted, "--") // $ Alert[go/command-injection] } // GOOD: sanitizing "--" preceding tainted data, used directly in a Command, after several other arguments @@ -89,66 +89,66 @@ func testDoubleDashSanitizes(req *http.Request) { // This test mirrors testDoubleDashSanitizes above, but uses sudo instead of git, where "--" is not sanitizing. // All cases are therefore BAD. func testDoubleDashIrrelevant(req *http.Request) { - tainted := req.URL.Query()["cmd"][0] + tainted := req.URL.Query()["cmd"][0] // $ Source[go/command-injection] { arrayLit := [1]string{tainted} - exec.Command("sudo", arrayLit[:]...) // BAD + exec.Command("sudo", arrayLit[:]...) // $ Alert[go/command-injection] // BAD } { arrayLit := [2]string{"--", tainted} - exec.Command("sudo", arrayLit[:]...) // BAD + exec.Command("sudo", arrayLit[:]...) // $ Alert[go/command-injection] // BAD } { arrayLit := []string{"--", tainted} - exec.Command("sudo", arrayLit...) // BAD + exec.Command("sudo", arrayLit...) // $ Alert[go/command-injection] // BAD } { arrayLit := []string{} arrayLit = append(arrayLit, "--", tainted) - exec.Command("sudo", arrayLit...) // BAD + exec.Command("sudo", arrayLit...) // $ Alert[go/command-injection] // BAD } { arrayLit := []string{} arrayLit = append(arrayLit, tainted, "--") - exec.Command("sudo", arrayLit...) // BAD + exec.Command("sudo", arrayLit...) // $ Alert[go/command-injection] // BAD } { arrayLit := []string{"--"} arrayLit = append(arrayLit, tainted) - exec.Command("sudo", arrayLit...) // BAD + exec.Command("sudo", arrayLit...) // $ Alert[go/command-injection] // BAD } { arrayLit := []string{tainted} arrayLit = append(arrayLit, "--") - exec.Command("sudo", arrayLit...) // BAD + exec.Command("sudo", arrayLit...) // $ Alert[go/command-injection] // BAD } { arrayLit := []string{"--"} arrayLit = append(arrayLit, "something else") arrayLit = append(arrayLit, tainted) - exec.Command("sudo", arrayLit...) // BAD + exec.Command("sudo", arrayLit...) // $ Alert[go/command-injection] // BAD } { arrayLit := []string{"something else"} arrayLit = append(arrayLit, tainted) arrayLit = append(arrayLit, "--") - exec.Command("sudo", arrayLit...) // BAD + exec.Command("sudo", arrayLit...) // $ Alert[go/command-injection] // BAD } { - exec.Command("sudo", "--", tainted) // BAD + exec.Command("sudo", "--", tainted) // $ Alert[go/command-injection] // BAD } { - exec.Command("sudo", tainted, "--") // BAD + exec.Command("sudo", tainted, "--") // $ Alert[go/command-injection] // BAD } } diff --git a/go/ql/test/query-tests/Security/CWE-078/StoredCommand.go b/go/ql/test/query-tests/Security/CWE-078/StoredCommand.go index 5b7c16d0c59..ee38e54f4da 100644 --- a/go/ql/test/query-tests/Security/CWE-078/StoredCommand.go +++ b/go/ql/test/query-tests/Security/CWE-078/StoredCommand.go @@ -8,9 +8,9 @@ import ( var db *sql.DB func run(query string) { - rows, _ := db.Query(query) + rows, _ := db.Query(query) // $ Source[go/stored-command] var cmdName string rows.Scan(&cmdName) - cmd := exec.Command(cmdName) + cmd := exec.Command(cmdName) // $ Alert[go/stored-command] cmd.Run() } diff --git a/go/ql/test/query-tests/Security/CWE-078/StoredCommand.qlref b/go/ql/test/query-tests/Security/CWE-078/StoredCommand.qlref index 92c41892880..d1bc2b0f697 100644 --- a/go/ql/test/query-tests/Security/CWE-078/StoredCommand.qlref +++ b/go/ql/test/query-tests/Security/CWE-078/StoredCommand.qlref @@ -1,2 +1,4 @@ query: Security/CWE-078/StoredCommand.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-089/SqlInjection.go b/go/ql/test/query-tests/Security/CWE-089/SqlInjection.go index 0df976d93c3..9e36ea24c99 100644 --- a/go/ql/test/query-tests/Security/CWE-089/SqlInjection.go +++ b/go/ql/test/query-tests/Security/CWE-089/SqlInjection.go @@ -8,6 +8,6 @@ import ( func handler(db *sql.DB, req *http.Request) { q := fmt.Sprintf("SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='%s' ORDER BY PRICE", - req.URL.Query()["category"]) - db.Query(q) + req.URL.Query()["category"]) // $ Source[go/sql-injection] + db.Query(q) // $ Alert[go/sql-injection] } diff --git a/go/ql/test/query-tests/Security/CWE-089/SqlInjection.qlref b/go/ql/test/query-tests/Security/CWE-089/SqlInjection.qlref index b6916bd2cd4..e1918157744 100644 --- a/go/ql/test/query-tests/Security/CWE-089/SqlInjection.qlref +++ b/go/ql/test/query-tests/Security/CWE-089/SqlInjection.qlref @@ -1,2 +1,4 @@ query: Security/CWE-089/SqlInjection.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-089/StringBreak.go b/go/ql/test/query-tests/Security/CWE-089/StringBreak.go index 5667ca35035..26cb9986c91 100644 --- a/go/ql/test/query-tests/Security/CWE-089/StringBreak.go +++ b/go/ql/test/query-tests/Security/CWE-089/StringBreak.go @@ -8,10 +8,10 @@ import ( ) func save(id string, version interface{}) { - versionJSON, _ := json.Marshal(version) + versionJSON, _ := json.Marshal(version) // $ Source[go/unsafe-quoting] sq.StatementBuilder. Insert("resources"). Columns("resource_id", "version_md5"). - Values(id, sq.Expr(fmt.Sprintf("md5('%s')", versionJSON))). + Values(id, sq.Expr(fmt.Sprintf("md5('%s')", versionJSON))). // $ Alert[go/unsafe-quoting] Exec() } diff --git a/go/ql/test/query-tests/Security/CWE-089/StringBreak.qlref b/go/ql/test/query-tests/Security/CWE-089/StringBreak.qlref index 45a8c419134..096091bde4c 100644 --- a/go/ql/test/query-tests/Security/CWE-089/StringBreak.qlref +++ b/go/ql/test/query-tests/Security/CWE-089/StringBreak.qlref @@ -1,2 +1,4 @@ query: Security/CWE-089/StringBreak.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-089/StringBreakMismatched.go b/go/ql/test/query-tests/Security/CWE-089/StringBreakMismatched.go index c838d5f6b7d..70f3af40d6f 100644 --- a/go/ql/test/query-tests/Security/CWE-089/StringBreakMismatched.go +++ b/go/ql/test/query-tests/Security/CWE-089/StringBreakMismatched.go @@ -10,23 +10,23 @@ import ( // Bad because quote characters are removed before concatenation, // but then enclosed in a different enclosing quote: func mismatch1(id string, version interface{}) { - versionJSON, _ := json.Marshal(version) + versionJSON, _ := json.Marshal(version) // $ Source[go/unsafe-quoting] escaped := strings.Replace(string(versionJSON), "\"", "", -1) sq.StatementBuilder. Insert("resources"). Columns("resource_id", "version_md5"). - Values(id, sq.Expr("'"+escaped+"'")). + Values(id, sq.Expr("'"+escaped+"'")). // $ Alert[go/unsafe-quoting] Exec() } // Bad because quote characters are removed before concatenation, // but then enclosed in a different enclosing quote: func mismatch2(id string, version interface{}) { - versionJSON, _ := json.Marshal(version) + versionJSON, _ := json.Marshal(version) // $ Source[go/unsafe-quoting] escaped := strings.Replace(string(versionJSON), "'", "", -1) sq.StatementBuilder. Insert("resources"). Columns("resource_id", "version_md5"). - Values(id, sq.Expr("\""+escaped+"\"")). + Values(id, sq.Expr("\""+escaped+"\"")). // $ Alert[go/unsafe-quoting] Exec() } diff --git a/go/ql/test/query-tests/Security/CWE-089/issue48.go b/go/ql/test/query-tests/Security/CWE-089/issue48.go index 2c23b617190..9ef91eb1350 100644 --- a/go/ql/test/query-tests/Security/CWE-089/issue48.go +++ b/go/ql/test/query-tests/Security/CWE-089/issue48.go @@ -14,29 +14,29 @@ func handler1(db *sql.DB, req *http.Request) { // read data from request body and unmarshal to a indeterminacy struct // POST: {"a": "b", "category": "test"} var RequestDataFromJson map[string]interface{} - b, _ := ioutil.ReadAll(req.Body) + b, _ := ioutil.ReadAll(req.Body) // $ Source[go/sql-injection] json.Unmarshal(b, &RequestDataFromJson) q3 := fmt.Sprintf("SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='%s' ORDER BY PRICE", RequestDataFromJson["category"]) - db.Query(q3) // NOT OK + db.Query(q3) // $ Alert[go/sql-injection] // NOT OK // read data from request body and unmarshal to a determined struct // POST: {"id": "1", "category": "test"} var RequestDataFromJson2 RequestStruct - b2, _ := ioutil.ReadAll(req.Body) + b2, _ := ioutil.ReadAll(req.Body) // $ Source[go/sql-injection] json.Unmarshal(b2, &RequestDataFromJson2) q4 := fmt.Sprintf("SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='%s' ORDER BY PRICE", RequestDataFromJson2.Category) - db.Query(q4) // NOT OK + db.Query(q4) // $ Alert[go/sql-injection] // NOT OK // read json data from a url parameter // GET: ?json={"id": 1, "category": "test"} var RequestDataFromJson3 RequestStruct - json.Unmarshal([]byte(req.URL.Query()["json"][0]), &RequestDataFromJson3) + json.Unmarshal([]byte(req.URL.Query()["json"][0]), &RequestDataFromJson3) // $ Source[go/sql-injection] q5 := fmt.Sprintf("SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='%s' ORDER BY PRICE", RequestDataFromJson3.Category) - db.Query(q5) // NOT OK + db.Query(q5) // $ Alert[go/sql-injection] // NOT OK } diff --git a/go/ql/test/query-tests/Security/CWE-089/main.go b/go/ql/test/query-tests/Security/CWE-089/main.go index 7e5f5a35a9d..d0b17bf1145 100644 --- a/go/ql/test/query-tests/Security/CWE-089/main.go +++ b/go/ql/test/query-tests/Security/CWE-089/main.go @@ -8,12 +8,12 @@ import ( ) func test(db *sql.DB, r *http.Request) { - db.Query(r.Form["query"][0]) // NOT OK + db.Query(r.Form["query"][0]) // $ Alert[go/sql-injection] // NOT OK } func test2(tx *sql.Tx, r *http.Request) { - tx.Query(fmt.Sprintf("SELECT USER FROM USERS WHERE ID='%s'", r.URL.Query()["uuid"])) // NOT OK - tx.Query(fmt.Sprintf("SELECT USER FROM USERS WHERE ID='%s'", r.Header.Get("X-Uuid"))) // NOT OK + tx.Query(fmt.Sprintf("SELECT USER FROM USERS WHERE ID='%s'", r.URL.Query()["uuid"])) // $ Alert[go/sql-injection] // NOT OK + tx.Query(fmt.Sprintf("SELECT USER FROM USERS WHERE ID='%s'", r.Header.Get("X-Uuid"))) // $ Alert[go/sql-injection] // NOT OK } func main() {} @@ -27,39 +27,39 @@ type RequestStruct struct { func handler2(db *sql.DB, req *http.Request) { RequestData := &RequestStruct{ Id: 1, - Category: req.URL.Query()["category"], + Category: req.URL.Query()["category"], // $ Source[go/sql-injection] } q := fmt.Sprintf("SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='%s' ORDER BY PRICE", RequestData.Category) - db.Query(q) + db.Query(q) // $ Alert[go/sql-injection] } func handler3(db *sql.DB, req *http.Request) { RequestData := &RequestStruct{} - RequestData.Category = req.URL.Query()["category"] + RequestData.Category = req.URL.Query()["category"] // $ Source[go/sql-injection] q := fmt.Sprintf("SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='%s' ORDER BY PRICE", RequestData.Category) - db.Query(q) + db.Query(q) // $ Alert[go/sql-injection] } func handler4(db *sql.DB, req *http.Request) { RequestData := &RequestStruct{} - (*RequestData).Category = req.URL.Query()["category"] + (*RequestData).Category = req.URL.Query()["category"] // $ Source[go/sql-injection] q := fmt.Sprintf("SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='%s' ORDER BY PRICE", RequestData.Category) - db.Query(q) + db.Query(q) // $ Alert[go/sql-injection] } func handler5(db *sql.DB, req *http.Request) { RequestData := &RequestStruct{} - (*RequestData).Category = req.URL.Query()["category"] + (*RequestData).Category = req.URL.Query()["category"] // $ Source[go/sql-injection] q := fmt.Sprintf("SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='%s' ORDER BY PRICE", (*RequestData).Category) - db.Query(q) + db.Query(q) // $ Alert[go/sql-injection] } // This is an integer, so should not counted as injection diff --git a/go/ql/test/query-tests/Security/CWE-089/mongoDB.go b/go/ql/test/query-tests/Security/CWE-089/mongoDB.go index 818f8adb13c..34c89d297b9 100644 --- a/go/ql/test/query-tests/Security/CWE-089/mongoDB.go +++ b/go/ql/test/query-tests/Security/CWE-089/mongoDB.go @@ -37,7 +37,7 @@ func mongo2(w http.ResponseWriter, r *http.Request) { // Get a handle for your collection db := client.Database("test") coll := db.Collection("collection") - untrustedInput := r.Referer() + untrustedInput := r.Referer() // $ Source[go/sql-injection] filter := bson.D{{"name", untrustedInput}} @@ -54,30 +54,30 @@ func mongo2(w http.ResponseWriter, r *http.Request) { update := bson.D{{"$inc", bson.D{{"age", 1}}}} // models := nil - coll.Aggregate(ctx, pipeline, nil) + coll.Aggregate(ctx, pipeline, nil) // $ Alert[go/sql-injection] // coll.BulkWrite(ctx, models, nil) coll.BulkWrite(ctx, nil, nil) coll.Clone(nil) - coll.CountDocuments(ctx, filter, nil) + coll.CountDocuments(ctx, filter, nil) // $ Alert[go/sql-injection] coll.Database() - coll.DeleteMany(ctx, filter, nil) - coll.DeleteOne(ctx, filter, nil) + coll.DeleteMany(ctx, filter, nil) // $ Alert[go/sql-injection] + coll.DeleteOne(ctx, filter, nil) // $ Alert[go/sql-injection] - coll.Distinct(ctx, fieldName, filter) + coll.Distinct(ctx, fieldName, filter) // $ Alert[go/sql-injection] coll.Drop(ctx) coll.EstimatedDocumentCount(ctx, nil) - coll.Find(ctx, filter, nil) - coll.FindOne(ctx, filter, nil) - coll.FindOneAndDelete(ctx, filter, nil) - coll.FindOneAndReplace(ctx, filter, nil) - coll.FindOneAndUpdate(ctx, filter, nil) + coll.Find(ctx, filter, nil) // $ Alert[go/sql-injection] + coll.FindOne(ctx, filter, nil) // $ Alert[go/sql-injection] + coll.FindOneAndDelete(ctx, filter, nil) // $ Alert[go/sql-injection] + coll.FindOneAndReplace(ctx, filter, nil) // $ Alert[go/sql-injection] + coll.FindOneAndUpdate(ctx, filter, nil) // $ Alert[go/sql-injection] coll.Indexes() coll.InsertMany(ctx, documents) coll.InsertOne(ctx, document, nil) coll.Name() - coll.ReplaceOne(ctx, filter, replacement) - coll.UpdateMany(ctx, filter, update) - coll.UpdateOne(ctx, filter, update) - coll.Watch(ctx, pipeline) + coll.ReplaceOne(ctx, filter, replacement) // $ Alert[go/sql-injection] + coll.UpdateMany(ctx, filter, update) // $ Alert[go/sql-injection] + coll.UpdateOne(ctx, filter, update) // $ Alert[go/sql-injection] + coll.Watch(ctx, pipeline) // $ Alert[go/sql-injection] } diff --git a/go/ql/test/query-tests/Security/CWE-190/AllocationSizeOverflow.go b/go/ql/test/query-tests/Security/CWE-190/AllocationSizeOverflow.go index aa11afa816a..c717cf6fd71 100644 --- a/go/ql/test/query-tests/Security/CWE-190/AllocationSizeOverflow.go +++ b/go/ql/test/query-tests/Security/CWE-190/AllocationSizeOverflow.go @@ -3,11 +3,11 @@ package main import "encoding/json" func encryptValue(v interface{}) ([]byte, error) { - jsonData, err := json.Marshal(v) + jsonData, err := json.Marshal(v) // $ Source if err != nil { return nil, err } - size := len(jsonData) + (len(jsonData) % 16) + size := len(jsonData) + (len(jsonData) % 16) // $ Alert buffer := make([]byte, size) copy(buffer, jsonData) return encryptBuffer(buffer) diff --git a/go/ql/test/query-tests/Security/CWE-190/AllocationSizeOverflow.qlref b/go/ql/test/query-tests/Security/CWE-190/AllocationSizeOverflow.qlref index f6da9bc1c36..e06f99c7747 100644 --- a/go/ql/test/query-tests/Security/CWE-190/AllocationSizeOverflow.qlref +++ b/go/ql/test/query-tests/Security/CWE-190/AllocationSizeOverflow.qlref @@ -1,2 +1,4 @@ query: Security/CWE-190/AllocationSizeOverflow.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-190/tst.go b/go/ql/test/query-tests/Security/CWE-190/tst.go index abe4452343e..6958fd9ad9a 100644 --- a/go/ql/test/query-tests/Security/CWE-190/tst.go +++ b/go/ql/test/query-tests/Security/CWE-190/tst.go @@ -11,28 +11,28 @@ func test(x int, s string, xs []int, ys [16]int, ss [16]string, h *header) { jsonData, _ := json.Marshal(x) ignore(make([]byte, len(jsonData)+1)) // OK: data is small - jsonData, _ = json.Marshal(s) - ignore(make([]byte, len(jsonData)+1)) // NOT OK: data might be big + jsonData, _ = json.Marshal(s) // $ Source + ignore(make([]byte, len(jsonData)+1)) // $ Alert // NOT OK: data might be big jsonData, _ = json.Marshal("hi there") ignore(make([]byte, len(jsonData)+1)) // OK: data is small - jsonData, _ = json.Marshal(xs) - ignore(make([]byte, len(jsonData)+1)) // NOT OK: data might be big + jsonData, _ = json.Marshal(xs) // $ Source + ignore(make([]byte, len(jsonData)+1)) // $ Alert // NOT OK: data might be big jsonData, _ = json.Marshal(ys) ignore(make([]byte, len(jsonData)+1)) // OK: data is small - jsonData, _ = json.Marshal(ss) - ignore(make([]byte, 10, len(jsonData)+1)) // NOT OK: data might be big + jsonData, _ = json.Marshal(ss) // $ Source + ignore(make([]byte, 10, len(jsonData)+1)) // $ Alert // NOT OK: data might be big jsonData, _ = json.Marshal(h) ignore(make([]byte, len(jsonData)+1)) // OK: data is small var i interface{} i = h - jsonData, _ = json.Marshal(i) - ignore(make([]byte, len(jsonData)+1)) // NOT OK: data might be big + jsonData, _ = json.Marshal(i) // $ Source + ignore(make([]byte, len(jsonData)+1)) // $ Alert // NOT OK: data might be big } func ignore(_ interface{}) {} diff --git a/go/ql/test/query-tests/Security/CWE-190/tst2.go b/go/ql/test/query-tests/Security/CWE-190/tst2.go index d9dfe6912e8..28725266d96 100644 --- a/go/ql/test/query-tests/Security/CWE-190/tst2.go +++ b/go/ql/test/query-tests/Security/CWE-190/tst2.go @@ -6,13 +6,13 @@ import ( ) func test2(filename string) { - data, _ := ioutil.ReadFile(filename) - ignore(make([]byte, len(data)+1)) // NOT OK + data, _ := ioutil.ReadFile(filename) // $ Source + ignore(make([]byte, len(data)+1)) // $ Alert // NOT OK } func test3(r io.Reader) { - data, _ := ioutil.ReadAll(r) - ignore(make([]byte, len(data)+1)) // NOT OK + data, _ := ioutil.ReadAll(r) // $ Source + ignore(make([]byte, len(data)+1)) // $ Alert // NOT OK } func test4(r io.Reader, ws []io.Writer) { diff --git a/go/ql/test/query-tests/Security/CWE-190/tst3.go b/go/ql/test/query-tests/Security/CWE-190/tst3.go index 660345b099d..9a905563953 100644 --- a/go/ql/test/query-tests/Security/CWE-190/tst3.go +++ b/go/ql/test/query-tests/Security/CWE-190/tst3.go @@ -3,8 +3,8 @@ package main import "encoding/json" func testSanitizers(s string) { - jsonData, _ := json.Marshal(s) - ignore(make([]byte, len(jsonData)+1)) // NOT OK: data might be big + jsonData, _ := json.Marshal(s) // $ Source + ignore(make([]byte, len(jsonData)+1)) // $ Alert // NOT OK: data might be big ignore(make([]byte, int64(len(jsonData))+1)) // OK: sanitized by widening to 64 bits @@ -21,7 +21,7 @@ func testSanitizers(s string) { } { - newlength := len(jsonData) + 3 // NOT OK: newlength is changed after the upper bound check (even though it's made smaller) + newlength := len(jsonData) + 3 // $ Alert // NOT OK: newlength is changed after the upper bound check (even though it's made smaller) if newlength < 1000 { newlength = newlength - 1 ignore(make([]byte, newlength)) @@ -29,7 +29,7 @@ func testSanitizers(s string) { } { - newlength := len(jsonData) + 4 // NOT OK: there is an upper bound check but it doesn't dominate `make` + newlength := len(jsonData) + 4 // $ Alert // NOT OK: there is an upper bound check but it doesn't dominate `make` if newlength < 1000 { ignore(newlength + 2) } diff --git a/go/ql/test/query-tests/Security/CWE-209/StackTraceExposure.qlref b/go/ql/test/query-tests/Security/CWE-209/StackTraceExposure.qlref index 18cf2d49a1a..420481918d1 100644 --- a/go/ql/test/query-tests/Security/CWE-209/StackTraceExposure.qlref +++ b/go/ql/test/query-tests/Security/CWE-209/StackTraceExposure.qlref @@ -1 +1,2 @@ -Security/CWE-209/StackTraceExposure.ql +query: Security/CWE-209/StackTraceExposure.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-209/test.go b/go/ql/test/query-tests/Security/CWE-209/test.go index 77df73b8046..6a1b6c298ba 100644 --- a/go/ql/test/query-tests/Security/CWE-209/test.go +++ b/go/ql/test/query-tests/Security/CWE-209/test.go @@ -12,10 +12,10 @@ var logger log.Logger func handlePanic(w http.ResponseWriter, r *http.Request) { buf := make([]byte, 2<<16) - stackLen := runtime.Stack(buf, true) + stackLen := runtime.Stack(buf, true) // $ Source buf = buf[:stackLen] // BAD: printing a stack trace back to the response - w.Write(buf) + w.Write(buf) // $ Alert // GOOD: logging the response to the server and sending // a more generic message. logger.Printf("Panic: %s", buf) diff --git a/go/ql/test/query-tests/Security/CWE-295/DisabledCertificateCheck/DisabledCertificateCheck.go b/go/ql/test/query-tests/Security/CWE-295/DisabledCertificateCheck/DisabledCertificateCheck.go index b0490ad6f4f..67f757544f2 100644 --- a/go/ql/test/query-tests/Security/CWE-295/DisabledCertificateCheck/DisabledCertificateCheck.go +++ b/go/ql/test/query-tests/Security/CWE-295/DisabledCertificateCheck/DisabledCertificateCheck.go @@ -7,7 +7,7 @@ import ( func doAuthReq(authReq *http.Request) *http.Response { tr := &http.Transport{ - TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // NOT OK + TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // $ Alert // NOT OK } client := &http.Client{Transport: tr} res, _ := client.Do(authReq) diff --git a/go/ql/test/query-tests/Security/CWE-295/DisabledCertificateCheck/DisabledCertificateCheck.qlref b/go/ql/test/query-tests/Security/CWE-295/DisabledCertificateCheck/DisabledCertificateCheck.qlref index cca259717b5..8864221dea7 100644 --- a/go/ql/test/query-tests/Security/CWE-295/DisabledCertificateCheck/DisabledCertificateCheck.qlref +++ b/go/ql/test/query-tests/Security/CWE-295/DisabledCertificateCheck/DisabledCertificateCheck.qlref @@ -1 +1,2 @@ -Security/CWE-295/DisabledCertificateCheck.ql +query: Security/CWE-295/DisabledCertificateCheck.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-295/DisabledCertificateCheck/main.go b/go/ql/test/query-tests/Security/CWE-295/DisabledCertificateCheck/main.go index 3cb5d107a70..152ece5ba46 100644 --- a/go/ql/test/query-tests/Security/CWE-295/DisabledCertificateCheck/main.go +++ b/go/ql/test/query-tests/Security/CWE-295/DisabledCertificateCheck/main.go @@ -6,7 +6,7 @@ import ( ) func bad1(cfg *tls.Config) { - cfg.InsecureSkipVerify = true // NOT OK + cfg.InsecureSkipVerify = true // $ Alert // NOT OK } func good1(cfg *tls.Config) { @@ -54,12 +54,12 @@ func makeInsecureConfig() *tls.Config { } func makeConfig() *tls.Config { - return &tls.Config{InsecureSkipVerify: true} // NOT OK + return &tls.Config{InsecureSkipVerify: true} // $ Alert // NOT OK } func bad3() *http.Transport { transport := &http.Transport{ - TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // NOT OK + TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // $ Alert // NOT OK } return transport } diff --git a/go/ql/test/query-tests/Security/CWE-322/InsecureHostKeyCallback.expected b/go/ql/test/query-tests/Security/CWE-322/InsecureHostKeyCallback.expected index b81d24f2665..b05736dc4c4 100644 --- a/go/ql/test/query-tests/Security/CWE-322/InsecureHostKeyCallback.expected +++ b/go/ql/test/query-tests/Security/CWE-322/InsecureHostKeyCallback.expected @@ -1,3 +1,8 @@ +#select +| InsecureHostKeyCallbackExample.go:15:20:18:5 | type conversion | InsecureHostKeyCallbackExample.go:16:4:18:4 | function literal | InsecureHostKeyCallbackExample.go:15:20:18:5 | type conversion | Configuring SSH ClientConfig with insecure HostKeyCallback implementation from $@. | InsecureHostKeyCallbackExample.go:16:4:18:4 | function literal | this source | +| InsecureHostKeyCallbackExample.go:26:20:26:46 | call to InsecureIgnoreHostKey | InsecureHostKeyCallbackExample.go:26:20:26:46 | call to InsecureIgnoreHostKey | InsecureHostKeyCallbackExample.go:26:20:26:46 | call to InsecureIgnoreHostKey | Configuring SSH ClientConfig with insecure HostKeyCallback implementation from $@. | InsecureHostKeyCallbackExample.go:26:20:26:46 | call to InsecureIgnoreHostKey | this source | +| InsecureHostKeyCallbackExample.go:39:20:39:27 | callback | InsecureHostKeyCallbackExample.go:32:3:34:3 | function literal | InsecureHostKeyCallbackExample.go:39:20:39:27 | callback | Configuring SSH ClientConfig with insecure HostKeyCallback implementation from $@. | InsecureHostKeyCallbackExample.go:32:3:34:3 | function literal | this source | +| InsecureHostKeyCallbackExample.go:52:20:52:48 | type conversion | InsecureHostKeyCallbackExample.go:45:3:47:3 | function literal | InsecureHostKeyCallbackExample.go:52:20:52:48 | type conversion | Configuring SSH ClientConfig with insecure HostKeyCallback implementation from $@. | InsecureHostKeyCallbackExample.go:45:3:47:3 | function literal | this source | edges | InsecureHostKeyCallbackExample.go:16:4:18:4 | function literal | InsecureHostKeyCallbackExample.go:15:20:18:5 | type conversion | provenance | | | InsecureHostKeyCallbackExample.go:31:14:34:4 | type conversion | InsecureHostKeyCallbackExample.go:39:20:39:27 | callback | provenance | | @@ -41,8 +46,3 @@ nodes | InsecureHostKeyCallbackExample.go:118:35:118:61 | call to InsecureIgnoreHostKey | semmle.label | call to InsecureIgnoreHostKey | | InsecureHostKeyCallbackExample.go:120:44:120:68 | potentiallySecureCallback | semmle.label | potentiallySecureCallback | subpaths -#select -| InsecureHostKeyCallbackExample.go:15:20:18:5 | type conversion | InsecureHostKeyCallbackExample.go:16:4:18:4 | function literal | InsecureHostKeyCallbackExample.go:15:20:18:5 | type conversion | Configuring SSH ClientConfig with insecure HostKeyCallback implementation from $@. | InsecureHostKeyCallbackExample.go:16:4:18:4 | function literal | this source | -| InsecureHostKeyCallbackExample.go:26:20:26:46 | call to InsecureIgnoreHostKey | InsecureHostKeyCallbackExample.go:26:20:26:46 | call to InsecureIgnoreHostKey | InsecureHostKeyCallbackExample.go:26:20:26:46 | call to InsecureIgnoreHostKey | Configuring SSH ClientConfig with insecure HostKeyCallback implementation from $@. | InsecureHostKeyCallbackExample.go:26:20:26:46 | call to InsecureIgnoreHostKey | this source | -| InsecureHostKeyCallbackExample.go:39:20:39:27 | callback | InsecureHostKeyCallbackExample.go:32:3:34:3 | function literal | InsecureHostKeyCallbackExample.go:39:20:39:27 | callback | Configuring SSH ClientConfig with insecure HostKeyCallback implementation from $@. | InsecureHostKeyCallbackExample.go:32:3:34:3 | function literal | this source | -| InsecureHostKeyCallbackExample.go:52:20:52:48 | type conversion | InsecureHostKeyCallbackExample.go:45:3:47:3 | function literal | InsecureHostKeyCallbackExample.go:52:20:52:48 | type conversion | Configuring SSH ClientConfig with insecure HostKeyCallback implementation from $@. | InsecureHostKeyCallbackExample.go:45:3:47:3 | function literal | this source | diff --git a/go/ql/test/query-tests/Security/CWE-322/InsecureHostKeyCallback.qlref b/go/ql/test/query-tests/Security/CWE-322/InsecureHostKeyCallback.qlref index b5f8712594d..2c5cecd3a29 100644 --- a/go/ql/test/query-tests/Security/CWE-322/InsecureHostKeyCallback.qlref +++ b/go/ql/test/query-tests/Security/CWE-322/InsecureHostKeyCallback.qlref @@ -1 +1,2 @@ -Security/CWE-322/InsecureHostKeyCallback.ql +query: Security/CWE-322/InsecureHostKeyCallback.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-322/InsecureHostKeyCallbackExample.go b/go/ql/test/query-tests/Security/CWE-322/InsecureHostKeyCallbackExample.go index d13bda30a5e..1d5b17ebd8d 100644 --- a/go/ql/test/query-tests/Security/CWE-322/InsecureHostKeyCallbackExample.go +++ b/go/ql/test/query-tests/Security/CWE-322/InsecureHostKeyCallbackExample.go @@ -15,7 +15,7 @@ func insecureSSHClientConfig() { HostKeyCallback: ssh.HostKeyCallback( // BAD func(hostname string, remote net.Addr, key ssh.PublicKey) error { return nil - }), + }), // $ Source Alert } } @@ -23,7 +23,7 @@ func insecureSSHClientConfigAlt() { _ = &ssh.ClientConfig{ User: "user", Auth: []ssh.AuthMethod{nil}, - HostKeyCallback: ssh.InsecureIgnoreHostKey(), // BAD + HostKeyCallback: ssh.InsecureIgnoreHostKey(), // $ Alert // BAD } } @@ -31,12 +31,12 @@ func insecureSSHClientConfigLocalFlow() { callback := ssh.HostKeyCallback( func(hostname string, remote net.Addr, key ssh.PublicKey) error { return nil - }) + }) // $ Source _ = &ssh.ClientConfig{ User: "user", Auth: []ssh.AuthMethod{nil}, - HostKeyCallback: callback, // BAD + HostKeyCallback: callback, // $ Alert // BAD } } @@ -44,12 +44,12 @@ func insecureSSHClientConfigLocalFlowAlt() { callback := func(hostname string, remote net.Addr, key ssh.PublicKey) error { return nil - } + } // $ Source _ = &ssh.ClientConfig{ User: "user", Auth: []ssh.AuthMethod{nil}, - HostKeyCallback: ssh.HostKeyCallback(callback), // BAD + HostKeyCallback: ssh.HostKeyCallback(callback), // $ Alert // BAD } } diff --git a/go/ql/test/query-tests/Security/CWE-326/InsufficientKeySize.go b/go/ql/test/query-tests/Security/CWE-326/InsufficientKeySize.go index 9d5ce2ac424..6c28a054b65 100644 --- a/go/ql/test/query-tests/Security/CWE-326/InsufficientKeySize.go +++ b/go/ql/test/query-tests/Security/CWE-326/InsufficientKeySize.go @@ -6,16 +6,16 @@ import ( ) func foo1() { - rsa.GenerateKey(rand.Reader, 1024) // BAD + rsa.GenerateKey(rand.Reader, 1024) // $ Alert // BAD } func foo2() { - size := 1024 - rsa.GenerateKey(rand.Reader, size) // BAD + size := 1024 // $ Source + rsa.GenerateKey(rand.Reader, size) // $ Alert // BAD } func foo3() { - foo5(1024) // BAD + foo5(1024) // $ Source // BAD } func foo4() { @@ -23,13 +23,13 @@ func foo4() { } func foo5(size int) { - rsa.GenerateKey(rand.Reader, size) + rsa.GenerateKey(rand.Reader, size) // $ Alert } func foo6() { - keyBits := 1024 + keyBits := 1024 // $ Source if keyBits >= 2047 { - rsa.GenerateKey(rand.Reader, keyBits) // BAD + rsa.GenerateKey(rand.Reader, keyBits) // $ Alert // BAD } } @@ -41,10 +41,10 @@ func foo7() { } func foo8() { - keyBits := 1024 + keyBits := 1024 // $ Source switch { case keyBits >= 2047: - rsa.GenerateKey(rand.Reader, keyBits) // BAD + rsa.GenerateKey(rand.Reader, keyBits) // $ Alert // BAD } } @@ -58,13 +58,13 @@ func foo9() { func foo10(customOptionSupplied bool, nonConstantKeyBits int) { keyBits := 0 - constantKeyBits := 1024 + constantKeyBits := 1024 // $ Source if customOptionSupplied { keyBits = constantKeyBits } else { keyBits = nonConstantKeyBits } - rsa.GenerateKey(rand.Reader, keyBits) // BAD + rsa.GenerateKey(rand.Reader, keyBits) // $ Alert // BAD } func foo11(customOptionSupplied bool, nonConstantKeyBits int) { diff --git a/go/ql/test/query-tests/Security/CWE-326/InsufficientKeySize.qlref b/go/ql/test/query-tests/Security/CWE-326/InsufficientKeySize.qlref index fbb59dd4be6..ef999cf368a 100644 --- a/go/ql/test/query-tests/Security/CWE-326/InsufficientKeySize.qlref +++ b/go/ql/test/query-tests/Security/CWE-326/InsufficientKeySize.qlref @@ -1 +1,2 @@ -Security/CWE-326/InsufficientKeySize.ql +query: Security/CWE-326/InsufficientKeySize.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-327/UnsafeTLS.go b/go/ql/test/query-tests/Security/CWE-327/UnsafeTLS.go index 24dfeb195a0..5a91077e555 100644 --- a/go/ql/test/query-tests/Security/CWE-327/UnsafeTLS.go +++ b/go/ql/test/query-tests/Security/CWE-327/UnsafeTLS.go @@ -18,7 +18,7 @@ func oldVersionFunc() bool { func minMaxTlsVersion() { { config := &tls.Config{} - config.MinVersion = 0 // BAD + config.MinVersion = 0 // $ Alert[go/insecure-tls] // BAD } { config := &tls.Config{} @@ -27,7 +27,7 @@ func minMaxTlsVersion() { /// { config := &tls.Config{ - MinVersion: 0, // BAD + MinVersion: 0, // $ Alert[go/insecure-tls] // BAD } _ = config } @@ -40,40 +40,40 @@ func minMaxTlsVersion() { /// { config := &tls.Config{} - config.MinVersion = tls.VersionSSL30 // BAD + config.MinVersion = tls.VersionSSL30 // $ Alert[go/insecure-tls] // BAD } { config := &tls.Config{} - config.MaxVersion = tls.VersionSSL30 // BAD + config.MaxVersion = tls.VersionSSL30 // $ Alert[go/insecure-tls] // BAD } /// { config := &tls.Config{} - config.MinVersion = tls.VersionTLS10 // BAD + config.MinVersion = tls.VersionTLS10 // $ Alert[go/insecure-tls] // BAD } { config := &tls.Config{} - config.MaxVersion = tls.VersionTLS10 // BAD + config.MaxVersion = tls.VersionTLS10 // $ Alert[go/insecure-tls] // BAD } /// { config := &tls.Config{} - config.MinVersion = tls.VersionTLS11 // BAD + config.MinVersion = tls.VersionTLS11 // $ Alert[go/insecure-tls] // BAD } { config := &tls.Config{} - config.MaxVersion = tls.VersionTLS11 // BAD + config.MaxVersion = tls.VersionTLS11 // $ Alert[go/insecure-tls] // BAD } /// { config := &tls.Config{ - MinVersion: tls.VersionTLS11, // BAD + MinVersion: tls.VersionTLS11, // $ Alert[go/insecure-tls] // BAD } _ = config } { config := &tls.Config{ - MaxVersion: tls.VersionTLS11, // BAD + MaxVersion: tls.VersionTLS11, // $ Alert[go/insecure-tls] // BAD } _ = config } @@ -92,13 +92,13 @@ func minMaxTlsVersion() { /// { config := &tls.Config{ - MinVersion: 0x0300, // BAD + MinVersion: 0x0300, // $ Alert[go/insecure-tls] // BAD } _ = config } { config := &tls.Config{ - MaxVersion: 0x0301, // BAD + MaxVersion: 0x0301, // $ Alert[go/insecure-tls] // BAD } _ = config } @@ -108,7 +108,7 @@ func minMaxTlsVersion() { oldVersionFlag := len(os.Args) > 3 if unknown { config := &tls.Config{ - MinVersion: 0, // BAD + MinVersion: 0, // $ Alert[go/insecure-tls] // BAD } _ = config } @@ -198,7 +198,7 @@ func minMaxTlsVersion() { _ = config default: config := &tls.Config{ - MinVersion: 0, // BAD + MinVersion: 0, // $ Alert[go/insecure-tls] // BAD } _ = config } @@ -216,7 +216,7 @@ func minMaxTlsVersion() { _ = config default: config := &tls.Config{ - MinVersion: 0, // BAD + MinVersion: 0, // $ Alert[go/insecure-tls] // BAD } _ = config } @@ -257,61 +257,61 @@ func cipherSuites() { { config := &tls.Config{ CipherSuites: []uint16{ - tls.TLS_RSA_WITH_RC4_128_SHA, // BAD - tls.TLS_RSA_WITH_AES_128_CBC_SHA256, // BAD - tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, // BAD - tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA, // BAD - tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, // BAD - tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, // BAD - }, + tls.TLS_RSA_WITH_RC4_128_SHA, // $ Source[go/insecure-tls] // BAD + tls.TLS_RSA_WITH_AES_128_CBC_SHA256, // $ Source[go/insecure-tls] // BAD + tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, // $ Source[go/insecure-tls] // BAD + tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA, // $ Source[go/insecure-tls] // BAD + tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, // $ Source[go/insecure-tls] // BAD + tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, // $ Source[go/insecure-tls] // BAD + }, // $ Alert[go/insecure-tls] } _ = config } { config := &tls.Config{ CipherSuites: []uint16{ - tls.TLS_RSA_WITH_RC4_128_SHA, // BAD - }, + tls.TLS_RSA_WITH_RC4_128_SHA, // $ Source[go/insecure-tls] // BAD + }, // $ Alert[go/insecure-tls] } _ = config } { config := &tls.Config{ CipherSuites: []uint16{ - tls.TLS_RSA_WITH_AES_128_CBC_SHA256, // BAD - }, + tls.TLS_RSA_WITH_AES_128_CBC_SHA256, // $ Source[go/insecure-tls] // BAD + }, // $ Alert[go/insecure-tls] } _ = config } { config := &tls.Config{ CipherSuites: []uint16{ - tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, // BAD - }, + tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, // $ Source[go/insecure-tls] // BAD + }, // $ Alert[go/insecure-tls] } _ = config } { config := &tls.Config{ CipherSuites: []uint16{ - tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA, // BAD - }, + tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA, // $ Source[go/insecure-tls] // BAD + }, // $ Alert[go/insecure-tls] } _ = config } { config := &tls.Config{ CipherSuites: []uint16{ - tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, // BAD - }, + tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, // $ Source[go/insecure-tls] // BAD + }, // $ Alert[go/insecure-tls] } _ = config } { config := &tls.Config{ CipherSuites: []uint16{ - tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, // BAD - }, + tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, // $ Source[go/insecure-tls] // BAD + }, // $ Alert[go/insecure-tls] } _ = config } @@ -326,33 +326,33 @@ func cipherSuites() { { config := &tls.Config{} config.CipherSuites = make([]uint16, 0) - config.CipherSuites = append(config.CipherSuites, tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) // BAD + config.CipherSuites = append(config.CipherSuites, tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) // $ Alert[go/insecure-tls] // BAD } { config := &tls.Config{} config.CipherSuites = make([]uint16, 0) - suites := tls.InsecureCipherSuites() + suites := tls.InsecureCipherSuites() // $ Source[go/insecure-tls] for _, v := range suites { - config.CipherSuites = append(config.CipherSuites, v.ID) // BAD + config.CipherSuites = append(config.CipherSuites, v.ID) // $ Alert[go/insecure-tls] // BAD } } { config := &tls.Config{} cipherSuites := make([]uint16, 0) - suites := tls.InsecureCipherSuites() + suites := tls.InsecureCipherSuites() // $ Source[go/insecure-tls] for _, v := range suites { cipherSuites = append(cipherSuites, v.ID) } - config.CipherSuites = cipherSuites // BAD + config.CipherSuites = cipherSuites // $ Alert[go/insecure-tls] // BAD } { config := &tls.Config{} cipherSuites := make([]uint16, 0) - suites := tls.InsecureCipherSuites() + suites := tls.InsecureCipherSuites() // $ Source[go/insecure-tls] for i := range suites { cipherSuites = append(cipherSuites, suites[i].ID) } - config.CipherSuites = cipherSuites // BAD + config.CipherSuites = cipherSuites // $ Alert[go/insecure-tls] // BAD } unknown := len(os.Args) > 1 insecureFlag := len(os.Args) > 2 @@ -360,8 +360,8 @@ func cipherSuites() { if unknown { config := &tls.Config{ CipherSuites: []uint16{ - tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, // BAD - }, + tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, // $ Source[go/insecure-tls] // BAD + }, // $ Alert[go/insecure-tls] } _ = config } @@ -430,8 +430,8 @@ func cipherSuites() { default: config := &tls.Config{ CipherSuites: []uint16{ - tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, // BAD - }, + tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, // $ Source[go/insecure-tls] // BAD + }, // $ Alert[go/insecure-tls] } _ = config } @@ -454,8 +454,8 @@ func cipherSuites() { default: config := &tls.Config{ CipherSuites: []uint16{ - tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, // BAD - }, + tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, // $ Source[go/insecure-tls] // BAD + }, // $ Alert[go/insecure-tls] } _ = config } diff --git a/go/ql/test/query-tests/Security/CWE-327/UnsafeTLS.qlref b/go/ql/test/query-tests/Security/CWE-327/UnsafeTLS.qlref index 0349f62f26f..892cb53d05b 100644 --- a/go/ql/test/query-tests/Security/CWE-327/UnsafeTLS.qlref +++ b/go/ql/test/query-tests/Security/CWE-327/UnsafeTLS.qlref @@ -1,2 +1,4 @@ query: Security/CWE-327/InsecureTLS.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-338/InsecureRandomness/InsecureRandomness.go b/go/ql/test/query-tests/Security/CWE-338/InsecureRandomness/InsecureRandomness.go index 2e4d309f46c..0dbc48b19d1 100644 --- a/go/ql/test/query-tests/Security/CWE-338/InsecureRandomness/InsecureRandomness.go +++ b/go/ql/test/query-tests/Security/CWE-338/InsecureRandomness/InsecureRandomness.go @@ -9,7 +9,7 @@ var charset = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345 func generatePassword() string { s := make([]rune, 20) for i := range s { - s[i] = charset[rand.Intn(len(charset))] // BAD: weak RNG used to generate password + s[i] = charset[rand.Intn(len(charset))] // $ Alert // BAD: weak RNG used to generate password } return string(s) } diff --git a/go/ql/test/query-tests/Security/CWE-338/InsecureRandomness/InsecureRandomness.qlref b/go/ql/test/query-tests/Security/CWE-338/InsecureRandomness/InsecureRandomness.qlref index b30e6ede8ce..f148404a1c5 100644 --- a/go/ql/test/query-tests/Security/CWE-338/InsecureRandomness/InsecureRandomness.qlref +++ b/go/ql/test/query-tests/Security/CWE-338/InsecureRandomness/InsecureRandomness.qlref @@ -1,2 +1,4 @@ query: Security/CWE-338/InsecureRandomness.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-338/InsecureRandomness/sample.go b/go/ql/test/query-tests/Security/CWE-338/InsecureRandomness/sample.go index 9eef81f63bb..3edbb67c42d 100644 --- a/go/ql/test/query-tests/Security/CWE-338/InsecureRandomness/sample.go +++ b/go/ql/test/query-tests/Security/CWE-338/InsecureRandomness/sample.go @@ -12,7 +12,7 @@ import ( ) func Guid() []byte { - hash := sha256.Sum256([]byte(fmt.Sprintf("%n", rand.Uint32()))) // OK: may not be used in a cryptographic setting + hash := sha256.Sum256([]byte(fmt.Sprintf("%n", rand.Uint32()))) // $ Source // OK: may not be used in a cryptographic setting return hash[:] } @@ -23,7 +23,7 @@ func createHash(key string) string { } func ed25519FromGuid() { - ed25519.NewKeyFromSeed(Guid()) // BAD: Guid internally uses rand + ed25519.NewKeyFromSeed(Guid()) // $ Alert // BAD: Guid internally uses rand } func encrypt(data []byte, password string) []byte { @@ -31,16 +31,16 @@ func encrypt(data []byte, password string) []byte { gcm, _ := cipher.NewGCM(block) nonce := make([]byte, gcm.NonceSize()) - random := rand.New(rand.NewSource(999)) + random := rand.New(rand.NewSource(999)) // $ Source io.ReadFull(random, nonce) - ciphertext := gcm.Seal(data[:0], nonce, data, nil) // BAD: use of an insecure rng to generate a nonce + ciphertext := gcm.Seal(data[:0], nonce, data, nil) // $ Alert // BAD: use of an insecure rng to generate a nonce return ciphertext } func makePasswordFiveChar() string { s := make([]rune, 5) - s[0] = charset[rand.Intn(len(charset))] // BAD: weak RNG used to generate salt + s[0] = charset[rand.Intn(len(charset))] // $ Alert // BAD: weak RNG used to generate salt s[1] = charset[rand.Intn(len(charset))] // Rest OK because only the first result is caught s[2] = charset[rand.Intn(len(charset))] s[3] = charset[rand.Intn(len(charset))] @@ -52,8 +52,8 @@ func generateRandomKey() ed25519.PrivateKey { candidates := "0123456789ABCDEF" seed := "" for i := 0; i < ed25519.SeedSize; i++ { - randNumber := rand.Intn(len(candidates)) + randNumber := rand.Intn(len(candidates)) // $ Source seed += string(candidates[randNumber]) } - return ed25519.NewKeyFromSeed([]byte(seed)) // BAD: seed candidates were selected with a weak RNG + return ed25519.NewKeyFromSeed([]byte(seed)) // $ Alert // BAD: seed candidates were selected with a weak RNG } diff --git a/go/ql/test/query-tests/Security/CWE-347/MissingJwtSignatureCheck.qlref b/go/ql/test/query-tests/Security/CWE-347/MissingJwtSignatureCheck.qlref index 404fe618edc..55524e6e0e6 100644 --- a/go/ql/test/query-tests/Security/CWE-347/MissingJwtSignatureCheck.qlref +++ b/go/ql/test/query-tests/Security/CWE-347/MissingJwtSignatureCheck.qlref @@ -1,2 +1,4 @@ query: Security/CWE-347/MissingJwtSignatureCheck.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-347/go-jose.v3.go b/go/ql/test/query-tests/Security/CWE-347/go-jose.v3.go index 3e55ced31f6..67ce9ed00ea 100644 --- a/go/ql/test/query-tests/Security/CWE-347/go-jose.v3.go +++ b/go/ql/test/query-tests/Security/CWE-347/go-jose.v3.go @@ -22,7 +22,7 @@ func jose(r *http.Request) { verifyJWT(signedToken) // NOT OK: no verification - signedToken = r.URL.Query().Get("signedToken") + signedToken = r.URL.Query().Get("signedToken") // $ Source notVerifyJWT(signedToken) } @@ -30,7 +30,7 @@ func notVerifyJWT(signedToken string) { fmt.Println("only decoding JWT") DecodedToken, _ := jwt.ParseSigned(signedToken) out := CustomerInfo{} - if err := DecodedToken.UnsafeClaimsWithoutVerification(&out); err != nil { + if err := DecodedToken.UnsafeClaimsWithoutVerification(&out); err != nil { // $ Alert panic(err) } fmt.Printf("%v\n", out) diff --git a/go/ql/test/query-tests/Security/CWE-347/golang-jwt-v5.go b/go/ql/test/query-tests/Security/CWE-347/golang-jwt-v5.go index e37265f03c0..82d6c764797 100644 --- a/go/ql/test/query-tests/Security/CWE-347/golang-jwt-v5.go +++ b/go/ql/test/query-tests/Security/CWE-347/golang-jwt-v5.go @@ -25,13 +25,13 @@ func golangjwt(r *http.Request) { verifyJWT_golangjwt(signedToken) // NOT OK: only unverified parse - signedToken = r.URL.Query().Get("signedToken") + signedToken = r.URL.Query().Get("signedToken") // $ Source notVerifyJWT_golangjwt(signedToken) } func notVerifyJWT_golangjwt(signedToken string) { fmt.Println("only decoding JWT") - DecodedToken, _, err := jwt.NewParser().ParseUnverified(signedToken, &CustomerInfo1{}) + DecodedToken, _, err := jwt.NewParser().ParseUnverified(signedToken, &CustomerInfo1{}) // $ Alert if claims, ok := DecodedToken.Claims.(*CustomerInfo1); ok { fmt.Printf("DecodedToken:%v\n", claims) } else { diff --git a/go/ql/test/query-tests/Security/CWE-352/ConstantOauth2State.go b/go/ql/test/query-tests/Security/CWE-352/ConstantOauth2State.go index 75f899aea51..817c76c8bfa 100644 --- a/go/ql/test/query-tests/Security/CWE-352/ConstantOauth2State.go +++ b/go/ql/test/query-tests/Security/CWE-352/ConstantOauth2State.go @@ -17,9 +17,9 @@ import ( func main() {} -const stateStringConst = "state" +const stateStringConst = "state" // $ Source -var stateStringVar = "state" +var stateStringVar = "state" // $ Source func badWithStringLiteralState(w http.ResponseWriter) { conf := &oauth2.Config{ @@ -32,7 +32,7 @@ func badWithStringLiteralState(w http.ResponseWriter) { }, } - url := conf.AuthCodeURL("state") // BAD + url := conf.AuthCodeURL("state") // $ Alert // BAD _ = url // ... } @@ -47,7 +47,7 @@ func badWithConstState(w http.ResponseWriter) { }, } - url := conf.AuthCodeURL(stateStringConst) // BAD + url := conf.AuthCodeURL(stateStringConst) // $ Alert // BAD _ = url // ... } @@ -62,7 +62,7 @@ func badWithFixedVarState(w http.ResponseWriter) { }, } - url := conf.AuthCodeURL(stateStringVar) // BAD + url := conf.AuthCodeURL(stateStringVar) // $ Alert // BAD _ = url // ... } @@ -78,12 +78,12 @@ func badWithFixedStateReturned(w http.ResponseWriter) { } state := newFixedState() - url := conf.AuthCodeURL(state) // BAD + url := conf.AuthCodeURL(state) // $ Alert // BAD _ = url // ... } func newFixedState() string { - return "state" + return "state" // $ Source } func betterWithVariableStateReturned(w http.ResponseWriter) { @@ -229,7 +229,7 @@ func badWithConstStatePrinter(w http.ResponseWriter) { }, } - url := conf.AuthCodeURL(stateStringConst) // BAD + url := conf.AuthCodeURL(stateStringConst) // $ Alert // BAD fmt.Printf("LOG: URL %v", url) // ... } diff --git a/go/ql/test/query-tests/Security/CWE-352/ConstantOauth2State.qlref b/go/ql/test/query-tests/Security/CWE-352/ConstantOauth2State.qlref index 7898f39d415..7d6cf646915 100644 --- a/go/ql/test/query-tests/Security/CWE-352/ConstantOauth2State.qlref +++ b/go/ql/test/query-tests/Security/CWE-352/ConstantOauth2State.qlref @@ -1 +1,2 @@ -Security/CWE-352/ConstantOauth2State.ql +query: Security/CWE-352/ConstantOauth2State.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-601/BadRedirectCheck/BadRedirectCheck.go b/go/ql/test/query-tests/Security/CWE-601/BadRedirectCheck/BadRedirectCheck.go index 279e59c9cfb..74e7c7c1c33 100644 --- a/go/ql/test/query-tests/Security/CWE-601/BadRedirectCheck/BadRedirectCheck.go +++ b/go/ql/test/query-tests/Security/CWE-601/BadRedirectCheck/BadRedirectCheck.go @@ -1,7 +1,7 @@ package main -func sanitizeUrl(redir string) string { - if len(redir) > 0 && redir[0] == '/' { +func sanitizeUrl(redir string) string { // $ Source + if len(redir) > 0 && redir[0] == '/' { // $ Alert return redir } return "/" diff --git a/go/ql/test/query-tests/Security/CWE-601/BadRedirectCheck/BadRedirectCheck.qlref b/go/ql/test/query-tests/Security/CWE-601/BadRedirectCheck/BadRedirectCheck.qlref index fddee377510..59540d49a15 100644 --- a/go/ql/test/query-tests/Security/CWE-601/BadRedirectCheck/BadRedirectCheck.qlref +++ b/go/ql/test/query-tests/Security/CWE-601/BadRedirectCheck/BadRedirectCheck.qlref @@ -1,2 +1,4 @@ query: Security/CWE-601/BadRedirectCheck.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-601/BadRedirectCheck/cves.go b/go/ql/test/query-tests/Security/CWE-601/BadRedirectCheck/cves.go index 42e8bab3452..01fc6553977 100644 --- a/go/ql/test/query-tests/Security/CWE-601/BadRedirectCheck/cves.go +++ b/go/ql/test/query-tests/Security/CWE-601/BadRedirectCheck/cves.go @@ -8,12 +8,12 @@ import ( // CVE-2018-15178 // Code from github.com/gogs/gogs func isValidRedirect(url string) bool { - return len(url) >= 2 && url[0] == '/' && url[1] != '/' // NOT OK + return len(url) >= 2 && url[0] == '/' && url[1] != '/' // $ Alert // NOT OK } -func alsoABadRedirect(url string, rw http.ResponseWriter, req *http.Request) { +func alsoABadRedirect(url string, rw http.ResponseWriter, req *http.Request) { // $ Source if isValidRedirect(url) { - http.Redirect(rw, req, url, 302) + http.Redirect(rw, req, url, 302) // $ Sink } } @@ -30,17 +30,17 @@ func alsoAGoodRedirect(url string, rw http.ResponseWriter, req *http.Request) { // CVE-2017-1000070 (both vulnerable!) // Code from github.com/bitly/oauth2_proxy func OAuthCallback(rw http.ResponseWriter, req *http.Request) { - redirect := req.Form.Get("state") - if !strings.HasPrefix(redirect, "/") { // NOT OK + redirect := req.Form.Get("state") // $ Source + if !strings.HasPrefix(redirect, "/") { // $ Alert // NOT OK redirect = "/" } - http.Redirect(rw, req, redirect, 302) + http.Redirect(rw, req, redirect, 302) // $ Sink } func OAuthCallback1(rw http.ResponseWriter, req *http.Request) { - redirect := req.Form.Get("state") - if !strings.HasPrefix(redirect, "/") || strings.HasPrefix(redirect, "//") { // NOT OK + redirect := req.Form.Get("state") // $ Source + if !strings.HasPrefix(redirect, "/") || strings.HasPrefix(redirect, "//") { // $ Alert // NOT OK redirect = "/" } - http.Redirect(rw, req, redirect, 302) + http.Redirect(rw, req, redirect, 302) // $ Sink } diff --git a/go/ql/test/query-tests/Security/CWE-601/BadRedirectCheck/main.go b/go/ql/test/query-tests/Security/CWE-601/BadRedirectCheck/main.go index beccc9a135d..f45653e0945 100644 --- a/go/ql/test/query-tests/Security/CWE-601/BadRedirectCheck/main.go +++ b/go/ql/test/query-tests/Security/CWE-601/BadRedirectCheck/main.go @@ -7,8 +7,8 @@ import ( "strings" ) -func badRedirect(redirect string, rw http.ResponseWriter, req *http.Request) { - http.Redirect(rw, req, sanitizeUrl(redirect), 302) +func badRedirect(redirect string, rw http.ResponseWriter, req *http.Request) { // $ Source + http.Redirect(rw, req, sanitizeUrl(redirect), 302) // $ Sink } func goodRedirect(redirect string, rw http.ResponseWriter, req *http.Request) { @@ -22,16 +22,16 @@ func goodRedirect2(url string, rw http.ResponseWriter, req *http.Request) { func isValidRedir(redirect string) bool { switch { // Not OK: does not check for '/\' - case strings.HasPrefix(redirect, "/") && !strings.HasPrefix(redirect, "//"): + case strings.HasPrefix(redirect, "/") && !strings.HasPrefix(redirect, "//"): // $ Alert return true default: return false } } -func alsoABadRedirect1(url string, rw http.ResponseWriter, req *http.Request) { +func alsoABadRedirect1(url string, rw http.ResponseWriter, req *http.Request) { // $ Source if isValidRedir(url) { - http.Redirect(rw, req, url, 302) + http.Redirect(rw, req, url, 302) // $ Sink } } @@ -65,28 +65,28 @@ func goodRedirect4(url string, rw http.ResponseWriter, req *http.Request) { http.Redirect(rw, req, getTarget(url), 302) } -func getTarget1(redirect string) string { - if redirect[0] != '/' { +func getTarget1(redirect string) string { // $ Source + if redirect[0] != '/' { // $ Alert return "/" } return path.Clean(redirect) } -func badRedirect1(url string, rw http.ResponseWriter, req *http.Request) { - http.Redirect(rw, req, getTarget1(url), 302) +func badRedirect1(url string, rw http.ResponseWriter, req *http.Request) { // $ Source + http.Redirect(rw, req, getTarget1(url), 302) // $ Sink } func getTarget2(redirect string) string { u, _ := url.Parse(redirect) - if u.Path[0] != '/' { + if u.Path[0] != '/' { // $ Alert return "/" } - return u.Path + return u.Path // $ Source } func badRedirect2(url string, rw http.ResponseWriter, req *http.Request) { - http.Redirect(rw, req, getTarget2(url), 302) + http.Redirect(rw, req, getTarget2(url), 302) // $ Sink } diff --git a/go/ql/test/query-tests/Security/CWE-643/XPathInjection.go b/go/ql/test/query-tests/Security/CWE-643/XPathInjection.go index 50b130db91c..bb7a45ca99a 100644 --- a/go/ql/test/query-tests/Security/CWE-643/XPathInjection.go +++ b/go/ql/test/query-tests/Security/CWE-643/XPathInjection.go @@ -10,10 +10,10 @@ import ( func processRequest(r *http.Request, doc tree.Node) { r.ParseForm() - username := r.Form.Get("username") + username := r.Form.Get("username") // $ Source // BAD: User input used directly in an XPath expression - xPath := goxpath.MustParse("//users/user[login/text()='" + username + "']/home_dir/text()") + xPath := goxpath.MustParse("//users/user[login/text()='" + username + "']/home_dir/text()") // $ Alert unsafeRes, _ := xPath.ExecBool(doc) fmt.Println(unsafeRes) diff --git a/go/ql/test/query-tests/Security/CWE-643/XPathInjection.qlref b/go/ql/test/query-tests/Security/CWE-643/XPathInjection.qlref index e6a07d4a688..f3d92cc4c01 100644 --- a/go/ql/test/query-tests/Security/CWE-643/XPathInjection.qlref +++ b/go/ql/test/query-tests/Security/CWE-643/XPathInjection.qlref @@ -1,2 +1,4 @@ query: Security/CWE-643/XPathInjection.ql -postprocess: utils/test/PrettyPrintModels.ql +postprocess: + - utils/test/PrettyPrintModels.ql + - utils/test/InlineExpectationsTestQuery.ql diff --git a/go/ql/test/query-tests/Security/CWE-643/tst.go b/go/ql/test/query-tests/Security/CWE-643/tst.go index d3fc98b41a7..cf15ceeb033 100644 --- a/go/ql/test/query-tests/Security/CWE-643/tst.go +++ b/go/ql/test/query-tests/Security/CWE-643/tst.go @@ -32,70 +32,70 @@ func main() {} func testAntchfxXpath(r *http.Request) { r.ParseForm() - username := r.Form.Get("username") + username := r.Form.Get("username") // $ Source // BAD: User input used directly in an XPath expression - _, _ = xpath.Compile("//users/user[login/text()='" + username + "']/home_dir/text()") - _, _ = xpath.CompileWithNS("//users/user[login/text()='"+username+"']/home_dir/text()", make(map[string]string)) - _ = xpath.MustCompile("//users/user[login/text()='" + username + "']/home_dir/text()") - _ = xpath.Select(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") + _, _ = xpath.Compile("//users/user[login/text()='" + username + "']/home_dir/text()") // $ Alert + _, _ = xpath.CompileWithNS("//users/user[login/text()='"+username+"']/home_dir/text()", make(map[string]string)) // $ Alert + _ = xpath.MustCompile("//users/user[login/text()='" + username + "']/home_dir/text()") // $ Alert + _ = xpath.Select(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") // $ Alert } func testAntchfxHtmlquery(r *http.Request) { r.ParseForm() - username := r.Form.Get("username") + username := r.Form.Get("username") // $ Source // BAD: User input used directly in an XPath expression - _ = htmlquery.Find(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") - _ = htmlquery.FindOne(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") - _, _ = htmlquery.Query(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") - _, _ = htmlquery.QueryAll(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") + _ = htmlquery.Find(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") // $ Alert + _ = htmlquery.FindOne(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") // $ Alert + _, _ = htmlquery.Query(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") // $ Alert + _, _ = htmlquery.QueryAll(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") // $ Alert } func testAntchfxXmlquery(r *http.Request, n *xmlquery.Node) { r.ParseForm() - username := r.Form.Get("username") + username := r.Form.Get("username") // $ Source // BAD: User input used directly in an XPath expression - _ = xmlquery.Find(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") - _ = xmlquery.FindOne(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") - xmlquery.FindEach(nil, "//users/user[login/text()='"+username+"']/home_dir/text()", nil) - xmlquery.FindEachWithBreak(nil, "//users/user[login/text()='"+username+"']/home_dir/text()", nil) - _, _ = xmlquery.Query(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") - _, _ = xmlquery.QueryAll(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") - _ = n.SelectElements("//users/user[login/text()='" + username + "']/home_dir/text()") - _ = n.SelectElement("//users/user[login/text()='" + username + "']/home_dir/text()") + _ = xmlquery.Find(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") // $ Alert + _ = xmlquery.FindOne(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") // $ Alert + xmlquery.FindEach(nil, "//users/user[login/text()='"+username+"']/home_dir/text()", nil) // $ Alert + xmlquery.FindEachWithBreak(nil, "//users/user[login/text()='"+username+"']/home_dir/text()", nil) // $ Alert + _, _ = xmlquery.Query(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") // $ Alert + _, _ = xmlquery.QueryAll(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") // $ Alert + _ = n.SelectElements("//users/user[login/text()='" + username + "']/home_dir/text()") // $ Alert + _ = n.SelectElement("//users/user[login/text()='" + username + "']/home_dir/text()") // $ Alert } func testAntchfxJsonquery(r *http.Request) { r.ParseForm() - username := r.Form.Get("username") + username := r.Form.Get("username") // $ Source // BAD: User input used directly in an XPath expression - _ = jsonquery.Find(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") - _ = jsonquery.FindOne(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") - _, _ = jsonquery.Query(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") - _, _ = jsonquery.QueryAll(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") + _ = jsonquery.Find(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") // $ Alert + _ = jsonquery.FindOne(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") // $ Alert + _, _ = jsonquery.Query(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") // $ Alert + _, _ = jsonquery.QueryAll(nil, "//users/user[login/text()='"+username+"']/home_dir/text()") // $ Alert } func testGoXmlpathXmlpath(r *http.Request) { r.ParseForm() - username := r.Form.Get("username") + username := r.Form.Get("username") // $ Source // BAD: User input used directly in an XPath expression - _, _ = xmlpath.Compile("//users/user[login/text()='" + username + "']/home_dir/text()") - _ = xmlpath.MustCompile("//users/user[login/text()='" + username + "']/home_dir/text()") + _, _ = xmlpath.Compile("//users/user[login/text()='" + username + "']/home_dir/text()") // $ Alert + _ = xmlpath.MustCompile("//users/user[login/text()='" + username + "']/home_dir/text()") // $ Alert } func testChrisTrenkampGoxpath(r *http.Request) { r.ParseForm() - username := r.Form.Get("username") - password := r.Form.Get("password") + username := r.Form.Get("username") // $ Source + password := r.Form.Get("password") // $ Source // BAD: User input used directly in an XPath expression - _, _ = goxpath.Parse("//users/user[login/text()='" + username + "' and password/text() = '" + password + "']/home_dir/text()") - _ = goxpath.MustParse("//users/user[login/text()='" + username + "' and password/text() = '" + password + "']/home_dir/text()") - _, _ = goxpath.ParseExec("//users/user[login/text()='"+username+"' and password/text() = '"+password+"']/home_dir/text()", nil) + _, _ = goxpath.Parse("//users/user[login/text()='" + username + "' and password/text() = '" + password + "']/home_dir/text()") // $ Alert + _ = goxpath.MustParse("//users/user[login/text()='" + username + "' and password/text() = '" + password + "']/home_dir/text()") // $ Alert + _, _ = goxpath.ParseExec("//users/user[login/text()='"+username+"' and password/text() = '"+password+"']/home_dir/text()", nil) // $ Alert // GOOD: Uses parameters to avoid including user input directly in XPath expression _ = goxpath.MustParse("//users/user[login/text()=$username and password/text() = $password]/home_dir/text()") @@ -103,24 +103,24 @@ func testChrisTrenkampGoxpath(r *http.Request) { func testSanthoshTekuriXpathparser(r *http.Request) { r.ParseForm() - username := r.Form.Get("username") + username := r.Form.Get("username") // $ Source // BAD: User input used directly in an XPath expression - _, _ = xpathparser.Parse("//users/user[login/text()='" + username + "']/home_dir/text()") - _ = xpathparser.MustParse("//users/user[login/text()='" + username + "']/home_dir/text()") + _, _ = xpathparser.Parse("//users/user[login/text()='" + username + "']/home_dir/text()") // $ Alert + _ = xpathparser.MustParse("//users/user[login/text()='" + username + "']/home_dir/text()") // $ Alert } func testJbowtieGokogiri(r *http.Request, n gokogiriXml.Node) { r.ParseForm() - username := r.Form.Get("username") - password := r.Form.Get("password") + username := r.Form.Get("username") // $ Source + password := r.Form.Get("password") // $ Source // BAD: User input used directly in an XPath expression - xpath := gokogiriXpath.Compile("//users/user[login/text()='" + username + "' and password/text() = '" + password + "']/home_dir/text()") - _, _ = n.Search("//users/user[login/text()='" + username + "' and password/text() = '" + password + "']/home_dir/text()") - _, _ = n.SearchWithVariables("//users/user[login/text()='"+username+"' and password/text() = '"+password+"']/home_dir/text()", nil) - _, _ = n.EvalXPath("//users/user[login/text()='"+username+"' and password/text() = '"+password+"']/home_dir/text()", nil) - _ = n.EvalXPathAsBoolean("//users/user[login/text()='"+username+"' and password/text() = '"+password+"']/home_dir/text()", nil) + xpath := gokogiriXpath.Compile("//users/user[login/text()='" + username + "' and password/text() = '" + password + "']/home_dir/text()") // $ Alert + _, _ = n.Search("//users/user[login/text()='" + username + "' and password/text() = '" + password + "']/home_dir/text()") // $ Alert + _, _ = n.SearchWithVariables("//users/user[login/text()='"+username+"' and password/text() = '"+password+"']/home_dir/text()", nil) // $ Alert + _, _ = n.EvalXPath("//users/user[login/text()='"+username+"' and password/text() = '"+password+"']/home_dir/text()", nil) // $ Alert + _ = n.EvalXPathAsBoolean("//users/user[login/text()='"+username+"' and password/text() = '"+password+"']/home_dir/text()", nil) // $ Alert // OK: Not flagged, since the creation of `xpath` is already flagged. _, _ = n.Search(xpath) @@ -136,12 +136,12 @@ func testJbowtieGokogiri(r *http.Request, n gokogiriXml.Node) { func testLestratGoLibxml2(r *http.Request) { r.ParseForm() - username := r.Form.Get("username") + username := r.Form.Get("username") // $ Source p := parser.New(parser.XMLParseNoEnt) // BAD: User input used directly in an XPath expression - _, _ = p.Parse([]byte("//users/user[login/text()='" + username + "']/home_dir/text()")) + _, _ = p.Parse([]byte("//users/user[login/text()='" + username + "']/home_dir/text()")) // $ Alert _, _ = p.ParseReader(strings.NewReader("//users/user[login/text()='" + username + "']/home_dir/text()")) - _, _ = p.ParseString("//users/user[login/text()='" + username + "']/home_dir/text()") + _, _ = p.ParseString("//users/user[login/text()='" + username + "']/home_dir/text()") // $ Alert } diff --git a/go/ql/test/query-tests/Security/CWE-798/AlertSuppressionExample.go b/go/ql/test/query-tests/Security/CWE-798/AlertSuppressionExample.go index c6cd369394f..938884f98df 100644 --- a/go/ql/test/query-tests/Security/CWE-798/AlertSuppressionExample.go +++ b/go/ql/test/query-tests/Security/CWE-798/AlertSuppressionExample.go @@ -8,7 +8,7 @@ func login(user, password string) bool { func TestLogin(t *testing.T) { user := "testuser" - password := "horsebatterystaplecorrect" // lgtm[go/hardcoded-credentials] + password := "horsebatterystaplecorrect" // $ Alert // lgtm[go/hardcoded-credentials] if !login(user, password) { t.Errorf("Login test failed.") } diff --git a/go/ql/test/query-tests/Security/CWE-798/HardcodedCredentials.go b/go/ql/test/query-tests/Security/CWE-798/HardcodedCredentials.go index 78d0603c2c3..8c3a96c941b 100644 --- a/go/ql/test/query-tests/Security/CWE-798/HardcodedCredentials.go +++ b/go/ql/test/query-tests/Security/CWE-798/HardcodedCredentials.go @@ -7,7 +7,7 @@ import ( const ( user = "dbuser" - password = "s3cretp4ssword" + password = "s3cretp4ssword" // $ Alert ) func connect() *sql.DB { diff --git a/go/ql/test/query-tests/Security/CWE-798/HardcodedKeysBad.go b/go/ql/test/query-tests/Security/CWE-798/HardcodedKeysBad.go index 2ffc46147f6..1c91a2b97b5 100644 --- a/go/ql/test/query-tests/Security/CWE-798/HardcodedKeysBad.go +++ b/go/ql/test/query-tests/Security/CWE-798/HardcodedKeysBad.go @@ -16,5 +16,5 @@ func bad() (interface{}, error) { } token := jwt.NewWithClaims(nil, claims) - return token.SignedString(mySigningKey) + return token.SignedString(mySigningKey) // $ Alert } diff --git a/go/ql/test/query-tests/Security/CWE-798/jwt.go b/go/ql/test/query-tests/Security/CWE-798/jwt.go index 560f95800df..f43749e6b4a 100644 --- a/go/ql/test/query-tests/Security/CWE-798/jwt.go +++ b/go/ql/test/query-tests/Security/CWE-798/jwt.go @@ -39,14 +39,14 @@ func gjwtt() (interface{}, error) { } token := gjwt.NewWithClaims(nil, claims) - return token.SignedString(mySigningKey) // BAD + return token.SignedString(mySigningKey) // $ Alert // BAD } func gin_jwt() (interface{}, error) { var identityKey = "id" return jwt.New(&jwt.GinJWTMiddleware{ Realm: "test zone", - Key: []byte("key2"), // BAD + Key: []byte("key2"), // $ Alert // BAD Timeout: time.Hour, MaxRefresh: time.Hour, IdentityKey: identityKey, @@ -65,12 +65,12 @@ func gin_jwt() (interface{}, error) { func cristalhq() (interface{}, error) { key := []byte(`key3`) - return cristal.NewSignerHS(cristal.HS256, key) // BAD + return cristal.NewSignerHS(cristal.HS256, key) // $ Alert // BAD } func josev3() (interface{}, error) { key := []byte("key4") - return jose_v3.NewSigner(jose_v3.SigningKey{Algorithm: "", Key: key}, nil) // BAD + return jose_v3.NewSigner(jose_v3.SigningKey{Algorithm: "", Key: key}, nil) // $ Alert // BAD } func josev3_2() (interface{}, error) { key2 := []byte("key5") @@ -78,7 +78,7 @@ func josev3_2() (interface{}, error) { "", jose_v3.Recipient{ Algorithm: "", - Key: key2, // BAD + Key: key2, // $ Alert // BAD }, nil) } @@ -88,14 +88,14 @@ func josev2() (interface{}, error) { return jose_v2.NewEncrypter( "", - jose_v2.Recipient{Algorithm: "", Key: key}, // BAD + jose_v2.Recipient{Algorithm: "", Key: key}, // $ Alert // BAD nil, ) } func jose_v2_2() (interface{}, error) { key2 := []byte("key7") - return jose_v2.NewSigner(jose_v2.SigningKey{Algorithm: "", Key: key2}, nil) // BAD + return jose_v2.NewSigner(jose_v2.SigningKey{Algorithm: "", Key: key2}, nil) // $ Alert // BAD } func go_kit() interface{} { @@ -106,24 +106,24 @@ func go_kit() interface{} { mapClaims = gjwt.MapClaims{"user": "go-kit"} ) - return gokit.NewSigner(kid, key, nil, mapClaims) // BAD + return gokit.NewSigner(kid, key, nil, mapClaims) // $ Alert // BAD } func lejwt() (interface{}, error) { sharedKey := []byte("key9") - return le.New(sharedKey) // BAD + return le.New(sharedKey) // $ Alert // BAD } var sharedKeyglobal = []byte("key10") func lejwt2() (interface{}, error) { - return le.New(sharedKeyglobal) // BAD + return le.New(sharedKeyglobal) // $ Alert // BAD } func gogfjwt() interface{} { return &gogf.GfJWTMiddleware{ Realm: "test zone", - Key: []byte("key11"), // BAD + Key: []byte("key11"), // $ Alert // BAD Timeout: time.Minute * 5, MaxRefresh: time.Minute * 5, IdentityKey: "id", @@ -140,7 +140,7 @@ func gogfjwt() interface{} { func irisjwt() interface{} { key := []byte("key12") token := iris.NewTokenWithClaims(nil, nil) - tokenString, _ := token.SignedString(key) // BAD + tokenString, _ := token.SignedString(key) // $ Alert // BAD return tokenString } @@ -149,7 +149,7 @@ func iris12jwt2() interface{} { s := &iris12.Signer{ Alg: nil, - Key: key, // BAD + Key: key, // $ Alert // BAD MaxAge: 3 * time.Second, } return s @@ -157,31 +157,31 @@ func iris12jwt2() interface{} { func irisjwt3() interface{} { key := []byte("key14") - signer := iris12.NewSigner(nil, key, 3*time.Second) // BAD + signer := iris12.NewSigner(nil, key, 3*time.Second) // $ Alert // BAD return signer } func katarasJwt() interface{} { key := []byte("key15") - token, _ := kataras.Sign(nil, key, nil, nil) // BAD + token, _ := kataras.Sign(nil, key, nil, nil) // $ Alert // BAD return token } func katarasJwt2() interface{} { key := []byte("key16") - token, _ := kataras.SignEncrypted(nil, key, nil, nil) // BAD + token, _ := kataras.SignEncrypted(nil, key, nil, nil) // $ Alert // BAD return token } func katarasJwt3() interface{} { key := []byte("key17") - token, _ := kataras.SignEncryptedWithHeader(nil, key, nil, nil, nil) // BAD + token, _ := kataras.SignEncryptedWithHeader(nil, key, nil, nil, nil) // $ Alert // BAD return token } func katarasJwt4() interface{} { key := []byte("key18") - token, _ := kataras.SignWithHeader(nil, key, nil, nil) // BAD + token, _ := kataras.SignWithHeader(nil, key, nil, nil) // $ Alert // BAD return token } @@ -189,5 +189,5 @@ func katarasJwt5() { key := []byte("key19") var keys kataras.Keys var alg kataras.Alg - keys.Register(alg, "api", nil, key) // BAD + keys.Register(alg, "api", nil, key) // $ Alert // BAD } diff --git a/go/ql/test/query-tests/Security/CWE-798/main.go b/go/ql/test/query-tests/Security/CWE-798/main.go index 366933c7693..7934c0d842f 100644 --- a/go/ql/test/query-tests/Security/CWE-798/main.go +++ b/go/ql/test/query-tests/Security/CWE-798/main.go @@ -3,7 +3,7 @@ package main import "fmt" const ( - passwd = "p4ssw0rd" // NOT OK + passwd = "p4ssw0rd" // $ Alert // NOT OK _password = "" // OK ) diff --git a/go/ql/test/query-tests/Security/CWE-798/sanitizer.go b/go/ql/test/query-tests/Security/CWE-798/sanitizer.go index 749642ceb3b..19cd3313987 100644 --- a/go/ql/test/query-tests/Security/CWE-798/sanitizer.go +++ b/go/ql/test/query-tests/Security/CWE-798/sanitizer.go @@ -15,7 +15,7 @@ import ( func check_ok() (interface{}, error) { key := []byte(`some_key`) - return cristal.NewSignerHS(cristal.HS256, key) // BAD + return cristal.NewSignerHS(cristal.HS256, key) // $ Alert // BAD } func GenerateRandomString(size int) string { From a375e186eda535d3df4a4370e6cb077b385a8ceb Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Thu, 11 Jun 2026 21:53:01 +0200 Subject: [PATCH 13/23] Third pass --- .../ConstantExpAppearsNonConstant.qlref | 3 ++- .../AbstractToConcreteCollection.qlref | 3 ++- .../ql/test-kotlin1/query-tests/AutoBoxing/AutoBoxing.qlref | 3 ++- .../test-kotlin1/query-tests/CloseReader/CloseReader.qlref | 3 ++- .../test-kotlin1/query-tests/CloseWriter/CloseWriter.qlref | 3 ++- .../ConfusingOverloading/ConfusingOverloading.qlref | 3 ++- java/ql/test-kotlin1/query-tests/ConstantLoopCondition/A.kt | 6 +++--- .../ConstantLoopCondition/ConstantLoopCondition.qlref | 3 ++- java/ql/test-kotlin1/query-tests/DeadCode/DeadClass.qlref | 3 ++- java/ql/test-kotlin1/query-tests/DeadCode/DeadMethod.qlref | 3 ++- .../query-tests/DeadRefTypes/DeadRefTypes.qlref | 3 ++- java/ql/test-kotlin1/query-tests/DeadRefTypes/test.kt | 2 +- .../ql/test-kotlin1/query-tests/EmptyBlock/EmptyBlock.qlref | 3 ++- .../ExposeRepresentation/ExposeRepresentation.qlref | 3 ++- .../InnerClassCouldBeStatic/InnerClassCouldBeStatic.qlref | 3 ++- .../MissingInstanceofInEquals.qlref | 3 ++- .../MissingOverrideAnnotation.qlref | 3 ++- .../query-tests/MutualDependency/MutualDependency.qlref | 3 ++- .../NamingConventionsRefTypes.qlref | 3 ++- .../query-tests/NamingConventionsRefTypes/Test.kt | 2 +- .../NonSerializableField/NonSerializableField.qlref | 3 ++- .../NonSerializableInnerClass.qlref | 3 ++- java/ql/test-kotlin1/query-tests/NullMaybe/NullMaybe.qlref | 3 ++- .../OneStatementPerLine/OneStatementPerLine.qlref | 3 ++- .../PartiallyMaskedCatch/PartiallyMaskedCatch.qlref | 3 ++- .../query-tests/ReturnValueIgnored/ReturnValueIgnored.qlref | 3 ++- .../query-tests/SimplifyBoolExpr/SimplifyBoolExpr.qlref | 3 ++- .../UnderscoreIdentifier/UnderscoreIdentifier.qlref | 3 ++- .../test-kotlin1/query-tests/UnreadLocal/UnreadLocal.qlref | 3 ++- java/ql/test-kotlin1/query-tests/UnreadLocal/test.kt | 4 ++-- java/ql/test-kotlin1/query-tests/UselessNullCheck/Test.kt | 2 +- .../query-tests/UselessNullCheck/UselessNullCheck.qlref | 3 ++- .../query-tests/UselessParameter/UselessParameter.qlref | 3 ++- .../WhitespaceContradictsPrecedence.qlref | 3 ++- .../AbstractToConcreteCollection.qlref | 3 ++- .../ql/test-kotlin2/query-tests/AutoBoxing/AutoBoxing.qlref | 3 ++- .../test-kotlin2/query-tests/CloseReader/CloseReader.qlref | 3 ++- .../test-kotlin2/query-tests/CloseWriter/CloseWriter.qlref | 3 ++- .../ConfusingOverloading/ConfusingOverloading.qlref | 3 ++- java/ql/test-kotlin2/query-tests/ConstantLoopCondition/A.kt | 6 +++--- .../ConstantLoopCondition/ConstantLoopCondition.qlref | 3 ++- java/ql/test-kotlin2/query-tests/DeadCode/DeadClass.qlref | 3 ++- java/ql/test-kotlin2/query-tests/DeadCode/DeadMethod.qlref | 3 ++- .../query-tests/DeadRefTypes/DeadRefTypes.qlref | 3 ++- java/ql/test-kotlin2/query-tests/DeadRefTypes/test.kt | 2 +- .../ql/test-kotlin2/query-tests/EmptyBlock/EmptyBlock.qlref | 3 ++- .../ExposeRepresentation/ExposeRepresentation.qlref | 3 ++- .../InnerClassCouldBeStatic/InnerClassCouldBeStatic.qlref | 3 ++- .../MissingInstanceofInEquals.qlref | 3 ++- .../MissingOverrideAnnotation.qlref | 3 ++- .../query-tests/MutualDependency/MutualDependency.qlref | 3 ++- .../NamingConventionsRefTypes.qlref | 3 ++- .../query-tests/NamingConventionsRefTypes/Test.kt | 2 +- .../NonSerializableField/NonSerializableField.qlref | 3 ++- .../NonSerializableInnerClass.qlref | 3 ++- java/ql/test-kotlin2/query-tests/NullMaybe/NullMaybe.qlref | 3 ++- .../OneStatementPerLine/OneStatementPerLine.qlref | 3 ++- .../PartiallyMaskedCatch/PartiallyMaskedCatch.qlref | 3 ++- .../query-tests/ReturnValueIgnored/ReturnValueIgnored.qlref | 3 ++- .../query-tests/SimplifyBoolExpr/SimplifyBoolExpr.qlref | 3 ++- .../UnderscoreIdentifier/UnderscoreIdentifier.qlref | 3 ++- .../test-kotlin2/query-tests/UnreadLocal/UnreadLocal.qlref | 3 ++- java/ql/test-kotlin2/query-tests/UnreadLocal/test.kt | 4 ++-- java/ql/test-kotlin2/query-tests/UselessNullCheck/Test.kt | 2 +- .../query-tests/UselessNullCheck/UselessNullCheck.qlref | 3 ++- .../query-tests/UselessParameter/UselessParameter.qlref | 3 ++- .../WhitespaceContradictsPrecedence.qlref | 3 ++- 67 files changed, 130 insertions(+), 73 deletions(-) diff --git a/java/ql/integration-tests/kotlin/all-platforms/gradle_kotlinx_serialization/ConstantExpAppearsNonConstant.qlref b/java/ql/integration-tests/kotlin/all-platforms/gradle_kotlinx_serialization/ConstantExpAppearsNonConstant.qlref index 6d7e1f5cb7f..924600d5a4d 100644 --- a/java/ql/integration-tests/kotlin/all-platforms/gradle_kotlinx_serialization/ConstantExpAppearsNonConstant.qlref +++ b/java/ql/integration-tests/kotlin/all-platforms/gradle_kotlinx_serialization/ConstantExpAppearsNonConstant.qlref @@ -1 +1,2 @@ -Likely Bugs/Arithmetic/ConstantExpAppearsNonConstant.ql \ No newline at end of file +query: Likely Bugs/Arithmetic/ConstantExpAppearsNonConstant.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/AbstractToConcreteCollection/AbstractToConcreteCollection.qlref b/java/ql/test-kotlin1/query-tests/AbstractToConcreteCollection/AbstractToConcreteCollection.qlref index ddc5d95d9d1..d7ef72c65e3 100644 --- a/java/ql/test-kotlin1/query-tests/AbstractToConcreteCollection/AbstractToConcreteCollection.qlref +++ b/java/ql/test-kotlin1/query-tests/AbstractToConcreteCollection/AbstractToConcreteCollection.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Implementation Hiding/AbstractToConcreteCollection.ql \ No newline at end of file +query: Violations of Best Practice/Implementation Hiding/AbstractToConcreteCollection.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/AutoBoxing/AutoBoxing.qlref b/java/ql/test-kotlin1/query-tests/AutoBoxing/AutoBoxing.qlref index f116f3bd8b4..dc47875616d 100644 --- a/java/ql/test-kotlin1/query-tests/AutoBoxing/AutoBoxing.qlref +++ b/java/ql/test-kotlin1/query-tests/AutoBoxing/AutoBoxing.qlref @@ -1 +1,2 @@ -Violations of Best Practice/legacy/AutoBoxing.ql +query: Violations of Best Practice/legacy/AutoBoxing.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/CloseReader/CloseReader.qlref b/java/ql/test-kotlin1/query-tests/CloseReader/CloseReader.qlref index 1c808bb9f46..9fae04fe76d 100644 --- a/java/ql/test-kotlin1/query-tests/CloseReader/CloseReader.qlref +++ b/java/ql/test-kotlin1/query-tests/CloseReader/CloseReader.qlref @@ -1 +1,2 @@ -Likely Bugs/Resource Leaks/CloseReader.ql +query: Likely Bugs/Resource Leaks/CloseReader.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/CloseWriter/CloseWriter.qlref b/java/ql/test-kotlin1/query-tests/CloseWriter/CloseWriter.qlref index 88008367363..d81d6020dae 100644 --- a/java/ql/test-kotlin1/query-tests/CloseWriter/CloseWriter.qlref +++ b/java/ql/test-kotlin1/query-tests/CloseWriter/CloseWriter.qlref @@ -1 +1,2 @@ -Likely Bugs/Resource Leaks/CloseWriter.ql +query: Likely Bugs/Resource Leaks/CloseWriter.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/ConfusingOverloading/ConfusingOverloading.qlref b/java/ql/test-kotlin1/query-tests/ConfusingOverloading/ConfusingOverloading.qlref index 4fc71295c2c..e74bc1b00aa 100644 --- a/java/ql/test-kotlin1/query-tests/ConfusingOverloading/ConfusingOverloading.qlref +++ b/java/ql/test-kotlin1/query-tests/ConfusingOverloading/ConfusingOverloading.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Naming Conventions/ConfusingOverloading.ql \ No newline at end of file +query: Violations of Best Practice/Naming Conventions/ConfusingOverloading.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/ConstantLoopCondition/A.kt b/java/ql/test-kotlin1/query-tests/ConstantLoopCondition/A.kt index 8c111c58fe7..b04d3135e8f 100644 --- a/java/ql/test-kotlin1/query-tests/ConstantLoopCondition/A.kt +++ b/java/ql/test-kotlin1/query-tests/ConstantLoopCondition/A.kt @@ -2,21 +2,21 @@ fun fn0(f: Function0) = f() fun fn1() { var c = true - while (c) { // TODO: false positive + while (c) { // $ SPURIOUS: Alert // TODO: false positive fn0 { c = false } } var d = true - while (d) { + while (d) { // $ Alert fn0 { println(d) } } val e = true - while (e) { + while (e) { // $ Alert fn0 { println(e) } diff --git a/java/ql/test-kotlin1/query-tests/ConstantLoopCondition/ConstantLoopCondition.qlref b/java/ql/test-kotlin1/query-tests/ConstantLoopCondition/ConstantLoopCondition.qlref index 37e6a9b72fe..f7081322f7d 100644 --- a/java/ql/test-kotlin1/query-tests/ConstantLoopCondition/ConstantLoopCondition.qlref +++ b/java/ql/test-kotlin1/query-tests/ConstantLoopCondition/ConstantLoopCondition.qlref @@ -1 +1,2 @@ -Likely Bugs/Termination/ConstantLoopCondition.ql +query: Likely Bugs/Termination/ConstantLoopCondition.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/DeadCode/DeadClass.qlref b/java/ql/test-kotlin1/query-tests/DeadCode/DeadClass.qlref index d726e7e0849..b94832ebfca 100644 --- a/java/ql/test-kotlin1/query-tests/DeadCode/DeadClass.qlref +++ b/java/ql/test-kotlin1/query-tests/DeadCode/DeadClass.qlref @@ -1 +1,2 @@ -DeadCode/DeadClass.ql +query: DeadCode/DeadClass.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/DeadCode/DeadMethod.qlref b/java/ql/test-kotlin1/query-tests/DeadCode/DeadMethod.qlref index 76204a1df5a..743a5f15775 100644 --- a/java/ql/test-kotlin1/query-tests/DeadCode/DeadMethod.qlref +++ b/java/ql/test-kotlin1/query-tests/DeadCode/DeadMethod.qlref @@ -1 +1,2 @@ -DeadCode/DeadMethod.ql +query: DeadCode/DeadMethod.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/DeadRefTypes/DeadRefTypes.qlref b/java/ql/test-kotlin1/query-tests/DeadRefTypes/DeadRefTypes.qlref index 2b925a78cbb..e8f47f2d682 100644 --- a/java/ql/test-kotlin1/query-tests/DeadRefTypes/DeadRefTypes.qlref +++ b/java/ql/test-kotlin1/query-tests/DeadRefTypes/DeadRefTypes.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Dead Code/DeadRefTypes.ql \ No newline at end of file +query: Violations of Best Practice/Dead Code/DeadRefTypes.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/DeadRefTypes/test.kt b/java/ql/test-kotlin1/query-tests/DeadRefTypes/test.kt index 6a38aa0f748..c65e8ab0d58 100644 --- a/java/ql/test-kotlin1/query-tests/DeadRefTypes/test.kt +++ b/java/ql/test-kotlin1/query-tests/DeadRefTypes/test.kt @@ -1,4 +1,4 @@ -private class C1 { } +private class C1 { } // $ Alert private class C2 { } diff --git a/java/ql/test-kotlin1/query-tests/EmptyBlock/EmptyBlock.qlref b/java/ql/test-kotlin1/query-tests/EmptyBlock/EmptyBlock.qlref index b0a56e88aa4..5fe264815b8 100644 --- a/java/ql/test-kotlin1/query-tests/EmptyBlock/EmptyBlock.qlref +++ b/java/ql/test-kotlin1/query-tests/EmptyBlock/EmptyBlock.qlref @@ -1 +1,2 @@ -Likely Bugs/Statements/EmptyBlock.ql \ No newline at end of file +query: Likely Bugs/Statements/EmptyBlock.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/ExposeRepresentation/ExposeRepresentation.qlref b/java/ql/test-kotlin1/query-tests/ExposeRepresentation/ExposeRepresentation.qlref index 6452bb942d2..e47d860dcc2 100644 --- a/java/ql/test-kotlin1/query-tests/ExposeRepresentation/ExposeRepresentation.qlref +++ b/java/ql/test-kotlin1/query-tests/ExposeRepresentation/ExposeRepresentation.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Implementation Hiding/ExposeRepresentation.ql +query: Violations of Best Practice/Implementation Hiding/ExposeRepresentation.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/InnerClassCouldBeStatic/InnerClassCouldBeStatic.qlref b/java/ql/test-kotlin1/query-tests/InnerClassCouldBeStatic/InnerClassCouldBeStatic.qlref index 3d3b5444609..68cb3e6761e 100644 --- a/java/ql/test-kotlin1/query-tests/InnerClassCouldBeStatic/InnerClassCouldBeStatic.qlref +++ b/java/ql/test-kotlin1/query-tests/InnerClassCouldBeStatic/InnerClassCouldBeStatic.qlref @@ -1 +1,2 @@ -Performance/InnerClassCouldBeStatic.ql \ No newline at end of file +query: Performance/InnerClassCouldBeStatic.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/MissingInstanceofInEquals/MissingInstanceofInEquals.qlref b/java/ql/test-kotlin1/query-tests/MissingInstanceofInEquals/MissingInstanceofInEquals.qlref index 40038cf027a..d1a5c7d8130 100644 --- a/java/ql/test-kotlin1/query-tests/MissingInstanceofInEquals/MissingInstanceofInEquals.qlref +++ b/java/ql/test-kotlin1/query-tests/MissingInstanceofInEquals/MissingInstanceofInEquals.qlref @@ -1 +1,2 @@ -Likely Bugs/Comparison/MissingInstanceofInEquals.ql \ No newline at end of file +query: Likely Bugs/Comparison/MissingInstanceofInEquals.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/MissingOverrideAnnotation/MissingOverrideAnnotation.qlref b/java/ql/test-kotlin1/query-tests/MissingOverrideAnnotation/MissingOverrideAnnotation.qlref index c74780e7d24..885c1312f9e 100644 --- a/java/ql/test-kotlin1/query-tests/MissingOverrideAnnotation/MissingOverrideAnnotation.qlref +++ b/java/ql/test-kotlin1/query-tests/MissingOverrideAnnotation/MissingOverrideAnnotation.qlref @@ -1 +1,2 @@ -Advisory/Declarations/MissingOverrideAnnotation.ql \ No newline at end of file +query: Advisory/Declarations/MissingOverrideAnnotation.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/MutualDependency/MutualDependency.qlref b/java/ql/test-kotlin1/query-tests/MutualDependency/MutualDependency.qlref index ab1dbe353ef..273ed4d757a 100644 --- a/java/ql/test-kotlin1/query-tests/MutualDependency/MutualDependency.qlref +++ b/java/ql/test-kotlin1/query-tests/MutualDependency/MutualDependency.qlref @@ -1 +1,2 @@ -Architecture/Dependencies/MutualDependency.ql \ No newline at end of file +query: Architecture/Dependencies/MutualDependency.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/NamingConventionsRefTypes/NamingConventionsRefTypes.qlref b/java/ql/test-kotlin1/query-tests/NamingConventionsRefTypes/NamingConventionsRefTypes.qlref index 6f76aed32cb..52bea60e468 100644 --- a/java/ql/test-kotlin1/query-tests/NamingConventionsRefTypes/NamingConventionsRefTypes.qlref +++ b/java/ql/test-kotlin1/query-tests/NamingConventionsRefTypes/NamingConventionsRefTypes.qlref @@ -1 +1,2 @@ -Advisory/Naming/NamingConventionsRefTypes.ql \ No newline at end of file +query: Advisory/Naming/NamingConventionsRefTypes.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/NamingConventionsRefTypes/Test.kt b/java/ql/test-kotlin1/query-tests/NamingConventionsRefTypes/Test.kt index f62497d59c6..1374f616316 100644 --- a/java/ql/test-kotlin1/query-tests/NamingConventionsRefTypes/Test.kt +++ b/java/ql/test-kotlin1/query-tests/NamingConventionsRefTypes/Test.kt @@ -9,4 +9,4 @@ class Foo { } } -class aaaa {} \ No newline at end of file +class aaaa {} // $ Alert diff --git a/java/ql/test-kotlin1/query-tests/NonSerializableField/NonSerializableField.qlref b/java/ql/test-kotlin1/query-tests/NonSerializableField/NonSerializableField.qlref index 401d63757af..1b3b59559be 100644 --- a/java/ql/test-kotlin1/query-tests/NonSerializableField/NonSerializableField.qlref +++ b/java/ql/test-kotlin1/query-tests/NonSerializableField/NonSerializableField.qlref @@ -1 +1,2 @@ -Likely Bugs/Serialization/NonSerializableField.ql +query: Likely Bugs/Serialization/NonSerializableField.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/NonSerializableInnerClass/NonSerializableInnerClass.qlref b/java/ql/test-kotlin1/query-tests/NonSerializableInnerClass/NonSerializableInnerClass.qlref index 4cbb0995764..0ce5b0819e9 100644 --- a/java/ql/test-kotlin1/query-tests/NonSerializableInnerClass/NonSerializableInnerClass.qlref +++ b/java/ql/test-kotlin1/query-tests/NonSerializableInnerClass/NonSerializableInnerClass.qlref @@ -1 +1,2 @@ -Likely Bugs/Serialization/NonSerializableInnerClass.ql +query: Likely Bugs/Serialization/NonSerializableInnerClass.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/NullMaybe/NullMaybe.qlref b/java/ql/test-kotlin1/query-tests/NullMaybe/NullMaybe.qlref index ab01473d8e5..19125c7bc59 100644 --- a/java/ql/test-kotlin1/query-tests/NullMaybe/NullMaybe.qlref +++ b/java/ql/test-kotlin1/query-tests/NullMaybe/NullMaybe.qlref @@ -1 +1,2 @@ -Likely Bugs/Nullness/NullMaybe.ql +query: Likely Bugs/Nullness/NullMaybe.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/OneStatementPerLine/OneStatementPerLine.qlref b/java/ql/test-kotlin1/query-tests/OneStatementPerLine/OneStatementPerLine.qlref index 99f3f3f3293..dbe810b5208 100644 --- a/java/ql/test-kotlin1/query-tests/OneStatementPerLine/OneStatementPerLine.qlref +++ b/java/ql/test-kotlin1/query-tests/OneStatementPerLine/OneStatementPerLine.qlref @@ -1 +1,2 @@ -Advisory/Statements/OneStatementPerLine.ql \ No newline at end of file +query: Advisory/Statements/OneStatementPerLine.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/PartiallyMaskedCatch/PartiallyMaskedCatch.qlref b/java/ql/test-kotlin1/query-tests/PartiallyMaskedCatch/PartiallyMaskedCatch.qlref index c2db43d8953..a129d30287b 100644 --- a/java/ql/test-kotlin1/query-tests/PartiallyMaskedCatch/PartiallyMaskedCatch.qlref +++ b/java/ql/test-kotlin1/query-tests/PartiallyMaskedCatch/PartiallyMaskedCatch.qlref @@ -1 +1,2 @@ -Likely Bugs/Statements/PartiallyMaskedCatch.ql \ No newline at end of file +query: Likely Bugs/Statements/PartiallyMaskedCatch.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/ReturnValueIgnored/ReturnValueIgnored.qlref b/java/ql/test-kotlin1/query-tests/ReturnValueIgnored/ReturnValueIgnored.qlref index ef1dc964d95..ab13392ec55 100644 --- a/java/ql/test-kotlin1/query-tests/ReturnValueIgnored/ReturnValueIgnored.qlref +++ b/java/ql/test-kotlin1/query-tests/ReturnValueIgnored/ReturnValueIgnored.qlref @@ -1 +1,2 @@ -Likely Bugs/Statements/ReturnValueIgnored.ql \ No newline at end of file +query: Likely Bugs/Statements/ReturnValueIgnored.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/SimplifyBoolExpr/SimplifyBoolExpr.qlref b/java/ql/test-kotlin1/query-tests/SimplifyBoolExpr/SimplifyBoolExpr.qlref index d071e989ebb..45d0db5559c 100644 --- a/java/ql/test-kotlin1/query-tests/SimplifyBoolExpr/SimplifyBoolExpr.qlref +++ b/java/ql/test-kotlin1/query-tests/SimplifyBoolExpr/SimplifyBoolExpr.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Boolean Logic/SimplifyBoolExpr.ql +query: Violations of Best Practice/Boolean Logic/SimplifyBoolExpr.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/UnderscoreIdentifier/UnderscoreIdentifier.qlref b/java/ql/test-kotlin1/query-tests/UnderscoreIdentifier/UnderscoreIdentifier.qlref index dbed8c6f411..7aa4b4176e3 100644 --- a/java/ql/test-kotlin1/query-tests/UnderscoreIdentifier/UnderscoreIdentifier.qlref +++ b/java/ql/test-kotlin1/query-tests/UnderscoreIdentifier/UnderscoreIdentifier.qlref @@ -1 +1,2 @@ -Compatibility/JDK9/UnderscoreIdentifier.ql \ No newline at end of file +query: Compatibility/JDK9/UnderscoreIdentifier.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/UnreadLocal/UnreadLocal.qlref b/java/ql/test-kotlin1/query-tests/UnreadLocal/UnreadLocal.qlref index 5a77117711e..dc6fb57ca6a 100644 --- a/java/ql/test-kotlin1/query-tests/UnreadLocal/UnreadLocal.qlref +++ b/java/ql/test-kotlin1/query-tests/UnreadLocal/UnreadLocal.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Dead Code/UnreadLocal.ql +query: Violations of Best Practice/Dead Code/UnreadLocal.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/UnreadLocal/test.kt b/java/ql/test-kotlin1/query-tests/UnreadLocal/test.kt index e1663d7c116..a7537d128d8 100644 --- a/java/ql/test-kotlin1/query-tests/UnreadLocal/test.kt +++ b/java/ql/test-kotlin1/query-tests/UnreadLocal/test.kt @@ -5,13 +5,13 @@ fun fn0(size: Int) { } fun fn1(a: Array) { - for (e in a) { + for (e in a) { // $ Alert println() } } fun fn2(a: Array) { - for ((idx, e) in a.withIndex()) { + for ((idx, e) in a.withIndex()) { // $ Alert println() } } diff --git a/java/ql/test-kotlin1/query-tests/UselessNullCheck/Test.kt b/java/ql/test-kotlin1/query-tests/UselessNullCheck/Test.kt index 138309dc9de..365eb5083a2 100644 --- a/java/ql/test-kotlin1/query-tests/UselessNullCheck/Test.kt +++ b/java/ql/test-kotlin1/query-tests/UselessNullCheck/Test.kt @@ -13,6 +13,6 @@ fun fn(x:Any?, y: Any?) { fun fn0(o: Any?) { if (o != null) { o?.toString() - o.toString() + o.toString() // $ Alert } } diff --git a/java/ql/test-kotlin1/query-tests/UselessNullCheck/UselessNullCheck.qlref b/java/ql/test-kotlin1/query-tests/UselessNullCheck/UselessNullCheck.qlref index 8b5a095d396..68c4adcf428 100644 --- a/java/ql/test-kotlin1/query-tests/UselessNullCheck/UselessNullCheck.qlref +++ b/java/ql/test-kotlin1/query-tests/UselessNullCheck/UselessNullCheck.qlref @@ -1 +1,2 @@ -Language Abuse/UselessNullCheck.ql +query: Language Abuse/UselessNullCheck.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/UselessParameter/UselessParameter.qlref b/java/ql/test-kotlin1/query-tests/UselessParameter/UselessParameter.qlref index b1ceb2751a6..7de29d4e3f4 100644 --- a/java/ql/test-kotlin1/query-tests/UselessParameter/UselessParameter.qlref +++ b/java/ql/test-kotlin1/query-tests/UselessParameter/UselessParameter.qlref @@ -1 +1,2 @@ -DeadCode/UselessParameter.ql \ No newline at end of file +query: DeadCode/UselessParameter.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin1/query-tests/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.qlref b/java/ql/test-kotlin1/query-tests/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.qlref index e8331b4132f..470fdcfe273 100644 --- a/java/ql/test-kotlin1/query-tests/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.qlref +++ b/java/ql/test-kotlin1/query-tests/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.qlref @@ -1 +1,2 @@ -Likely Bugs/Arithmetic/WhitespaceContradictsPrecedence.ql \ No newline at end of file +query: Likely Bugs/Arithmetic/WhitespaceContradictsPrecedence.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/AbstractToConcreteCollection/AbstractToConcreteCollection.qlref b/java/ql/test-kotlin2/query-tests/AbstractToConcreteCollection/AbstractToConcreteCollection.qlref index ddc5d95d9d1..d7ef72c65e3 100644 --- a/java/ql/test-kotlin2/query-tests/AbstractToConcreteCollection/AbstractToConcreteCollection.qlref +++ b/java/ql/test-kotlin2/query-tests/AbstractToConcreteCollection/AbstractToConcreteCollection.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Implementation Hiding/AbstractToConcreteCollection.ql \ No newline at end of file +query: Violations of Best Practice/Implementation Hiding/AbstractToConcreteCollection.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/AutoBoxing/AutoBoxing.qlref b/java/ql/test-kotlin2/query-tests/AutoBoxing/AutoBoxing.qlref index f116f3bd8b4..dc47875616d 100644 --- a/java/ql/test-kotlin2/query-tests/AutoBoxing/AutoBoxing.qlref +++ b/java/ql/test-kotlin2/query-tests/AutoBoxing/AutoBoxing.qlref @@ -1 +1,2 @@ -Violations of Best Practice/legacy/AutoBoxing.ql +query: Violations of Best Practice/legacy/AutoBoxing.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/CloseReader/CloseReader.qlref b/java/ql/test-kotlin2/query-tests/CloseReader/CloseReader.qlref index 1c808bb9f46..9fae04fe76d 100644 --- a/java/ql/test-kotlin2/query-tests/CloseReader/CloseReader.qlref +++ b/java/ql/test-kotlin2/query-tests/CloseReader/CloseReader.qlref @@ -1 +1,2 @@ -Likely Bugs/Resource Leaks/CloseReader.ql +query: Likely Bugs/Resource Leaks/CloseReader.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/CloseWriter/CloseWriter.qlref b/java/ql/test-kotlin2/query-tests/CloseWriter/CloseWriter.qlref index 88008367363..d81d6020dae 100644 --- a/java/ql/test-kotlin2/query-tests/CloseWriter/CloseWriter.qlref +++ b/java/ql/test-kotlin2/query-tests/CloseWriter/CloseWriter.qlref @@ -1 +1,2 @@ -Likely Bugs/Resource Leaks/CloseWriter.ql +query: Likely Bugs/Resource Leaks/CloseWriter.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/ConfusingOverloading/ConfusingOverloading.qlref b/java/ql/test-kotlin2/query-tests/ConfusingOverloading/ConfusingOverloading.qlref index 4fc71295c2c..e74bc1b00aa 100644 --- a/java/ql/test-kotlin2/query-tests/ConfusingOverloading/ConfusingOverloading.qlref +++ b/java/ql/test-kotlin2/query-tests/ConfusingOverloading/ConfusingOverloading.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Naming Conventions/ConfusingOverloading.ql \ No newline at end of file +query: Violations of Best Practice/Naming Conventions/ConfusingOverloading.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/ConstantLoopCondition/A.kt b/java/ql/test-kotlin2/query-tests/ConstantLoopCondition/A.kt index 8c111c58fe7..b04d3135e8f 100644 --- a/java/ql/test-kotlin2/query-tests/ConstantLoopCondition/A.kt +++ b/java/ql/test-kotlin2/query-tests/ConstantLoopCondition/A.kt @@ -2,21 +2,21 @@ fun fn0(f: Function0) = f() fun fn1() { var c = true - while (c) { // TODO: false positive + while (c) { // $ SPURIOUS: Alert // TODO: false positive fn0 { c = false } } var d = true - while (d) { + while (d) { // $ Alert fn0 { println(d) } } val e = true - while (e) { + while (e) { // $ Alert fn0 { println(e) } diff --git a/java/ql/test-kotlin2/query-tests/ConstantLoopCondition/ConstantLoopCondition.qlref b/java/ql/test-kotlin2/query-tests/ConstantLoopCondition/ConstantLoopCondition.qlref index 37e6a9b72fe..f7081322f7d 100644 --- a/java/ql/test-kotlin2/query-tests/ConstantLoopCondition/ConstantLoopCondition.qlref +++ b/java/ql/test-kotlin2/query-tests/ConstantLoopCondition/ConstantLoopCondition.qlref @@ -1 +1,2 @@ -Likely Bugs/Termination/ConstantLoopCondition.ql +query: Likely Bugs/Termination/ConstantLoopCondition.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/DeadCode/DeadClass.qlref b/java/ql/test-kotlin2/query-tests/DeadCode/DeadClass.qlref index d726e7e0849..b94832ebfca 100644 --- a/java/ql/test-kotlin2/query-tests/DeadCode/DeadClass.qlref +++ b/java/ql/test-kotlin2/query-tests/DeadCode/DeadClass.qlref @@ -1 +1,2 @@ -DeadCode/DeadClass.ql +query: DeadCode/DeadClass.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/DeadCode/DeadMethod.qlref b/java/ql/test-kotlin2/query-tests/DeadCode/DeadMethod.qlref index 76204a1df5a..743a5f15775 100644 --- a/java/ql/test-kotlin2/query-tests/DeadCode/DeadMethod.qlref +++ b/java/ql/test-kotlin2/query-tests/DeadCode/DeadMethod.qlref @@ -1 +1,2 @@ -DeadCode/DeadMethod.ql +query: DeadCode/DeadMethod.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/DeadRefTypes/DeadRefTypes.qlref b/java/ql/test-kotlin2/query-tests/DeadRefTypes/DeadRefTypes.qlref index 2b925a78cbb..e8f47f2d682 100644 --- a/java/ql/test-kotlin2/query-tests/DeadRefTypes/DeadRefTypes.qlref +++ b/java/ql/test-kotlin2/query-tests/DeadRefTypes/DeadRefTypes.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Dead Code/DeadRefTypes.ql \ No newline at end of file +query: Violations of Best Practice/Dead Code/DeadRefTypes.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/DeadRefTypes/test.kt b/java/ql/test-kotlin2/query-tests/DeadRefTypes/test.kt index 6a38aa0f748..c65e8ab0d58 100644 --- a/java/ql/test-kotlin2/query-tests/DeadRefTypes/test.kt +++ b/java/ql/test-kotlin2/query-tests/DeadRefTypes/test.kt @@ -1,4 +1,4 @@ -private class C1 { } +private class C1 { } // $ Alert private class C2 { } diff --git a/java/ql/test-kotlin2/query-tests/EmptyBlock/EmptyBlock.qlref b/java/ql/test-kotlin2/query-tests/EmptyBlock/EmptyBlock.qlref index b0a56e88aa4..5fe264815b8 100644 --- a/java/ql/test-kotlin2/query-tests/EmptyBlock/EmptyBlock.qlref +++ b/java/ql/test-kotlin2/query-tests/EmptyBlock/EmptyBlock.qlref @@ -1 +1,2 @@ -Likely Bugs/Statements/EmptyBlock.ql \ No newline at end of file +query: Likely Bugs/Statements/EmptyBlock.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/ExposeRepresentation/ExposeRepresentation.qlref b/java/ql/test-kotlin2/query-tests/ExposeRepresentation/ExposeRepresentation.qlref index 6452bb942d2..e47d860dcc2 100644 --- a/java/ql/test-kotlin2/query-tests/ExposeRepresentation/ExposeRepresentation.qlref +++ b/java/ql/test-kotlin2/query-tests/ExposeRepresentation/ExposeRepresentation.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Implementation Hiding/ExposeRepresentation.ql +query: Violations of Best Practice/Implementation Hiding/ExposeRepresentation.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/InnerClassCouldBeStatic/InnerClassCouldBeStatic.qlref b/java/ql/test-kotlin2/query-tests/InnerClassCouldBeStatic/InnerClassCouldBeStatic.qlref index 3d3b5444609..68cb3e6761e 100644 --- a/java/ql/test-kotlin2/query-tests/InnerClassCouldBeStatic/InnerClassCouldBeStatic.qlref +++ b/java/ql/test-kotlin2/query-tests/InnerClassCouldBeStatic/InnerClassCouldBeStatic.qlref @@ -1 +1,2 @@ -Performance/InnerClassCouldBeStatic.ql \ No newline at end of file +query: Performance/InnerClassCouldBeStatic.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/MissingInstanceofInEquals/MissingInstanceofInEquals.qlref b/java/ql/test-kotlin2/query-tests/MissingInstanceofInEquals/MissingInstanceofInEquals.qlref index 40038cf027a..d1a5c7d8130 100644 --- a/java/ql/test-kotlin2/query-tests/MissingInstanceofInEquals/MissingInstanceofInEquals.qlref +++ b/java/ql/test-kotlin2/query-tests/MissingInstanceofInEquals/MissingInstanceofInEquals.qlref @@ -1 +1,2 @@ -Likely Bugs/Comparison/MissingInstanceofInEquals.ql \ No newline at end of file +query: Likely Bugs/Comparison/MissingInstanceofInEquals.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/MissingOverrideAnnotation/MissingOverrideAnnotation.qlref b/java/ql/test-kotlin2/query-tests/MissingOverrideAnnotation/MissingOverrideAnnotation.qlref index c74780e7d24..885c1312f9e 100644 --- a/java/ql/test-kotlin2/query-tests/MissingOverrideAnnotation/MissingOverrideAnnotation.qlref +++ b/java/ql/test-kotlin2/query-tests/MissingOverrideAnnotation/MissingOverrideAnnotation.qlref @@ -1 +1,2 @@ -Advisory/Declarations/MissingOverrideAnnotation.ql \ No newline at end of file +query: Advisory/Declarations/MissingOverrideAnnotation.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/MutualDependency/MutualDependency.qlref b/java/ql/test-kotlin2/query-tests/MutualDependency/MutualDependency.qlref index ab1dbe353ef..273ed4d757a 100644 --- a/java/ql/test-kotlin2/query-tests/MutualDependency/MutualDependency.qlref +++ b/java/ql/test-kotlin2/query-tests/MutualDependency/MutualDependency.qlref @@ -1 +1,2 @@ -Architecture/Dependencies/MutualDependency.ql \ No newline at end of file +query: Architecture/Dependencies/MutualDependency.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/NamingConventionsRefTypes/NamingConventionsRefTypes.qlref b/java/ql/test-kotlin2/query-tests/NamingConventionsRefTypes/NamingConventionsRefTypes.qlref index 6f76aed32cb..52bea60e468 100644 --- a/java/ql/test-kotlin2/query-tests/NamingConventionsRefTypes/NamingConventionsRefTypes.qlref +++ b/java/ql/test-kotlin2/query-tests/NamingConventionsRefTypes/NamingConventionsRefTypes.qlref @@ -1 +1,2 @@ -Advisory/Naming/NamingConventionsRefTypes.ql \ No newline at end of file +query: Advisory/Naming/NamingConventionsRefTypes.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/NamingConventionsRefTypes/Test.kt b/java/ql/test-kotlin2/query-tests/NamingConventionsRefTypes/Test.kt index f62497d59c6..1374f616316 100644 --- a/java/ql/test-kotlin2/query-tests/NamingConventionsRefTypes/Test.kt +++ b/java/ql/test-kotlin2/query-tests/NamingConventionsRefTypes/Test.kt @@ -9,4 +9,4 @@ class Foo { } } -class aaaa {} \ No newline at end of file +class aaaa {} // $ Alert diff --git a/java/ql/test-kotlin2/query-tests/NonSerializableField/NonSerializableField.qlref b/java/ql/test-kotlin2/query-tests/NonSerializableField/NonSerializableField.qlref index 401d63757af..1b3b59559be 100644 --- a/java/ql/test-kotlin2/query-tests/NonSerializableField/NonSerializableField.qlref +++ b/java/ql/test-kotlin2/query-tests/NonSerializableField/NonSerializableField.qlref @@ -1 +1,2 @@ -Likely Bugs/Serialization/NonSerializableField.ql +query: Likely Bugs/Serialization/NonSerializableField.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/NonSerializableInnerClass/NonSerializableInnerClass.qlref b/java/ql/test-kotlin2/query-tests/NonSerializableInnerClass/NonSerializableInnerClass.qlref index 4cbb0995764..0ce5b0819e9 100644 --- a/java/ql/test-kotlin2/query-tests/NonSerializableInnerClass/NonSerializableInnerClass.qlref +++ b/java/ql/test-kotlin2/query-tests/NonSerializableInnerClass/NonSerializableInnerClass.qlref @@ -1 +1,2 @@ -Likely Bugs/Serialization/NonSerializableInnerClass.ql +query: Likely Bugs/Serialization/NonSerializableInnerClass.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/NullMaybe/NullMaybe.qlref b/java/ql/test-kotlin2/query-tests/NullMaybe/NullMaybe.qlref index ab01473d8e5..19125c7bc59 100644 --- a/java/ql/test-kotlin2/query-tests/NullMaybe/NullMaybe.qlref +++ b/java/ql/test-kotlin2/query-tests/NullMaybe/NullMaybe.qlref @@ -1 +1,2 @@ -Likely Bugs/Nullness/NullMaybe.ql +query: Likely Bugs/Nullness/NullMaybe.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/OneStatementPerLine/OneStatementPerLine.qlref b/java/ql/test-kotlin2/query-tests/OneStatementPerLine/OneStatementPerLine.qlref index 99f3f3f3293..dbe810b5208 100644 --- a/java/ql/test-kotlin2/query-tests/OneStatementPerLine/OneStatementPerLine.qlref +++ b/java/ql/test-kotlin2/query-tests/OneStatementPerLine/OneStatementPerLine.qlref @@ -1 +1,2 @@ -Advisory/Statements/OneStatementPerLine.ql \ No newline at end of file +query: Advisory/Statements/OneStatementPerLine.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/PartiallyMaskedCatch/PartiallyMaskedCatch.qlref b/java/ql/test-kotlin2/query-tests/PartiallyMaskedCatch/PartiallyMaskedCatch.qlref index c2db43d8953..a129d30287b 100644 --- a/java/ql/test-kotlin2/query-tests/PartiallyMaskedCatch/PartiallyMaskedCatch.qlref +++ b/java/ql/test-kotlin2/query-tests/PartiallyMaskedCatch/PartiallyMaskedCatch.qlref @@ -1 +1,2 @@ -Likely Bugs/Statements/PartiallyMaskedCatch.ql \ No newline at end of file +query: Likely Bugs/Statements/PartiallyMaskedCatch.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/ReturnValueIgnored/ReturnValueIgnored.qlref b/java/ql/test-kotlin2/query-tests/ReturnValueIgnored/ReturnValueIgnored.qlref index ef1dc964d95..ab13392ec55 100644 --- a/java/ql/test-kotlin2/query-tests/ReturnValueIgnored/ReturnValueIgnored.qlref +++ b/java/ql/test-kotlin2/query-tests/ReturnValueIgnored/ReturnValueIgnored.qlref @@ -1 +1,2 @@ -Likely Bugs/Statements/ReturnValueIgnored.ql \ No newline at end of file +query: Likely Bugs/Statements/ReturnValueIgnored.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/SimplifyBoolExpr/SimplifyBoolExpr.qlref b/java/ql/test-kotlin2/query-tests/SimplifyBoolExpr/SimplifyBoolExpr.qlref index d071e989ebb..45d0db5559c 100644 --- a/java/ql/test-kotlin2/query-tests/SimplifyBoolExpr/SimplifyBoolExpr.qlref +++ b/java/ql/test-kotlin2/query-tests/SimplifyBoolExpr/SimplifyBoolExpr.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Boolean Logic/SimplifyBoolExpr.ql +query: Violations of Best Practice/Boolean Logic/SimplifyBoolExpr.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/UnderscoreIdentifier/UnderscoreIdentifier.qlref b/java/ql/test-kotlin2/query-tests/UnderscoreIdentifier/UnderscoreIdentifier.qlref index dbed8c6f411..7aa4b4176e3 100644 --- a/java/ql/test-kotlin2/query-tests/UnderscoreIdentifier/UnderscoreIdentifier.qlref +++ b/java/ql/test-kotlin2/query-tests/UnderscoreIdentifier/UnderscoreIdentifier.qlref @@ -1 +1,2 @@ -Compatibility/JDK9/UnderscoreIdentifier.ql \ No newline at end of file +query: Compatibility/JDK9/UnderscoreIdentifier.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/UnreadLocal/UnreadLocal.qlref b/java/ql/test-kotlin2/query-tests/UnreadLocal/UnreadLocal.qlref index 5a77117711e..dc6fb57ca6a 100644 --- a/java/ql/test-kotlin2/query-tests/UnreadLocal/UnreadLocal.qlref +++ b/java/ql/test-kotlin2/query-tests/UnreadLocal/UnreadLocal.qlref @@ -1 +1,2 @@ -Violations of Best Practice/Dead Code/UnreadLocal.ql +query: Violations of Best Practice/Dead Code/UnreadLocal.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/UnreadLocal/test.kt b/java/ql/test-kotlin2/query-tests/UnreadLocal/test.kt index e1663d7c116..a7537d128d8 100644 --- a/java/ql/test-kotlin2/query-tests/UnreadLocal/test.kt +++ b/java/ql/test-kotlin2/query-tests/UnreadLocal/test.kt @@ -5,13 +5,13 @@ fun fn0(size: Int) { } fun fn1(a: Array) { - for (e in a) { + for (e in a) { // $ Alert println() } } fun fn2(a: Array) { - for ((idx, e) in a.withIndex()) { + for ((idx, e) in a.withIndex()) { // $ Alert println() } } diff --git a/java/ql/test-kotlin2/query-tests/UselessNullCheck/Test.kt b/java/ql/test-kotlin2/query-tests/UselessNullCheck/Test.kt index 138309dc9de..365eb5083a2 100644 --- a/java/ql/test-kotlin2/query-tests/UselessNullCheck/Test.kt +++ b/java/ql/test-kotlin2/query-tests/UselessNullCheck/Test.kt @@ -13,6 +13,6 @@ fun fn(x:Any?, y: Any?) { fun fn0(o: Any?) { if (o != null) { o?.toString() - o.toString() + o.toString() // $ Alert } } diff --git a/java/ql/test-kotlin2/query-tests/UselessNullCheck/UselessNullCheck.qlref b/java/ql/test-kotlin2/query-tests/UselessNullCheck/UselessNullCheck.qlref index 8b5a095d396..68c4adcf428 100644 --- a/java/ql/test-kotlin2/query-tests/UselessNullCheck/UselessNullCheck.qlref +++ b/java/ql/test-kotlin2/query-tests/UselessNullCheck/UselessNullCheck.qlref @@ -1 +1,2 @@ -Language Abuse/UselessNullCheck.ql +query: Language Abuse/UselessNullCheck.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/UselessParameter/UselessParameter.qlref b/java/ql/test-kotlin2/query-tests/UselessParameter/UselessParameter.qlref index b1ceb2751a6..7de29d4e3f4 100644 --- a/java/ql/test-kotlin2/query-tests/UselessParameter/UselessParameter.qlref +++ b/java/ql/test-kotlin2/query-tests/UselessParameter/UselessParameter.qlref @@ -1 +1,2 @@ -DeadCode/UselessParameter.ql \ No newline at end of file +query: DeadCode/UselessParameter.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/java/ql/test-kotlin2/query-tests/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.qlref b/java/ql/test-kotlin2/query-tests/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.qlref index e8331b4132f..470fdcfe273 100644 --- a/java/ql/test-kotlin2/query-tests/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.qlref +++ b/java/ql/test-kotlin2/query-tests/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.qlref @@ -1 +1,2 @@ -Likely Bugs/Arithmetic/WhitespaceContradictsPrecedence.ql \ No newline at end of file +query: Likely Bugs/Arithmetic/WhitespaceContradictsPrecedence.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql From a4bf2b8f58c97a8fd785ffecc2d5717b9b3246d6 Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Thu, 11 Jun 2026 22:59:39 +0200 Subject: [PATCH 14/23] Fix 3 tests --- .../query-tests/DeadRefTypes/DeadRefTypes.expected | 2 +- .../NamingConventionsRefTypes.expected | 2 +- java/ql/test-kotlin1/query-tests/UselessNullCheck/Test.kt | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/java/ql/test-kotlin1/query-tests/DeadRefTypes/DeadRefTypes.expected b/java/ql/test-kotlin1/query-tests/DeadRefTypes/DeadRefTypes.expected index b900d5172c8..2cf2b34754e 100644 --- a/java/ql/test-kotlin1/query-tests/DeadRefTypes/DeadRefTypes.expected +++ b/java/ql/test-kotlin1/query-tests/DeadRefTypes/DeadRefTypes.expected @@ -1 +1 @@ -| test.kt:1:1:1:20 | C1 | Unused class: C1 is not referenced within this codebase. If not used as an external API it should be removed. | +| test.kt:1:1:1:31 | C1 | Unused class: C1 is not referenced within this codebase. If not used as an external API it should be removed. | diff --git a/java/ql/test-kotlin1/query-tests/NamingConventionsRefTypes/NamingConventionsRefTypes.expected b/java/ql/test-kotlin1/query-tests/NamingConventionsRefTypes/NamingConventionsRefTypes.expected index ffcd13ccc56..89795785c85 100644 --- a/java/ql/test-kotlin1/query-tests/NamingConventionsRefTypes/NamingConventionsRefTypes.expected +++ b/java/ql/test-kotlin1/query-tests/NamingConventionsRefTypes/NamingConventionsRefTypes.expected @@ -1 +1 @@ -| Test.kt:12:1:12:13 | aaaa | Class and interface names should start in uppercase. | +| Test.kt:12:1:12:24 | aaaa | Class and interface names should start in uppercase. | diff --git a/java/ql/test-kotlin1/query-tests/UselessNullCheck/Test.kt b/java/ql/test-kotlin1/query-tests/UselessNullCheck/Test.kt index 365eb5083a2..cca4c6fb51d 100644 --- a/java/ql/test-kotlin1/query-tests/UselessNullCheck/Test.kt +++ b/java/ql/test-kotlin1/query-tests/UselessNullCheck/Test.kt @@ -12,7 +12,7 @@ fun fn(x:Any?, y: Any?) { fun fn0(o: Any?) { if (o != null) { - o?.toString() - o.toString() // $ Alert + o?.toString() // $ Alert + o.toString() } } From 29b0c286a7c98da3431e1b0f230ede466e9a4007 Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Thu, 11 Jun 2026 23:40:14 +0200 Subject: [PATCH 15/23] Fix 3 more tests --- .../query-tests/DeadRefTypes/DeadRefTypes.expected | 2 +- .../NamingConventionsRefTypes.expected | 2 +- java/ql/test-kotlin2/query-tests/UselessNullCheck/Test.kt | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/java/ql/test-kotlin2/query-tests/DeadRefTypes/DeadRefTypes.expected b/java/ql/test-kotlin2/query-tests/DeadRefTypes/DeadRefTypes.expected index b900d5172c8..2cf2b34754e 100644 --- a/java/ql/test-kotlin2/query-tests/DeadRefTypes/DeadRefTypes.expected +++ b/java/ql/test-kotlin2/query-tests/DeadRefTypes/DeadRefTypes.expected @@ -1 +1 @@ -| test.kt:1:1:1:20 | C1 | Unused class: C1 is not referenced within this codebase. If not used as an external API it should be removed. | +| test.kt:1:1:1:31 | C1 | Unused class: C1 is not referenced within this codebase. If not used as an external API it should be removed. | diff --git a/java/ql/test-kotlin2/query-tests/NamingConventionsRefTypes/NamingConventionsRefTypes.expected b/java/ql/test-kotlin2/query-tests/NamingConventionsRefTypes/NamingConventionsRefTypes.expected index ffcd13ccc56..89795785c85 100644 --- a/java/ql/test-kotlin2/query-tests/NamingConventionsRefTypes/NamingConventionsRefTypes.expected +++ b/java/ql/test-kotlin2/query-tests/NamingConventionsRefTypes/NamingConventionsRefTypes.expected @@ -1 +1 @@ -| Test.kt:12:1:12:13 | aaaa | Class and interface names should start in uppercase. | +| Test.kt:12:1:12:24 | aaaa | Class and interface names should start in uppercase. | diff --git a/java/ql/test-kotlin2/query-tests/UselessNullCheck/Test.kt b/java/ql/test-kotlin2/query-tests/UselessNullCheck/Test.kt index 365eb5083a2..cca4c6fb51d 100644 --- a/java/ql/test-kotlin2/query-tests/UselessNullCheck/Test.kt +++ b/java/ql/test-kotlin2/query-tests/UselessNullCheck/Test.kt @@ -12,7 +12,7 @@ fun fn(x:Any?, y: Any?) { fun fn0(o: Any?) { if (o != null) { - o?.toString() - o.toString() // $ Alert + o?.toString() // $ Alert + o.toString() } } From 1ac079d06674ac797eb62d0097bf9045bc4365b6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 12 Jun 2026 03:03:31 +0000 Subject: [PATCH 16/23] Bump golang.org/x/tools Bumps the extractor-dependencies group in /go/extractor with 1 update: [golang.org/x/tools](https://github.com/golang/tools). Updates `golang.org/x/tools` from 0.45.0 to 0.46.0 - [Release notes](https://github.com/golang/tools/releases) - [Commits](https://github.com/golang/tools/compare/v0.45.0...v0.46.0) --- updated-dependencies: - dependency-name: golang.org/x/tools dependency-version: 0.46.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: extractor-dependencies ... Signed-off-by: dependabot[bot] --- go/extractor/go.mod | 4 ++-- go/extractor/go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go/extractor/go.mod b/go/extractor/go.mod index 04abf5cdbe5..5de56683a3e 100644 --- a/go/extractor/go.mod +++ b/go/extractor/go.mod @@ -10,7 +10,7 @@ toolchain go1.26.4 // bazel mod tidy require ( golang.org/x/mod v0.37.0 - golang.org/x/tools v0.45.0 + golang.org/x/tools v0.46.0 ) require github.com/stretchr/testify v1.11.1 @@ -18,6 +18,6 @@ require github.com/stretchr/testify v1.11.1 require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/sync v0.20.0 // indirect + golang.org/x/sync v0.21.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go/extractor/go.sum b/go/extractor/go.sum index 86c3e7b5f11..55bcadfe98a 100644 --- a/go/extractor/go.sum +++ b/go/extractor/go.sum @@ -8,10 +8,10 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= golang.org/x/mod v0.37.0 h1:vF1DjpVEshcIqoEaauuHebaLk1O1forxjxBaVn884JQ= golang.org/x/mod v0.37.0/go.mod h1:m8S8VeM9r4dzDwjrKO0a1sZP3YjeMamRRlD+fmR2Q/0= -golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4= -golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= -golang.org/x/tools v0.45.0 h1:18qN3FAooORvApf5XjCXgsuayZOEtXf6JK18I3+ONa8= -golang.org/x/tools v0.45.0/go.mod h1:LuUGqqaXcXMEFEruIVJVm5mgDD8vww/z/SR1gQ4uE/0= +golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM= +golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +golang.org/x/tools v0.46.0 h1:7jTurBkPZu4moS/Uy4OQT1M+QBlsj3wejyZwsT8Z7rk= +golang.org/x/tools v0.46.0/go.mod h1:FrD85F8l+NWL+9XWBSyVSHO6Ne4jutsfIFba7AWQ5Ys= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= From 9078b511c678a5b6db9135b3c2d6563c4faa5038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Loba=C4=8Devski?= Date: Fri, 12 Jun 2026 09:37:18 +0300 Subject: [PATCH 17/23] Update regex for GitHub hosted runner matching Fixes false positives (of critical severity). New label naming conventions were introduced since the query was initially written. --- actions/ql/lib/codeql/actions/security/SelfHostedQuery.qll | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/ql/lib/codeql/actions/security/SelfHostedQuery.qll b/actions/ql/lib/codeql/actions/security/SelfHostedQuery.qll index 14d36ef0fa8..bb4437d803e 100644 --- a/actions/ql/lib/codeql/actions/security/SelfHostedQuery.qll +++ b/actions/ql/lib/codeql/actions/security/SelfHostedQuery.qll @@ -5,7 +5,7 @@ predicate isGithubHostedRunner(string runner) { // list of github hosted repos: https://github.com/actions/runner-images/blob/main/README.md#available-images runner .toLowerCase() - .regexpMatch("^(ubuntu-([0-9.]+|latest)|macos-([0-9]+|latest)(-x?large)?|windows-([0-9.]+|latest))$") + .regexpMatch("^(ubuntu-([0-9.]+|latest)(-arm)?|macos-([0-9]+|latest)(-x?large|-intel)?|windows-([0-9.]+|latest)(-arm|-vs[0-9.]+)?)$") } bindingset[runner] From eedef515f7c23b4edf73a0e9f58772d93429db31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Loba=C4=8Devski?= Date: Fri, 12 Jun 2026 07:50:02 +0000 Subject: [PATCH 18/23] Updated regex. Added test and change note. --- actions/ql/lib/change-notes/2026-06-12.md | 4 ++ .../actions/security/SelfHostedQuery.qll | 10 +++-- .../CWE-284/.github/workflows/test3.yml | 43 +++++++++++++++++++ 3 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 actions/ql/lib/change-notes/2026-06-12.md create mode 100644 actions/ql/test/query-tests/Security/CWE-284/.github/workflows/test3.yml diff --git a/actions/ql/lib/change-notes/2026-06-12.md b/actions/ql/lib/change-notes/2026-06-12.md new file mode 100644 index 00000000000..8fbf902b6ee --- /dev/null +++ b/actions/ql/lib/change-notes/2026-06-12.md @@ -0,0 +1,4 @@ +--- +category: fix +--- +* The query `actions/pr-on-self-hosted-runner` was updated to the latest standard runner labels reducing false positive results. \ No newline at end of file diff --git a/actions/ql/lib/codeql/actions/security/SelfHostedQuery.qll b/actions/ql/lib/codeql/actions/security/SelfHostedQuery.qll index bb4437d803e..3a65771c174 100644 --- a/actions/ql/lib/codeql/actions/security/SelfHostedQuery.qll +++ b/actions/ql/lib/codeql/actions/security/SelfHostedQuery.qll @@ -2,10 +2,12 @@ import actions bindingset[runner] predicate isGithubHostedRunner(string runner) { - // list of github hosted repos: https://github.com/actions/runner-images/blob/main/README.md#available-images - runner - .toLowerCase() - .regexpMatch("^(ubuntu-([0-9.]+|latest)(-arm)?|macos-([0-9]+|latest)(-x?large|-intel)?|windows-([0-9.]+|latest)(-arm|-vs[0-9.]+)?)$") + // The list of github hosted repos: + // https://github.com/actions/runner-images/blob/main/README.md#available-images + // https://docs.github.com/en/enterprise-cloud@latest/actions/how-tos/write-workflows/choose-where-workflows-run/choose-the-runner-for-a-job#standard-github-hosted-runners-for-public-repositories + runner.toLowerCase().regexpMatch("^ubuntu-([0-9.]+|latest|slim)(-arm)?$") or + runner.toLowerCase().regexpMatch("^macos-([0-9]+|latest)(-x?large|-intel)?$") or + runner.toLowerCase().regexpMatch("^windows-([0-9.]+|latest)(-vs[0-9.]+)?(-arm)?$") } bindingset[runner] diff --git a/actions/ql/test/query-tests/Security/CWE-284/.github/workflows/test3.yml b/actions/ql/test/query-tests/Security/CWE-284/.github/workflows/test3.yml new file mode 100644 index 00000000000..b1fe9fa0caa --- /dev/null +++ b/actions/ql/test/query-tests/Security/CWE-284/.github/workflows/test3.yml @@ -0,0 +1,43 @@ +name: test + +on: + pull_request: + +jobs: + test: + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - ubuntu-24.04 + - ubuntu-24.04-arm + - ubuntu-22.04 + - ubuntu-22.04-arm + - ubuntu-26.04 + - ubuntu-26.04-arm + - ubuntu-slim + - macos-26 + - macos-26-xlarge + - macos-26-intel + - macos-26-large + - macos-latest-large + - macos-15-large + - macos-15 + - macos-15-intel + - macos-latest + - macos-15 + - macos-15-xlarge + - macos-14-large + - macos-14 + - macos-14-xlarge + - windows-2025-vs2026 + - windows-latest + - windows-2025 + - windows-2022 + - windows-11 + - windows-11-arm + - windows-11-vs2026-arm + runs-on: ${{ matrix.os }} + steps: + - run: cmd From bea55224731601a3b6ab8679c5c4045fbc47eed0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Loba=C4=8Devski?= Date: Fri, 12 Jun 2026 07:52:34 +0000 Subject: [PATCH 19/23] rename change note --- .../{2026-06-12.md => 2026-06-12-self_hosted_runners.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename actions/ql/lib/change-notes/{2026-06-12.md => 2026-06-12-self_hosted_runners.md} (100%) diff --git a/actions/ql/lib/change-notes/2026-06-12.md b/actions/ql/lib/change-notes/2026-06-12-self_hosted_runners.md similarity index 100% rename from actions/ql/lib/change-notes/2026-06-12.md rename to actions/ql/lib/change-notes/2026-06-12-self_hosted_runners.md From f3ec7087e3e83b2849f6a2b2a8d3cac61e87f559 Mon Sep 17 00:00:00 2001 From: Anders Schack-Mulligen Date: Fri, 12 Jun 2026 10:02:48 +0200 Subject: [PATCH 20/23] Cfg: Fix type. --- .../code/csharp/controlflow/internal/ControlFlowGraph.qll | 2 +- java/ql/lib/semmle/code/java/ControlFlowGraph.qll | 2 +- shared/controlflow/codeql/controlflow/ControlFlowGraph.qll | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll b/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll index 0d8ced82e24..7e87fa32568 100644 --- a/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll +++ b/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll @@ -203,7 +203,7 @@ module Ast implements AstSig { final private class FinalTryStmt = CS::TryStmt; class TryStmt extends FinalTryStmt { - Stmt getBody(int index) { index = 0 and result = this.getBlock() } + AstNode getBody(int index) { index = 0 and result = this.getBlock() } CatchClause getCatch(int index) { result = this.getCatchClause(index) } diff --git a/java/ql/lib/semmle/code/java/ControlFlowGraph.qll b/java/ql/lib/semmle/code/java/ControlFlowGraph.qll index ec1ce80a9b8..d2d13a79d35 100644 --- a/java/ql/lib/semmle/code/java/ControlFlowGraph.qll +++ b/java/ql/lib/semmle/code/java/ControlFlowGraph.qll @@ -117,7 +117,7 @@ private module Ast implements AstSig { final private class FinalTryStmt = J::TryStmt; class TryStmt extends FinalTryStmt { - Stmt getBody(int index) { + AstNode getBody(int index) { result = super.getResource(index) or index = count(super.getAResource()) and diff --git a/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll b/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll index 4e6fd7ac2d4..2d71048d43c 100644 --- a/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll +++ b/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll @@ -190,7 +190,7 @@ signature module AstSig { * position `index`. In some languages, there is only ever a single body * (with `index` 0). */ - Stmt getBody(int index); + AstNode getBody(int index); /** * Gets the `catch` clause at the specified (zero-based) position `index` From eea406f62228aa7271248e5b46a5c9da046c5609 Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Fri, 12 Jun 2026 10:33:37 +0200 Subject: [PATCH 21/23] Remove @RasmusWL from CODEOWNERS He hasn't worked on CodeQL for a few years now. He told me that he doesn't remember how these scripts work. --- CODEOWNERS | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CODEOWNERS b/CODEOWNERS index 131fb1e767d..503410725a7 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -59,9 +59,5 @@ MODULE.bazel @github/codeql-ci-reviewers /.github/workflows/rust.yml @github/codeql-rust /.github/workflows/swift.yml @github/codeql-swift -# Misc -/misc/scripts/accept-expected-changes-from-ci.py @RasmusWL -/misc/scripts/generate-code-scanning-query-list.py @RasmusWL - # .devcontainer /.devcontainer/ @github/codeql-ci-reviewers From fe8c029ac7241dd585d5d1c91518edf877a24018 Mon Sep 17 00:00:00 2001 From: Anders Schack-Mulligen Date: Fri, 12 Jun 2026 13:50:41 +0200 Subject: [PATCH 22/23] Cfg: Add support for unless-statements. --- shared/controlflow/codeql/controlflow/ControlFlowGraph.qll | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll b/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll index 81b1d1a2e00..8f71cc2af38 100644 --- a/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll +++ b/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll @@ -1513,7 +1513,12 @@ module Make0 Ast> { n2.isBefore(ifstmt.getCondition()) or n1.isAfterTrue(ifstmt.getCondition()) and - n2.isBefore(ifstmt.getThen()) + ( + n2.isBefore(ifstmt.getThen()) + or + not exists(ifstmt.getThen()) and + n2.isAfter(ifstmt) + ) or n1.isAfterFalse(ifstmt.getCondition()) and ( From ff61344afa2d7fff0a11f297bf269e4e00c8512d Mon Sep 17 00:00:00 2001 From: Anders Schack-Mulligen Date: Fri, 12 Jun 2026 13:55:05 +0200 Subject: [PATCH 23/23] Cfg: Add support for until-statements. --- .../controlflow/internal/ControlFlowGraph.qll | 4 +++ .../lib/semmle/code/java/ControlFlowGraph.qll | 4 +++ .../codeql/controlflow/ControlFlowGraph.qll | 25 +++++++++++++------ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll b/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll index 7e87fa32568..18a967eee28 100644 --- a/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll +++ b/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll @@ -172,6 +172,10 @@ module Ast implements AstSig { class DoStmt = CS::DoStmt; + class UntilStmt extends LoopStmt { + UntilStmt() { none() } + } + final private class FinalForStmt = CS::ForStmt; class ForStmt extends FinalForStmt { diff --git a/java/ql/lib/semmle/code/java/ControlFlowGraph.qll b/java/ql/lib/semmle/code/java/ControlFlowGraph.qll index d2d13a79d35..51f3046e1bf 100644 --- a/java/ql/lib/semmle/code/java/ControlFlowGraph.qll +++ b/java/ql/lib/semmle/code/java/ControlFlowGraph.qll @@ -84,6 +84,10 @@ private module Ast implements AstSig { class DoStmt = J::DoStmt; + class UntilStmt extends LoopStmt { + UntilStmt() { none() } + } + final private class FinalForStmt = J::ForStmt; class ForStmt extends FinalForStmt { diff --git a/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll b/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll index 8f71cc2af38..522a416c768 100644 --- a/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll +++ b/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll @@ -119,6 +119,12 @@ signature module AstSig { Expr getCondition(); } + /** An `until` loop statement. */ + class UntilStmt extends LoopStmt { + /** Gets the boolean condition of this `until` loop. */ + Expr getCondition(); + } + /** A traditional C-style `for` loop. */ class ForStmt extends LoopStmt { /** Gets the initializer of the loop at the specified (zero-based) position, if any. */ @@ -608,6 +614,7 @@ module Make0 Ast> { any(IfStmt ifstmt).getCondition() = n or any(WhileStmt whilestmt).getCondition() = n or any(DoStmt dostmt).getCondition() = n or + any(UntilStmt untilstmt).getCondition() = n or any(ForStmt forstmt).getCondition() = n or any(ConditionalExpr condexpr).getCondition() = n or any(CatchClause catch).getCondition() = n or @@ -1535,9 +1542,9 @@ module Make0 Ast> { n2.isAfter(ifstmt) ) or - exists(WhileStmt whilestmt | - n1.isBefore(whilestmt) and - n2.isAdditional(whilestmt, loopHeaderTag()) + exists(LoopStmt loopstmt | loopstmt instanceof WhileStmt or loopstmt instanceof UntilStmt | + n1.isBefore(loopstmt) and + n2.isAdditional(loopstmt, loopHeaderTag()) ) or exists(DoStmt dostmt | @@ -1545,16 +1552,20 @@ module Make0 Ast> { n2.isBefore(dostmt.getBody()) ) or - exists(LoopStmt loopstmt, AstNode cond | - loopstmt.(WhileStmt).getCondition() = cond or loopstmt.(DoStmt).getCondition() = cond + exists(LoopStmt loopstmt, AstNode cond, boolean while | + loopstmt.(WhileStmt).getCondition() = cond and while = true + or + loopstmt.(DoStmt).getCondition() = cond and while = true + or + loopstmt.(UntilStmt).getCondition() = cond and while = false | n1.isAdditional(loopstmt, loopHeaderTag()) and n2.isBefore(cond) or - n1.isAfterTrue(cond) and + n1.isAfterValue(cond, any(BooleanSuccessor b | b.getValue() = while)) and n2.isBefore(loopstmt.getBody()) or - n1.isAfterFalse(cond) and + n1.isAfterValue(cond, any(BooleanSuccessor b | b.getValue() = while.booleanNot())) and n2.isAfter(loopstmt) or n1.isAfter(loopstmt.getBody()) and