From 0b81d44ec71f1bc1de9d8f01fdddf36762786f2d Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Fri, 12 Dec 2025 09:55:23 +0100 Subject: [PATCH] Rust: Apply same filtering of generated summaries as in C# and Java --- .../code/java/dataflow/internal/DataFlowDispatch.qll | 2 +- .../lib/codeql/rust/dataflow/internal/DataFlowImpl.qll | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/java/ql/lib/semmle/code/java/dataflow/internal/DataFlowDispatch.qll b/java/ql/lib/semmle/code/java/dataflow/internal/DataFlowDispatch.qll index dc58529ed26..a27f14cede0 100644 --- a/java/ql/lib/semmle/code/java/dataflow/internal/DataFlowDispatch.qll +++ b/java/ql/lib/semmle/code/java/dataflow/internal/DataFlowDispatch.qll @@ -60,7 +60,7 @@ private module DispatchImpl { not ( // Only use summarized callables with generated summaries in case // the static call target is not in the source code. - // Note that if applyGeneratedModel holds it implies that there doesn't + // Note that if `applyGeneratedModel` holds it implies that there doesn't // exist a manual model. exists(Callable staticTarget | staticTarget = call.getCallee().getSourceDeclaration() | staticTarget.fromSource() and not staticTarget.isStub() diff --git a/rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll b/rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll index 393095e80d9..fc84c8f0bc6 100644 --- a/rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll +++ b/rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll @@ -445,7 +445,15 @@ module RustDataFlow implements InputSig { or exists(SummarizedCallable sc, Function staticTarget | staticTarget = getStaticTargetExt(c) and - sc = result.asSummarizedCallable() + sc = result.asSummarizedCallable() and + // Only use summarized callables with generated summaries in case + // the static call target is not in the source code. + // Note that if `applyGeneratedModel` holds it implies that there doesn't + // exist a manual model. + not ( + staticTarget.fromSource() and + sc.applyGeneratedModel() + ) | sc = staticTarget or