-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Rust: Don't apply generated models for functions that have a manual model #21036
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rust: Don't apply generated models for functions that have a manual model #21036
Conversation
8b8898e to
c07d98f
Compare
c07d98f to
477e1cd
Compare
There was a problem hiding this 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 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 <[email protected]>
|
Thanks for the review. Merging as DCA is uneventful. |
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.