Rust: Add reverse post-update flow steps#19106
Conversation
71f86d2 to
18e55b8
Compare
There was a problem hiding this comment.
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.
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 |
paldepind
left a comment
There was a problem hiding this comment.
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.
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 ato allow for side effects on the receiver to be reach&mut a.