Ruby: Weaken scopeNoFirst check

This commit is contained in:
Tom Hvitved
2024-09-25 16:43:33 +02:00
parent 1bd504bf61
commit a3ad6f5697

View File

@@ -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())
)
}