From 45b84ffb3195f7b0069494624cd47e805c539872 Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Mon, 22 Sep 2025 14:23:50 +0200 Subject: [PATCH] Rust: Ensure singleton --- rust/ql/lib/codeql/rust/dataflow/internal/FlowSummaryImpl.qll | 4 ++-- shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/rust/ql/lib/codeql/rust/dataflow/internal/FlowSummaryImpl.qll b/rust/ql/lib/codeql/rust/dataflow/internal/FlowSummaryImpl.qll index 129bd468e01..2763908ae02 100644 --- a/rust/ql/lib/codeql/rust/dataflow/internal/FlowSummaryImpl.qll +++ b/rust/ql/lib/codeql/rust/dataflow/internal/FlowSummaryImpl.qll @@ -168,12 +168,12 @@ private module StepsInput implements Impl::Private::StepsInputSig { or exists(ArgumentPosition pos, Expr arg | s.head() = Impl::Private::SummaryComponent::parameter(pos) and - arg = getSourceNodeArgument(source, s.tail().head()) and + arg = getSourceNodeArgument(source, s.tail().headOfSingleton()) and result.asParameter() = getCallable(arg).getParam(pos.getPosition()) ) or result.(RustDataFlow::PostUpdateNode).getPreUpdateNode().asExpr().getExpr() = - getSourceNodeArgument(source, s.head()) + getSourceNodeArgument(source, s.headOfSingleton()) } RustDataFlow::Node getSinkNode(Input::SinkBase sink, Impl::Private::SummaryComponent sc) { diff --git a/shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll b/shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll index 9c46e04bf4b..6cc9d6f88a4 100644 --- a/shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll +++ b/shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll @@ -709,6 +709,9 @@ module Make< this = TConsSummaryComponentStack(result, _) } + /** Gets the head of this stack if it is a singleton. */ + SummaryComponent headOfSingleton() { this = TSingletonSummaryComponentStack(result) } + /** Gets the tail of this stack, if any. */ SummaryComponentStack tail() { this = TConsSummaryComponentStack(_, result) }