Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion rust/ql/lib/codeql/rust/frameworks/stdlib/core.model.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ extensions:
- ["<& as core::ops::deref::Deref>::deref", "Argument[self].Reference", "ReturnValue", "value", "manual"]
- ["<&mut as core::ops::deref::Deref>::deref", "Argument[self].Reference", "ReturnValue", "value", "manual"]
- ["<core::ops::deref::Deref>::deref", "Argument[self].Reference", "ReturnValue.Reference", "taint", "manual"]
# for the pseudo implementation in `builtins/types.rs`
- ["<[;] as core::ops::deref::Deref>::deref", "Argument[self].Reference", "ReturnValue.Reference", "value", "manual"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might not work/be worth it, but could we have let the body of the pseudo implementation be &self and have gotten this for free?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not generate CFGs for functions not in source, so that will not work.

# Index
- ["<core::ops::index::Index>::index", "Argument[self].Reference.Element", "ReturnValue.Reference", "value", "manual"]
- ["<core::ops::index::IndexMut>::index_mut", "Argument[self].Reference.Element", "ReturnValue.Reference", "value", "manual"]
Expand Down Expand Up @@ -98,7 +100,6 @@ extensions:
- ["<core::iter::traits::iterator::Iterator>::next", "Argument[self].Reference.Element", "ReturnValue.Field[core::option::Option::Some(0)]", "value", "manual"]
- ["<core::iter::traits::iterator::Iterator>::collect", "Argument[self].Element", "ReturnValue.Element", "value", "manual"]
- ["<core::iter::traits::iterator::Iterator>::map", "Argument[self].Element", "Argument[0].Parameter[0]", "value", "manual"]
- ["<core::iter::traits::iterator::Iterator>::for_each", "Argument[self].Element", "Argument[0].Parameter[0]", "value", "manual"]
- ["<core::iter::traits::iterator::Iterator>::chain", "Argument[self]", "ReturnValue", "taint", "manual"]
- ["<core::iter::traits::iterator::Iterator>::chain", "Argument[0]", "ReturnValue", "taint", "manual"]
- ["<core::iter::traits::iterator::Iterator>::take", "Argument[self]", "ReturnValue", "taint", "manual"]
Expand Down Expand Up @@ -140,6 +141,8 @@ extensions:
- ["<core::cmp::Ord>::clamp", "Argument[self,0,1]", "ReturnValue", "value", "manual"]
# Slice
- ["<[]>::get", "Argument[self].Reference.Element", "ReturnValue.Field[core::option::Option::Some(0)].Reference", "value", "manual"]
- ["<[]>::iter", "Argument[self].Reference.Element", "ReturnValue.Element.Reference", "value", "manual"]
- ["<[]>::iter_mut", "Argument[self].Reference.Element", "ReturnValue.Element.Reference", "value", "manual"]
- addsTo:
pack: codeql/rust-all
extensible: sourceModel
Expand Down
54 changes: 54 additions & 0 deletions rust/ql/test/library-tests/dataflow/local/DataFlowStep.expected
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,7 @@ localStep
| main.rs:535:20:535:20 | x | main.rs:535:20:535:20 | x |
| main.rs:536:5:536:6 | [post] vs | main.rs:538:14:538:15 | vs |
| main.rs:536:5:536:6 | vs | main.rs:538:14:538:15 | vs |
| main.rs:536:24:536:35 | \|...\| ... | main.rs:536:24:536:35 | \|...\| ... |
| main.rs:536:25:536:25 | ... | main.rs:536:25:536:25 | x |
| main.rs:536:25:536:25 | [SSA] x | main.rs:536:34:536:34 | x |
| main.rs:536:25:536:25 | x | main.rs:536:25:536:25 | [SSA] x |
Expand Down Expand Up @@ -944,26 +945,57 @@ readStep
| main.rs:519:10:519:11 | [post] vs [implicit borrow] | file://:0:0:0:0 | &ref | main.rs:519:10:519:11 | [post] vs |
| main.rs:519:10:519:14 | vs[0] [pre-dereferenced] | file://:0:0:0:0 | &ref | main.rs:519:10:519:14 | vs[0] |
| main.rs:520:10:520:35 | * ... [pre-dereferenced] | file://:0:0:0:0 | &ref | main.rs:520:10:520:35 | * ... |
| main.rs:520:11:520:12 | [post] vs [implicit borrow] | file://:0:0:0:0 | &ref | main.rs:520:11:520:12 | [post] vs [implicit deref 0 in state after deref] |
| main.rs:520:11:520:12 | [post] vs [implicit deref 0 in state after borrow] | file://:0:0:0:0 | &ref | main.rs:520:11:520:12 | [post] vs |
| main.rs:520:11:520:12 | vs [implicit deref 0 in state before deref] | file://:0:0:0:0 | &ref | main.rs:520:11:520:12 | vs [implicit deref 0 in state after deref] |
| main.rs:520:11:520:19 | [post] vs.iter() [implicit borrow] | file://:0:0:0:0 | &ref | main.rs:520:11:520:19 | [post] vs.iter() |
| main.rs:520:11:520:35 | [post] ... .unwrap() [implicit borrow] | file://:0:0:0:0 | &ref | main.rs:520:11:520:35 | [post] ... .unwrap() |
| main.rs:521:10:521:35 | * ... [pre-dereferenced] | file://:0:0:0:0 | &ref | main.rs:521:10:521:35 | * ... |
| main.rs:521:11:521:12 | [post] vs [implicit borrow] | file://:0:0:0:0 | &ref | main.rs:521:11:521:12 | [post] vs [implicit deref 0 in state after deref] |
| main.rs:521:11:521:12 | [post] vs [implicit deref 0 in state after borrow] | file://:0:0:0:0 | &ref | main.rs:521:11:521:12 | [post] vs |
| main.rs:521:11:521:12 | vs [implicit deref 0 in state before deref] | file://:0:0:0:0 | &ref | main.rs:521:11:521:12 | vs [implicit deref 0 in state after deref] |
| main.rs:521:11:521:19 | [post] vs.iter() [implicit borrow] | file://:0:0:0:0 | &ref | main.rs:521:11:521:19 | [post] vs.iter() |
| main.rs:521:11:521:35 | [post] ... .unwrap() [implicit borrow] | file://:0:0:0:0 | &ref | main.rs:521:11:521:35 | [post] ... .unwrap() |
| main.rs:523:14:523:15 | vs | file://:0:0:0:0 | element | main.rs:523:9:523:9 | v |
| main.rs:526:9:526:10 | &... | file://:0:0:0:0 | &ref | main.rs:526:10:526:10 | v |
| main.rs:526:15:526:16 | [post] vs [implicit borrow] | file://:0:0:0:0 | &ref | main.rs:526:15:526:16 | [post] vs [implicit deref 0 in state after deref] |
| main.rs:526:15:526:16 | [post] vs [implicit deref 0 in state after borrow] | file://:0:0:0:0 | &ref | main.rs:526:15:526:16 | [post] vs |
| main.rs:526:15:526:16 | vs [implicit deref 0 in state before deref] | file://:0:0:0:0 | &ref | main.rs:526:15:526:16 | vs [implicit deref 0 in state after deref] |
| main.rs:526:15:526:23 | vs.iter() | file://:0:0:0:0 | element | main.rs:526:9:526:10 | &... |
| main.rs:530:26:530:27 | [post] vs [implicit borrow] | file://:0:0:0:0 | &ref | main.rs:530:26:530:27 | [post] vs [implicit deref 0 in state after deref] |
| main.rs:530:26:530:27 | [post] vs [implicit deref 0 in state after borrow] | file://:0:0:0:0 | &ref | main.rs:530:26:530:27 | [post] vs |
| main.rs:530:26:530:27 | vs [implicit deref 0 in state before deref] | file://:0:0:0:0 | &ref | main.rs:530:26:530:27 | vs [implicit deref 0 in state after deref] |
| main.rs:531:9:531:10 | &... | file://:0:0:0:0 | &ref | main.rs:531:10:531:10 | v |
| main.rs:531:15:531:17 | vs2 | file://:0:0:0:0 | element | main.rs:531:9:531:10 | &... |
| main.rs:535:5:535:6 | [post] vs [implicit borrow] | file://:0:0:0:0 | &ref | main.rs:535:5:535:6 | [post] vs [implicit deref 0 in state after deref] |
| main.rs:535:5:535:6 | [post] vs [implicit deref 0 in state after borrow] | file://:0:0:0:0 | &ref | main.rs:535:5:535:6 | [post] vs |
| main.rs:535:5:535:6 | vs [implicit deref 0 in state before deref] | file://:0:0:0:0 | &ref | main.rs:535:5:535:6 | vs [implicit deref 0 in state after deref] |
| main.rs:535:28:535:29 | * ... [pre-dereferenced] | file://:0:0:0:0 | &ref | main.rs:535:28:535:29 | * ... |
| main.rs:535:29:535:29 | [post] x [implicit borrow] | file://:0:0:0:0 | &ref | main.rs:535:29:535:29 | [post] x |
| main.rs:536:5:536:6 | [post] vs [implicit borrow] | file://:0:0:0:0 | &ref | main.rs:536:5:536:6 | [post] vs [implicit deref 0 in state after deref] |
| main.rs:536:5:536:6 | [post] vs [implicit deref 0 in state after borrow] | file://:0:0:0:0 | &ref | main.rs:536:5:536:6 | [post] vs |
| main.rs:536:5:536:6 | vs [implicit deref 0 in state before deref] | file://:0:0:0:0 | &ref | main.rs:536:5:536:6 | vs [implicit deref 0 in state after deref] |
| main.rs:536:33:536:34 | * ... [pre-dereferenced] | file://:0:0:0:0 | &ref | main.rs:536:33:536:34 | * ... |
| main.rs:536:34:536:34 | [post] x [implicit borrow] | file://:0:0:0:0 | &ref | main.rs:536:34:536:34 | [post] x |
| main.rs:538:14:538:27 | vs.into_iter() | file://:0:0:0:0 | element | main.rs:538:9:538:9 | v |
| main.rs:544:10:544:15 | [post] vs_mut [implicit borrow] | file://:0:0:0:0 | &ref | main.rs:544:10:544:15 | [post] vs_mut |
| main.rs:544:10:544:18 | vs_mut[0] [pre-dereferenced] | file://:0:0:0:0 | &ref | main.rs:544:10:544:18 | vs_mut[0] |
| main.rs:545:10:545:39 | * ... [pre-dereferenced] | file://:0:0:0:0 | &ref | main.rs:545:10:545:39 | * ... |
| main.rs:545:11:545:16 | [post] vs_mut [implicit borrow] | file://:0:0:0:0 | &ref | main.rs:545:11:545:16 | [post] vs_mut [implicit deref 0 in state after deref] |
| main.rs:545:11:545:16 | [post] vs_mut [implicit deref 0 in state after borrow] | file://:0:0:0:0 | &ref | main.rs:545:11:545:16 | [post] vs_mut |
| main.rs:545:11:545:16 | vs_mut [implicit deref 0 in state before deref] | file://:0:0:0:0 | &ref | main.rs:545:11:545:16 | vs_mut [implicit deref 0 in state after deref] |
| main.rs:545:11:545:23 | [post] vs_mut.iter() [implicit borrow] | file://:0:0:0:0 | &ref | main.rs:545:11:545:23 | [post] vs_mut.iter() |
| main.rs:545:11:545:39 | [post] ... .unwrap() [implicit borrow] | file://:0:0:0:0 | &ref | main.rs:545:11:545:39 | [post] ... .unwrap() |
| main.rs:546:10:546:39 | * ... [pre-dereferenced] | file://:0:0:0:0 | &ref | main.rs:546:10:546:39 | * ... |
| main.rs:546:11:546:16 | [post] vs_mut [implicit borrow] | file://:0:0:0:0 | &ref | main.rs:546:11:546:16 | [post] vs_mut [implicit deref 0 in state after deref] |
| main.rs:546:11:546:16 | [post] vs_mut [implicit deref 0 in state after borrow] | file://:0:0:0:0 | &ref | main.rs:546:11:546:16 | [post] vs_mut |
| main.rs:546:11:546:16 | vs_mut [implicit deref 0 in state before deref] | file://:0:0:0:0 | &ref | main.rs:546:11:546:16 | vs_mut [implicit deref 0 in state after deref] |
| main.rs:546:11:546:23 | [post] vs_mut.iter() [implicit borrow] | file://:0:0:0:0 | &ref | main.rs:546:11:546:23 | [post] vs_mut.iter() |
| main.rs:546:11:546:39 | [post] ... .unwrap() [implicit borrow] | file://:0:0:0:0 | &ref | main.rs:546:11:546:39 | [post] ... .unwrap() |
| main.rs:548:9:548:14 | &mut ... | file://:0:0:0:0 | &ref | main.rs:548:14:548:14 | v |
| main.rs:548:19:548:24 | [post] vs_mut [implicit borrow] | file://:0:0:0:0 | &ref | main.rs:548:19:548:24 | [post] vs_mut [implicit deref 0 in state after deref] |
| main.rs:548:19:548:24 | [post] vs_mut [implicit deref 0 in state after borrow] | file://:0:0:0:0 | &ref | main.rs:548:19:548:24 | [post] vs_mut |
| main.rs:548:19:548:24 | vs_mut [implicit deref 0 in state before deref] | file://:0:0:0:0 | &ref | main.rs:548:19:548:24 | vs_mut [implicit deref 0 in state after deref] |
| main.rs:548:19:548:35 | vs_mut.iter_mut() | file://:0:0:0:0 | element | main.rs:548:9:548:14 | &mut ... |
| main.rs:562:10:562:15 | * ... [pre-dereferenced] | file://:0:0:0:0 | &ref | main.rs:562:10:562:15 | * ... |
| main.rs:562:11:562:15 | [post] c_ref [implicit borrow] | file://:0:0:0:0 | &ref | main.rs:562:11:562:15 | [post] c_ref |
Expand Down Expand Up @@ -1069,17 +1101,39 @@ storeStep
| main.rs:517:30:517:30 | 3 | file://:0:0:0:0 | element | main.rs:517:14:517:34 | [...] |
| main.rs:517:33:517:33 | 4 | file://:0:0:0:0 | element | main.rs:517:14:517:34 | [...] |
| main.rs:519:10:519:11 | vs | file://:0:0:0:0 | &ref | main.rs:519:10:519:11 | vs [implicit borrow] |
| main.rs:520:11:520:12 | vs | file://:0:0:0:0 | &ref | main.rs:520:11:520:12 | vs [implicit deref 0 in state after borrow] |
| main.rs:520:11:520:12 | vs [implicit deref 0 in state after deref] | file://:0:0:0:0 | &ref | main.rs:520:11:520:12 | vs [implicit borrow] |
| main.rs:520:11:520:19 | vs.iter() | file://:0:0:0:0 | &ref | main.rs:520:11:520:19 | vs.iter() [implicit borrow] |
| main.rs:520:11:520:35 | ... .unwrap() | file://:0:0:0:0 | &ref | main.rs:520:11:520:35 | ... .unwrap() [implicit borrow] |
| main.rs:521:11:521:12 | vs | file://:0:0:0:0 | &ref | main.rs:521:11:521:12 | vs [implicit deref 0 in state after borrow] |
| main.rs:521:11:521:12 | vs [implicit deref 0 in state after deref] | file://:0:0:0:0 | &ref | main.rs:521:11:521:12 | vs [implicit borrow] |
| main.rs:521:11:521:19 | vs.iter() | file://:0:0:0:0 | &ref | main.rs:521:11:521:19 | vs.iter() [implicit borrow] |
| main.rs:521:11:521:35 | ... .unwrap() | file://:0:0:0:0 | &ref | main.rs:521:11:521:35 | ... .unwrap() [implicit borrow] |
| main.rs:526:15:526:16 | vs | file://:0:0:0:0 | &ref | main.rs:526:15:526:16 | vs [implicit deref 0 in state after borrow] |
| main.rs:526:15:526:16 | vs [implicit deref 0 in state after deref] | file://:0:0:0:0 | &ref | main.rs:526:15:526:16 | vs [implicit borrow] |
| main.rs:530:26:530:27 | vs | file://:0:0:0:0 | &ref | main.rs:530:26:530:27 | vs [implicit deref 0 in state after borrow] |
| main.rs:530:26:530:27 | vs [implicit deref 0 in state after deref] | file://:0:0:0:0 | &ref | main.rs:530:26:530:27 | vs [implicit borrow] |
| main.rs:535:5:535:6 | vs | file://:0:0:0:0 | &ref | main.rs:535:5:535:6 | vs [implicit deref 0 in state after borrow] |
| main.rs:535:5:535:6 | vs [implicit deref 0 in state after deref] | file://:0:0:0:0 | &ref | main.rs:535:5:535:6 | vs [implicit borrow] |
| main.rs:535:29:535:29 | x | file://:0:0:0:0 | &ref | main.rs:535:29:535:29 | x [implicit borrow] |
| main.rs:536:5:536:6 | vs | file://:0:0:0:0 | &ref | main.rs:536:5:536:6 | vs [implicit deref 0 in state after borrow] |
| main.rs:536:5:536:6 | vs [implicit deref 0 in state after deref] | file://:0:0:0:0 | &ref | main.rs:536:5:536:6 | vs [implicit borrow] |
| main.rs:536:34:536:34 | x | file://:0:0:0:0 | &ref | main.rs:536:34:536:34 | x [implicit borrow] |
| main.rs:542:23:542:32 | source(...) | file://:0:0:0:0 | element | main.rs:542:22:542:42 | [...] |
| main.rs:542:35:542:35 | 2 | file://:0:0:0:0 | element | main.rs:542:22:542:42 | [...] |
| main.rs:542:38:542:38 | 3 | file://:0:0:0:0 | element | main.rs:542:22:542:42 | [...] |
| main.rs:542:41:542:41 | 4 | file://:0:0:0:0 | element | main.rs:542:22:542:42 | [...] |
| main.rs:544:10:544:15 | vs_mut | file://:0:0:0:0 | &ref | main.rs:544:10:544:15 | vs_mut [implicit borrow] |
| main.rs:545:11:545:16 | vs_mut | file://:0:0:0:0 | &ref | main.rs:545:11:545:16 | vs_mut [implicit deref 0 in state after borrow] |
| main.rs:545:11:545:16 | vs_mut [implicit deref 0 in state after deref] | file://:0:0:0:0 | &ref | main.rs:545:11:545:16 | vs_mut [implicit borrow] |
| main.rs:545:11:545:23 | vs_mut.iter() | file://:0:0:0:0 | &ref | main.rs:545:11:545:23 | vs_mut.iter() [implicit borrow] |
| main.rs:545:11:545:39 | ... .unwrap() | file://:0:0:0:0 | &ref | main.rs:545:11:545:39 | ... .unwrap() [implicit borrow] |
| main.rs:546:11:546:16 | vs_mut | file://:0:0:0:0 | &ref | main.rs:546:11:546:16 | vs_mut [implicit deref 0 in state after borrow] |
| main.rs:546:11:546:16 | vs_mut [implicit deref 0 in state after deref] | file://:0:0:0:0 | &ref | main.rs:546:11:546:16 | vs_mut [implicit borrow] |
| main.rs:546:11:546:23 | vs_mut.iter() | file://:0:0:0:0 | &ref | main.rs:546:11:546:23 | vs_mut.iter() [implicit borrow] |
| main.rs:546:11:546:39 | ... .unwrap() | file://:0:0:0:0 | &ref | main.rs:546:11:546:39 | ... .unwrap() [implicit borrow] |
| main.rs:548:19:548:24 | vs_mut | file://:0:0:0:0 | &ref | main.rs:548:19:548:24 | vs_mut [implicit deref 0 in state after borrow] |
| main.rs:548:19:548:24 | vs_mut [implicit deref 0 in state after deref] | file://:0:0:0:0 | &ref | main.rs:548:19:548:24 | vs_mut [implicit borrow] |
| main.rs:557:18:557:18 | c | file://:0:0:0:0 | &ref | main.rs:557:17:557:18 | &c |
| main.rs:560:15:560:15 | b | file://:0:0:0:0 | &ref | main.rs:560:14:560:15 | &b |
| main.rs:562:11:562:15 | c_ref | file://:0:0:0:0 | &ref | main.rs:562:11:562:15 | c_ref [implicit borrow] |
Expand Down
Loading
Loading