From 24f39ccae2e503100c7f8809e31287ceae4e7f7d Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Thu, 26 Sep 2024 11:09:31 +0200 Subject: [PATCH] Rust: Weaken `scopeNoFirst` check --- rust/ql/consistency-queries/CfgConsistency.ql | 10 +++++++++- rust/ql/test/library-tests/controlflow/Cfg.ql | 4 ---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/rust/ql/consistency-queries/CfgConsistency.ql b/rust/ql/consistency-queries/CfgConsistency.ql index 6bcf8d88201..ef7f9b6f255 100644 --- a/rust/ql/consistency-queries/CfgConsistency.ql +++ b/rust/ql/consistency-queries/CfgConsistency.ql @@ -1,5 +1,7 @@ import rust -import codeql.rust.controlflow.internal.ControlFlowGraphImpl::Consistency +import codeql.rust.controlflow.internal.ControlFlowGraphImpl::Consistency as Consistency +import Consistency +import codeql.rust.controlflow.ControlFlowGraph import codeql.rust.controlflow.internal.ControlFlowGraphImpl as CfgImpl import codeql.rust.controlflow.internal.Completion @@ -17,3 +19,9 @@ query predicate nonPostOrderExpr(Expr e, string cls) { c instanceof NormalCompletion ) } + +query predicate scopeNoFirst(CfgScope scope) { + Consistency::scopeNoFirst(scope) and + not scope = any(Function f | not exists(f.getBody())) and + not scope = any(ClosureExpr c | not exists(c.getBody())) +} diff --git a/rust/ql/test/library-tests/controlflow/Cfg.ql b/rust/ql/test/library-tests/controlflow/Cfg.ql index dbafdaa6caa..23b047b5b2e 100644 --- a/rust/ql/test/library-tests/controlflow/Cfg.ql +++ b/rust/ql/test/library-tests/controlflow/Cfg.ql @@ -1,7 +1,3 @@ -/** - * @id rust/controlflow/cfg - */ - import rust import codeql.rust.controlflow.ControlFlowGraph import TestUtils