Skip to content

Conversation

@hvitved
Copy link
Contributor

@hvitved hvitved commented Dec 12, 2025

I noticed on https://github.com/github/codeql/pull/20879/changes#diff-2dc9c76255b29ca51e9fe9d8861fe51534f0d72c032a32dbb2f554cbb7ffdf55 that we got some duplicate flow paths, which happens because std::fs::read has both a manual model and an auto-generated model. The fix is to always prioritize manual source/sink models over generated models, just like we do for flow summaries.

This PR also filters away generated flow summaries when there is a static target in source code for Rust, similar to C# and Java.

@github-actions github-actions bot added Java Rust Pull requests that update Rust code DataFlow Library labels Dec 12, 2025
@hvitved hvitved force-pushed the shared/source-sink-provenance-prio branch from 4d27a73 to e393034 Compare December 12, 2025 09:37
@hvitved hvitved force-pushed the shared/source-sink-provenance-prio branch from e393034 to 0b00589 Compare December 12, 2025 10:16
@hvitved hvitved added the no-change-note-required This PR does not need a change note label Dec 12, 2025
@hvitved hvitved marked this pull request as ready for review December 12, 2025 10:40
@hvitved hvitved requested a review from a team as a code owner December 12, 2025 10:40
Copilot AI review requested due to automatic review settings December 12, 2025 10:40
@hvitved hvitved requested review from a team as code owners December 12, 2025 10:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses duplicate flow paths in dataflow analysis by prioritizing manual source/sink models over auto-generated models, and filtering away generated flow summaries when a static call target exists in source code for Rust.

Key Changes:

  • Introduced filtering logic to prefer manual models over generated models for sources and sinks
  • Added similar filtering for Rust flow summaries to match existing C# and Java behavior
  • Corrected a minor comment formatting issue in Java

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll Added isRelevantSource and isRelevantSink predicates to filter generated models when manual models exist for the same kind
rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll Added logic to exclude generated flow summaries when static call target is in source code, aligning with Java/C# behavior
java/ql/lib/semmle/code/java/dataflow/internal/DataFlowDispatch.qll Added backticks around applyGeneratedModel in comment for consistency
rust/ql/test/query-tests/security/CWE-825/AccessInvalidPointer.expected Removed duplicate flow path results as expected
rust/ql/test/query-tests/security/CWE-312/CleartextLogging.expected Removed duplicate flow path results and renumbered model references
rust/ql/test/library-tests/dataflow/sources/file/TaintSources.expected Removed duplicate source detections
rust/ql/test/library-tests/dataflow/sources/file/InlineFlow.expected Removed duplicate flow edges and model references, renumbered remaining ones

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@paldepind paldepind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Nice to get this right.

@hvitved hvitved merged commit b61a439 into github:main Dec 12, 2025
55 checks passed
@hvitved hvitved deleted the shared/source-sink-provenance-prio branch December 12, 2025 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DataFlow Library Java no-change-note-required This PR does not need a change note Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants