-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Rust: Handle writes to references and add encoding of reference content #18714
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
Conversation
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.
PR Overview
This PR adds and updates data flow tests in multiple Rust files to handle cases involving mutable references, updated annotations for reference-based flows in model generator files, and clarifications around reference handling in MyOption methods.
- Introduces new tests for functions that mutate arguments via references.
- Adds or refines data flow summaries in model generator to track references more accurately.
- Updates pointer-related data flow tests to confirm flow through borrowed references.
Changes
| File | Description |
|---|---|
| rust/ql/test/library-tests/dataflow/global/main.rs | Adds functions mutates_argument_1 and mutates_argument_2 to test data flow from source to sink via mutable references. |
| rust/ql/test/utils-tests/modelgenerator/summaries.rs | Adds reference-based data flow summaries set_int and read_int for improved data flow tracking. |
| rust/ql/test/utils-tests/modelgenerator/option.rs | Adjusts generated summaries to handle references in MyOption methods, clarifying argument and return flows. |
| rust/ql/test/library-tests/dataflow/pointers/main.rs | Enhances pointer tests to verify clearing data after flow, ensuring correct data flow through mutable borrows. |
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Tip: If you use Visual Studio Code, you can request a review from Copilot before you push from the "Source Control" tab. Learn more
| let mut n = 0; | ||
| sink(n); | ||
| set_int(&mut n, source(88)); | ||
| sink(n); // $ MISSING: hasValueFlow=88 |
Copilot
AI
Feb 7, 2025
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.
This comment indicates a missing data flow annotation for the value from source(88). Consider adding the correct annotation or removing the note to reflect the intended test behavior accurately.
| sink(n); // $ MISSING: hasValueFlow=88 | |
| sink(n); // $ hasValueFlow=88 |
geoffw0
left a comment
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.
Obviously there's more to be done in future, but this looks like a solid step forward.
I'd like to see a DCA run.
|
DCA is uneventful as far as I can see. |
No description provided.