Rust: Don't apply generated models for functions that have a manual model#21036
Merged
paldepind merged 4 commits intogithub:mainfrom Dec 16, 2025
Merged
Conversation
8b8898e to
c07d98f
Compare
c07d98f to
477e1cd
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request enhances the Rust dataflow model system to prevent generated models from being applied when manual models exist for the same function. This ensures that manual models, which are typically more precise, take precedence over automatically generated ones.
Key changes:
- Implements logic to filter out generated models when manual models exist for a function
- Fixes an incorrect manual model for
PathBuf::as_path - Promotes a
Pin::newmodel to manual status to preserve test results
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
rust/ql/lib/codeql/rust/dataflow/internal/ModelsAsData.qll |
Adds hasManualModel() predicate and updates propagatesFlow() to exclude generated models when manual models exist |
rust/ql/lib/codeql/rust/frameworks/stdlib/fs.model.yml |
Fixes the as_path model specification from Argument[Self] to Argument[self].Reference |
rust/ql/lib/codeql/rust/frameworks/stdlib/core.model.yml |
Adds a new manual model for Pin::new to handle implicit dereference cases |
rust/ql/test/library-tests/dataflow/models/models.ext.yml |
Adds test models for the snd function to verify the fix works correctly |
rust/ql/test/library-tests/dataflow/models/main.rs |
Adds test case for snd function demonstrating that wrong generated model is ignored |
rust/ql/test/library-tests/dataflow/models/models.expected |
Updates expected test output to reflect the new behavior |
rust/ql/test/library-tests/dataflow/sources/file/InlineFlow.expected |
Updates expected output to reflect the corrected as_path model |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
hvitved
approved these changes
Dec 16, 2025
Contributor
Author
|
Thanks for the review. Merging as DCA is uneventful. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Also
as_pathwhich was previously covered up by another wrong generated model 😅Pin::newto a manual model. The model is not precise, but not having it caused a bunch of test failures (here for instance) so it's probably best to keep it until we can get those results the precise way.