diff --git a/ruby/ql/consistency-queries/CfgConsistency.ql b/ruby/ql/consistency-queries/CfgConsistency.ql index a57cb03ebb2..c8d797b71f4 100644 --- a/ruby/ql/consistency-queries/CfgConsistency.ql +++ b/ruby/ql/consistency-queries/CfgConsistency.ql @@ -1,4 +1,5 @@ -import codeql.ruby.controlflow.internal.ControlFlowGraphImpl::Consistency +import codeql.ruby.controlflow.internal.ControlFlowGraphImpl::Consistency as Consistency +import Consistency import codeql.ruby.AST import codeql.ruby.CFG import codeql.ruby.controlflow.internal.Completion @@ -19,3 +20,14 @@ query predicate nonPostOrderExpr(Expr e, string cls) { c instanceof NormalCompletion ) } + +query predicate scopeNoFirst(CfgScope scope) { + Consistency::scopeNoFirst(scope) and + not scope = any(StmtSequence seq | not exists(seq.getAStmt())) and + not scope = + any(Callable c | + not exists(c.getAParameter()) and + not c.(BodyStmt).hasEnsure() and + not exists(c.(BodyStmt).getARescue()) + ) +}