From 7dda951a51449f41973c768815d30c1b2a7aba58 Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Mon, 24 Mar 2025 16:20:51 +0100 Subject: [PATCH] Ql4Ql: Exclude files named PrintAst.qlref and qlref files that uses a query with a PrintAst name from QlRefInlineExpectations. --- ql/ql/src/codeql_ql/ast/Yaml.qll | 11 +++++++++++ ql/ql/src/queries/style/QlRefInlineExpectations.ql | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ql/ql/src/codeql_ql/ast/Yaml.qll b/ql/ql/src/codeql_ql/ast/Yaml.qll index 142820226a4..d5e80365ff4 100644 --- a/ql/ql/src/codeql_ql/ast/Yaml.qll +++ b/ql/ql/src/codeql_ql/ast/Yaml.qll @@ -64,4 +64,15 @@ class QlRefDocument extends YamlDocument { value = n.lookup("postprocess").(YamlSequence).getElement(_) ) } + + predicate isPrintAst() { + this.getFile().getStem() = "PrintAst" + or + exists(YamlMapping n, YamlScalar value | + n.getDocument() = this and + value.getValue().matches("%PrintAst%") + | + value = n.lookup("query") + ) + } } diff --git a/ql/ql/src/queries/style/QlRefInlineExpectations.ql b/ql/ql/src/queries/style/QlRefInlineExpectations.ql index 870dd0f437c..66c139f683f 100644 --- a/ql/ql/src/queries/style/QlRefInlineExpectations.ql +++ b/ql/ql/src/queries/style/QlRefInlineExpectations.ql @@ -11,5 +11,7 @@ import ql import codeql_ql.ast.Yaml from QlRefDocument f -where not f.usesInlineExpectations() +where + not f.usesInlineExpectations() and + not f.isPrintAst() select f, "Query test does not use inline test expectations."