Skip to content

Commit 2f2a846

Browse files
paldepindCopilot
andcommitted
Rust: Preserve referenced contents through Cow::to_mut
The regenerated Cow::to_mut summary only propagates whole-value taint and misses the paths from the Cow variants through the receiver reference to the returned mutable reference. This loses the existing file-name taint flow through file_name.to_string_lossy().to_mut(). Model Cow::Owned as value flow from its stored value to the returned reference, and Cow::Borrowed as taint flow from the referenced contents because converting borrowed contents to owned contents may clone them. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 786f0f17-6512-4098-8c92-7721e13b78b2
1 parent 6e441b5 commit 2f2a846

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎rust/ql/lib/codeql/rust/frameworks/stdlib/alloc.model.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
["<alloc::boxed::Box>::pin", "Argument[0]", "ReturnValue.Field[core::pin::Pin::pointer].Field[alloc::boxed::Box(0)]", "value", "manual"],
4141
["<alloc::boxed::Box>::new", "Argument[0]", "ReturnValue.Field[alloc::boxed::Box(0)]", "value", "manual"],
4242
["<alloc::boxed::Box>::into_pin", "Argument[0]", "ReturnValue.Field[core::pin::Pin::pointer]", "value", "manual"],
43+
// Cow
44+
["<alloc::borrow::Cow>::to_mut", "Argument[self].Reference.Field[alloc::borrow::Cow::Owned(0)]", "ReturnValue.Reference", "value", "manual"],
45+
["<alloc::borrow::Cow>::to_mut", "Argument[self].Reference.Field[alloc::borrow::Cow::Borrowed(0)].Reference", "ReturnValue.Reference", "taint", "manual"],
4346
// Fmt
4447
["alloc::fmt::format", "Argument[0]", "ReturnValue", "taint", "manual"],
4548
// Layout

0 commit comments

Comments
 (0)