mirror of
https://github.com/github/codeql.git
synced 2026-04-24 08:15:14 +02:00
Rust: Add models for tokio (fs).
This commit is contained in:
11
rust/ql/lib/codeql/rust/frameworks/tokio/fs.model.yml
Normal file
11
rust/ql/lib/codeql/rust/frameworks/tokio/fs.model.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
extensions:
|
||||
- addsTo:
|
||||
pack: codeql/rust-all
|
||||
extensible: sourceModel
|
||||
data:
|
||||
- ["repo:https://github.com/tokio-rs/tokio:tokio", "crate::fs::read::read", "ReturnValue.Future.Field[crate::result::Result::Ok(0)]", "file", "manual"]
|
||||
- ["repo:https://github.com/tokio-rs/tokio:tokio", "crate::fs::read_to_string::read_to_string", "ReturnValue.Future.Field[crate::result::Result::Ok(0)]", "file", "manual"]
|
||||
- ["repo:https://github.com/tokio-rs/tokio:tokio", "crate::fs::read_link::read_link", "ReturnValue.Future.Field[crate::result::Result::Ok(0)]", "file", "manual"]
|
||||
- ["repo:https://github.com/tokio-rs/tokio:tokio", "<crate::fs::read_dir::DirEntry>::path", "ReturnValue", "file", "manual"]
|
||||
- ["repo:https://github.com/tokio-rs/tokio:tokio", "<crate::fs::read_dir::DirEntry>::file_name", "ReturnValue", "file", "manual"]
|
||||
- ["repo:https://github.com/tokio-rs/tokio:tokio", "<crate::fs::file::File>::open", "ReturnValue.Future.Field[crate::result::Result::Ok(0)]", "file", "manual"]
|
||||
@@ -46,3 +46,6 @@ extensions:
|
||||
- ["repo:https://github.com/tokio-rs/tokio:tokio", "crate::io::util::async_read_ext::AsyncReadExt::read_f32_le", "Argument[self]", "ReturnValue.Future.Field[crate::result::Result::Ok(0)]", "taint", "manual"]
|
||||
- ["repo:https://github.com/tokio-rs/tokio:tokio", "crate::io::util::async_read_ext::AsyncReadExt::read_f64", "Argument[self]", "ReturnValue.Future.Field[crate::result::Result::Ok(0)]", "taint", "manual"]
|
||||
- ["repo:https://github.com/tokio-rs/tokio:tokio", "crate::io::util::async_read_ext::AsyncReadExt::read_f64_le", "Argument[self]", "ReturnValue.Future.Field[crate::result::Result::Ok(0)]", "taint", "manual"]
|
||||
- ["repo:https://github.com/tokio-rs/tokio:tokio", "crate::io::util::async_read_ext::AsyncReadExt::chain", "Argument[self]", "ReturnValue", "taint", "manual"]
|
||||
- ["repo:https://github.com/tokio-rs/tokio:tokio", "crate::io::util::async_read_ext::AsyncReadExt::chain", "Argument[0]", "ReturnValue", "taint", "manual"]
|
||||
- ["repo:https://github.com/tokio-rs/tokio:tokio", "crate::io::util::async_read_ext::AsyncReadExt::take", "Argument[self]", "ReturnValue", "taint", "manual"]
|
||||
|
||||
@@ -54,8 +54,18 @@
|
||||
| test.rs:423:22:423:25 | path | Flow source 'FileSource' of type file (DEFAULT). |
|
||||
| test.rs:424:27:424:35 | file_name | Flow source 'FileSource' of type file (DEFAULT). |
|
||||
| test.rs:430:22:430:34 | ...::read_link | Flow source 'FileSource' of type file (DEFAULT). |
|
||||
| test.rs:439:31:439:45 | ...::read | Flow source 'FileSource' of type file (DEFAULT). |
|
||||
| test.rs:444:31:444:45 | ...::read | Flow source 'FileSource' of type file (DEFAULT). |
|
||||
| test.rs:449:22:449:46 | ...::read_to_string | Flow source 'FileSource' of type file (DEFAULT). |
|
||||
| test.rs:455:26:455:29 | path | Flow source 'FileSource' of type file (DEFAULT). |
|
||||
| test.rs:456:31:456:39 | file_name | Flow source 'FileSource' of type file (DEFAULT). |
|
||||
| test.rs:462:22:462:41 | ...::read_link | Flow source 'FileSource' of type file (DEFAULT). |
|
||||
| test.rs:472:20:472:38 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
|
||||
| test.rs:506:21:506:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
|
||||
| test.rs:507:21:507:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
|
||||
| test.rs:515:21:515:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
|
||||
| test.rs:527:20:527:40 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
|
||||
| test.rs:574:21:574:41 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
|
||||
| test.rs:575:21:575:41 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
|
||||
| test.rs:583:21:583:41 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
|
||||
| test.rs:775:16:775:29 | ...::args | Flow source 'CommandLineArgs' of type commandargs (DEFAULT). |
|
||||
|
||||
@@ -436,31 +436,31 @@ fn test_fs() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
async fn test_tokio_fs() -> Result<(), Box<dyn std::error::Error>> {
|
||||
{
|
||||
let buffer: Vec<u8> = tokio::fs::read("file.bin").await?; // $ MISSING: Alert[rust/summary/taint-sources]
|
||||
sink(buffer); // $ MISSING: hasTaintFlow="file.bin"
|
||||
let buffer: Vec<u8> = tokio::fs::read("file.bin").await?; // $ Alert[rust/summary/taint-sources]
|
||||
sink(buffer); // $ hasTaintFlow="file.bin"
|
||||
}
|
||||
|
||||
{
|
||||
let buffer: Vec<u8> = tokio::fs::read("file.bin").await?; // $ MISSING: Alert[rust/summary/taint-sources]
|
||||
sink(buffer); // $ MISSING: hasTaintFlow="file.bin"
|
||||
let buffer: Vec<u8> = tokio::fs::read("file.bin").await?; // $ Alert[rust/summary/taint-sources]
|
||||
sink(buffer); // $ hasTaintFlow="file.bin"
|
||||
}
|
||||
|
||||
{
|
||||
let buffer = tokio::fs::read_to_string("file.txt").await?; // $ MISSING: Alert[rust/summary/taint-sources]
|
||||
sink(buffer); // $ MISSING: hasTaintFlow="file.txt"
|
||||
let buffer = tokio::fs::read_to_string("file.txt").await?; // $ Alert[rust/summary/taint-sources]
|
||||
sink(buffer); // $ hasTaintFlow="file.txt"
|
||||
}
|
||||
|
||||
let mut read_dir = tokio::fs::read_dir("directory").await?;
|
||||
for entry in read_dir.next_entry().await? {
|
||||
let path = entry.path(); // $ MISSING: Alert[rust/summary/taint-sources]
|
||||
let file_name = entry.file_name(); // $ MISSING: Alert[rust/summary/taint-sources]
|
||||
sink(path); // $ MISSING: hasTaintFlow
|
||||
sink(file_name); // $ MISSING: hasTaintFlow
|
||||
let path = entry.path(); // $ Alert[rust/summary/taint-sources]
|
||||
let file_name = entry.file_name(); // $ Alert[rust/summary/taint-sources]
|
||||
sink(path); // $ hasTaintFlow
|
||||
sink(file_name); // $ hasTaintFlow
|
||||
}
|
||||
|
||||
{
|
||||
let target = tokio::fs::read_link("symlink.txt").await?; // $ MISSING: Alert[rust/summary/taint-sources]
|
||||
sink(target); // $ MISSING: hasTaintFlow="symlink.txt"
|
||||
let target = tokio::fs::read_link("symlink.txt").await?; // $ Alert[rust/summary/taint-sources]
|
||||
sink(target); // $ hasTaintFlow="symlink.txt"
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -524,30 +524,30 @@ fn test_io_file() -> std::io::Result<()> {
|
||||
async fn test_tokio_file() -> std::io::Result<()> {
|
||||
// --- file ---
|
||||
|
||||
let mut file = tokio::fs::File::open("file.txt").await?; // $ MISSING: Alert[rust/summary/taint-sources]
|
||||
let mut file = tokio::fs::File::open("file.txt").await?; // $ Alert[rust/summary/taint-sources]
|
||||
|
||||
{
|
||||
let mut buffer = [0u8; 100];
|
||||
let _bytes = file.read(&mut buffer).await?;
|
||||
sink(&buffer); // $ MISSING: hasTaintFlow="file.txt"
|
||||
sink(&buffer); // $ hasTaintFlow="file.txt"
|
||||
}
|
||||
|
||||
{
|
||||
let mut buffer = Vec::<u8>::new();
|
||||
let _bytes = file.read_to_end(&mut buffer).await?;
|
||||
sink(&buffer); // $ MISSING: hasTaintFlow="file.txt"
|
||||
sink(&buffer); // $ hasTaintFlow="file.txt"
|
||||
}
|
||||
|
||||
{
|
||||
let mut buffer = String::new();
|
||||
let _bytes = file.read_to_string(&mut buffer).await?;
|
||||
sink(&buffer); // $ MISSING: hasTaintFlow="file.txt"
|
||||
sink(&buffer); // $ hasTaintFlow="file.txt"
|
||||
}
|
||||
|
||||
{
|
||||
let mut buffer = [0; 100];
|
||||
file.read_exact(&mut buffer).await?;
|
||||
sink(&buffer); // $ MISSING: hasTaintFlow="file.txt"
|
||||
sink(&buffer); // $ hasTaintFlow="file.txt"
|
||||
}
|
||||
|
||||
{
|
||||
@@ -555,35 +555,35 @@ async fn test_tokio_file() -> std::io::Result<()> {
|
||||
let v2 = file.read_i16().await?;
|
||||
let v3 = file.read_f32().await?;
|
||||
let v4 = file.read_i64_le().await?;
|
||||
sink(v1); // $ MISSING: hasTaintFlow
|
||||
sink(v2); // $ MISSING: hasTaintFlow
|
||||
sink(v3); // $ MISSING: hasTaintFlow
|
||||
sink(v4); // $ MISSING: hasTaintFlow
|
||||
sink(v1); // $ hasTaintFlow="file.txt"
|
||||
sink(v2); // $ hasTaintFlow="file.txt"
|
||||
sink(v3); // $ hasTaintFlow="file.txt"
|
||||
sink(v4); // $ hasTaintFlow="file.txt"
|
||||
}
|
||||
|
||||
{
|
||||
let mut buffer = bytes::BytesMut::new();
|
||||
file.read_buf(&mut buffer).await?;
|
||||
sink(&buffer); // $ MISSING: hasTaintFlow
|
||||
sink(&buffer); // $ hasTaintFlow="file.txt"
|
||||
}
|
||||
|
||||
// --- misc operations ---
|
||||
|
||||
{
|
||||
let mut buffer = String::new();
|
||||
let file1 = tokio::fs::File::open("file.txt").await?; // $ MISSING: Alert[rust/summary/taint-sources]
|
||||
let file2 = tokio::fs::File::open("another_file.txt").await?; // $ MISSING: [rust/summary/taint-sources]
|
||||
let file1 = tokio::fs::File::open("file.txt").await?; // $ Alert[rust/summary/taint-sources]
|
||||
let file2 = tokio::fs::File::open("another_file.txt").await?; // $ Alert[rust/summary/taint-sources]
|
||||
let mut reader = file1.chain(file2);
|
||||
reader.read_to_string(&mut buffer).await?;
|
||||
sink(&buffer); // $ MISSING: hasTaintFlow="file.txt" hasTaintFlow="another_file.txt"
|
||||
sink(&buffer); // $ hasTaintFlow="file.txt" hasTaintFlow="another_file.txt"
|
||||
}
|
||||
|
||||
{
|
||||
let mut buffer = String::new();
|
||||
let file1 = tokio::fs::File::open("file.txt").await?; // $ MISSING: Alert[rust/summary/taint-sources]
|
||||
let file1 = tokio::fs::File::open("file.txt").await?; // $ Alert[rust/summary/taint-sources]
|
||||
let mut reader = file1.take(100);
|
||||
reader.read_to_string(&mut buffer).await?;
|
||||
sink(&buffer); // $ MISSING: hasTaintFlow="file.txt"
|
||||
sink(&buffer); // $ hasTaintFlow="file.txt"
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user