diff --git a/ql/ql/src/codeql_ql/ast/internal/Module.qll b/ql/ql/src/codeql_ql/ast/internal/Module.qll index 50416337bf4..12a377aa974 100644 --- a/ql/ql/src/codeql_ql/ast/internal/Module.qll +++ b/ql/ql/src/codeql_ql/ast/internal/Module.qll @@ -311,4 +311,8 @@ module ModConsistency { c > 1 and resolveModuleExpr(me, m) } + + query predicate noName(Module mod) { not exists(mod.getName()) } + + query predicate nonUniqueName(Module mod) { count(mod.getName()) >= 2 } } diff --git a/ql/ql/src/queries/diagnostics/EmptyConsistencies.ql b/ql/ql/src/queries/diagnostics/EmptyConsistencies.ql index c90b0618d9c..e592f7b0830 100644 --- a/ql/ql/src/queries/diagnostics/EmptyConsistencies.ql +++ b/ql/ql/src/queries/diagnostics/EmptyConsistencies.ql @@ -31,7 +31,7 @@ where TypeConsistency::multiplePrimitivesExpr(node, _, _) and msg = "TypeConsistency::multiplePrimitivesExpr" or - AstConsistency::nonTotalGetParent(node) and msg = "AstConsistency::nonTotalGetParent" + AstConsistency::nonTotalGetParent(node) and msg = "AstConsistency::nonTotalGetParent" // TODO: unique parent or TypeConsistency::noResolve(node) and msg = "TypeConsistency::noResolve" or @@ -39,15 +39,12 @@ where or ModConsistency::noResolveModuleExpr(node) and msg = "ModConsistency::noResolveModuleExpr" or + ModConsistency::noName(node) and msg = "ModConsistency::noName" + or + ModConsistency::nonUniqueName(node) and msg = "ModConsistency::nonUniqueName" + or VarConsistency::noFieldDef(node) and msg = "VarConsistency::noFieldDef" or VarConsistency::noVarDef(node) and msg = "VarConsistency::noVarDef" - or - node instanceof ModuleExpr and - not exists(node.(ModuleExpr).getName()) and - msg = "exists(ModuleExpr::getName)" - or - node instanceof ModuleExpr and - count(node.(ModuleExpr).getName()) >= 2 and - msg = "unique(ModuleExpr::getName)" select node, msg +// TODO: vardef consistency.