Skip to content
Draft
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* Added neutral models to inhibit spurious generated sink models for `map` and `from`. This fixes some false positive query results.
12 changes: 11 additions & 1 deletion rust/ql/lib/codeql/rust/frameworks/stdlib/alloc.model.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,14 @@ extensions:
- ["<alloc::string::String as core::ops::arith::Add>::add", "Argument[0].Reference", "ReturnValue", "taint", "manual"]
# Vec
- ["alloc::vec::from_elem", "Argument[0]", "ReturnValue.Element", "value", "manual"]
- ["<alloc::vec::Vec as core::ops::deref::Deref>::deref", "Argument[self].Reference.Element", "ReturnValue.Reference.Element", "value", "manual"]
- ["<alloc::vec::Vec as core::ops::deref::Deref>::deref", "Argument[self].Reference.Element", "ReturnValue.Reference.Element", "value", "manual"]
- addsTo:
pack: codeql/rust-all
extensible: neutralModel
data:
- ["<alloc::vec::Vec as core::convert::From>::from", "sink", "manual"]
- ["<alloc::collections::vec_deque::VecDeque as core::convert::From>::from", "sink", "manual"]
- ["<alloc::sync::Arc as core::convert::From>::from", "sink", "manual"]
- ["<alloc::rc::Rc as core::convert::From>::from", "sink", "manual"]
- ["<alloc::string::String>::split_off", "sink", "manual"]
- ["<alloc::vec::Vec>::split_off", "sink", "manual"]
9 changes: 9 additions & 0 deletions rust/ql/lib/codeql/rust/frameworks/stdlib/core.model.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ extensions:
- ["<_ as core::iter::traits::iterator::Iterator>::chain", "Argument[self]", "ReturnValue", "taint", "manual"]
- ["<_ as core::iter::traits::iterator::Iterator>::chain", "Argument[0]", "ReturnValue", "taint", "manual"]
- ["<_ as core::iter::traits::iterator::Iterator>::take", "Argument[self]", "ReturnValue", "taint", "manual"]
# Option
- ["<core::option::Option>::map", "Argument[self]", "Argument[0].Parameter[0]", "taint", "manual"]
- ["<core::option::Option>::map", "Argument[0].ReturnValue", "ReturnValue", "taint", "manual"]
# Pin
- ["<core::pin::Pin>::new", "Argument[0]", "ReturnValue.Field[core::pin::Pin::pointer]", "value", "manual"]
# This model is not precise, but helps in cases where a `Pin` is implicitly dereferenced.
Expand Down Expand Up @@ -157,6 +160,12 @@ extensions:
- ["core::ptr::write_bytes", "Argument[0]", "pointer-access", "manual"]
- ["core::ptr::write_unaligned", "Argument[0]", "pointer-access", "manual"]
- ["core::ptr::write_volatile", "Argument[0]", "pointer-access", "manual"]
- addsTo:
pack: codeql/rust-all
extensible: neutralModel
data:
- ["<core::option::Option>::map", "sink", "manual"]
- ["<std::io::error::Error as core::convert::From>::from", "sink", "manual"]
- addsTo:
pack: codeql/rust-all
extensible: excludeFieldTaintStep
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,4 @@ module UncontrolledAllocationSize {
branch = false
)
}

/**
* A barrier for uncontrolled allocation size flow into particular functions.
*/
private class ModeledBarrier extends Barrier {
ModeledBarrier() {
exists(MethodCall c |
c.getStaticTarget().getCanonicalPath() =
["<alloc::string::String>::split_off", "<alloc::vec::Vec>::split_off"] and
this.asExpr() = c.getAnArgument()
)
}
}
}
129 changes: 125 additions & 4 deletions rust/ql/test/query-tests/security/CWE-117/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading