From d0aa219652dff01351529a93154917cf5ff4e961 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Fri, 15 Oct 2021 19:46:51 +0200 Subject: [PATCH] add an consistency test for the totality of `getParent()` --- ql/consistency-queries/AstConsistency.ql | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 ql/consistency-queries/AstConsistency.ql diff --git a/ql/consistency-queries/AstConsistency.ql b/ql/consistency-queries/AstConsistency.ql new file mode 100644 index 00000000000..773b6c8b898 --- /dev/null +++ b/ql/consistency-queries/AstConsistency.ql @@ -0,0 +1,10 @@ +import ql +private import codeql_ql.ast.internal.AstNodes as AstNodes + +query AstNode nonTotalGetParent() { + exists(AstNodes::toQL(result).getParent()) and + not exists(result.getParent()) and + not result.getLocation().getStartColumn() = 1 and // startcolumn = 1 <=> top level in file <=> fine to have no parent + not result instanceof YAML::YAMLNode and // parents for YAML doens't work + not (result instanceof QLDoc and result.getLocation().getFile().getExtension() = "dbscheme") // qldoc in dbschemes are not hooked up +}