mirror of
https://github.com/github/codeql.git
synced 2026-02-08 03:01:10 +01:00
add nonTotalGetParent to the list of empty consistency queries
This commit is contained in:
@@ -1,10 +1 @@
|
||||
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
|
||||
}
|
||||
private import codeql_ql.ast.internal.AstNodes::AstConsistency
|
||||
|
||||
@@ -209,3 +209,16 @@ class TTypeDeclaration = TClass or TNewType or TNewTypeBranch;
|
||||
class TModuleDeclaration = TClasslessPredicate or TModule or TClass or TNewType;
|
||||
|
||||
class TVarDef = TVarDecl or TAsExpr;
|
||||
|
||||
module AstConsistency {
|
||||
import ql
|
||||
|
||||
query predicate nonTotalGetParent(AstNode node) {
|
||||
exists(toQL(node).getParent()) and
|
||||
not exists(node.getParent()) and
|
||||
not node.getLocation().getStartColumn() = 1 and // startcolumn = 1 <=> top level in file <=> fine to have no parent
|
||||
exists(node.toString()) and // <- there are a few parse errors in "global-data-flow-java-1.ql", this way we filter them out.
|
||||
not node instanceof YAML::YAMLNode and // parents for YAML doens't work
|
||||
not (node instanceof QLDoc and node.getLocation().getFile().getExtension() = "dbscheme") // qldoc in dbschemes are not hooked up
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import codeql_ql.ast.internal.Type::TyConsistency as TypeConsistency
|
||||
import codeql_ql.ast.internal.Builtins::BuildinsConsistency as BuildinsConsistency
|
||||
import codeql_ql.ast.internal.Module::ModConsistency as ModConsistency
|
||||
import codeql_ql.ast.internal.Variable::VarConsistency as VarConsistency
|
||||
import codeql_ql.ast.internal.AstNodes::AstConsistency as AstConsistency
|
||||
|
||||
from AstNode node, string msg
|
||||
where
|
||||
@@ -30,6 +31,8 @@ where
|
||||
TypeConsistency::multiplePrimitivesExpr(node, _, _) and
|
||||
msg = "TypeConsistency::multiplePrimitivesExpr"
|
||||
or
|
||||
AstConsistency::nonTotalGetParent(node) and msg = "AstConsistency::nonTotalGetParent"
|
||||
or
|
||||
//or // has 1 result, but the CodeQL compiler also can't figure out that one. I suppoed the file is never imported.
|
||||
//TypeConsistency::noResolve(node) and msg = "TypeConsistency::noResolve"
|
||||
//or // has 1 result, but the CodeQL compiler also can't figure out that one. Same file as above.
|
||||
|
||||
Reference in New Issue
Block a user