-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rust: Add reverse post-update flow steps #19106
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
71f86d2
to
18e55b8
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 PR introduces reverse post-update flow steps to handle side effects on receivers in post-update nodes.
- Introduces a new struct MyStruct with set_data and get_data methods.
- Adds two test functions (data_out_of_call_side_effect1 and data_out_of_call_side_effect2) to verify the reverse flow steps.
- Updates main() to invoke the new test functions.
Files not reviewed (9)
- rust/ql/lib/codeql/rust/dataflow/internal/DataFlowConsistency.qll: Language not supported
- rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll: Language not supported
- rust/ql/lib/codeql/rust/dataflow/internal/Node.qll: Language not supported
- rust/ql/lib/codeql/rust/dataflow/internal/SsaImpl.qll: Language not supported
- rust/ql/lib/codeql/rust/dataflow/internal/TaintTrackingImpl.qll: Language not supported
- rust/ql/test/library-tests/dataflow/global/inline-flow.expected: Language not supported
- rust/ql/test/library-tests/dataflow/global/viableCallable.expected: Language not supported
- rust/ql/test/library-tests/dataflow/local/DataFlowStep.expected: Language not supported
- rust/ql/test/library-tests/dataflow/taint/TaintFlowStep.expected: Language not supported
Tip: Copilot only keeps its highest confidence comments to reduce noise and keep you focused. Learn more
|
||
impl MyStruct { | ||
fn set_data(&mut self, n: i64) { | ||
(*self).data = n // todo: implicit deref not yet supported |
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.
The assignment statement is missing a semicolon, which could cause a compile error. Please add a semicolon at the end of the assignment.
(*self).data = n // todo: implicit deref not yet supported | |
(*self).data = n; // todo: implicit deref not yet supported |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
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.
Nice!
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.
Oops, I hit the wrong button. Looks great, but I've also left two comments :)
* | ||
* we add a reverse flow step from `[post] { foo(); &mut a}` to `[post] &mut a`, | ||
* in order for the side-effect of `set_data` to reach `&mut a`. | ||
*/ |
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.
Thanks, this comment really helps add context 🤩
28c1c9b
to
f45eca7
Compare
Rebased to resolve merge conflict. |
* we add a reverse flow step from `[post] { foo(); &mut a}` to `[post] &mut a`, | ||
* in order for the side-effect of `set_data` to reach `&mut a`. | ||
*/ | ||
ExprCfgNode getPostUpdateReverseStep(ExprCfgNode e, boolean preservesValue) { |
Check warning
Code scanning / CodeQL
Missing QLDoc for parameter Warning
Adds (restricted) reverse flow steps for post-update nodes. For example, in a call like
we add a flow step from
[post] { 42; &mut a}
to[post] &mut a
to allow for side effects on the receiver to be reach&mut a
.