Description
Description:
Rudra is designed to detect unsafe usage patterns such as SliceFromRaw
. However, it seems that the current version of Rudra fails to detect this pattern.
Root Cause:
The issue appears to be related to the specific path Rudra uses for detection. Currently, Rudra looks for the function under the path core::slice::from_raw_parts
. However, as of a certain update in Rust (commit bcd18f9), the from_raw_parts
function has been moved to a new location, and the correct path is now core::slice::raw::from_raw_parts
.
Due to this change, Rudra's detection mechanism no longer matches the updated path, resulting in a failure to detect the SliceFromRaw
pattern in newer versions of Rust.
Steps to Reproduce:
Run Rudra to analyze code that uses SliceFromRaw.
Observe that Rudra fails to detect the SliceFromRaw
.
pub trait Writer {
fn write_bytes(&mut self, slice: &[u8]) -> Result<(), ()>;
fn write_u8(&mut self, value: u8) -> Result<(), ()> {
let slice = unsafe { std::slice::from_raw_parts(&value, 1) };
self.write_bytes(slice)
}
}
Expected Behavior:
Rudra should report an SliceFromRaw
warning for the code.
Actual Behavior:
Rudra does not report any SliceFromRaw
warning.
Regression:
In previous versions of Rudra, the following code would trigger a warning.
However, in the current version of Rudra, no warning is reported for the same code.