Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Rust: Model std::net and tokio fs, io, net #19446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Rust: Add source tests for tokio (fs).
  • Loading branch information
geoffw0 committed May 1, 2025
commit 627496df094bcc2d36b01cbdb7bd1b8bab3ed15c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
| 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:440:20:440:38 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:474:21:474:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:475:21:475:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:483:21:483:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:743:16:743:29 | ...::args | Flow source 'CommandLineArgs' of type commandargs (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:775:16:775:29 | ...::args | Flow source 'CommandLineArgs' of type commandargs (DEFAULT). |
38 changes: 38 additions & 0 deletions 38 rust/ql/test/library-tests/dataflow/sources/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,38 @@ fn test_fs() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}

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?; // $ MISSING: Alert[rust/summary/taint-sources]
sink(buffer); // $ MISSING: 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 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 target = tokio::fs::read_link("symlink.txt").await?; // $ MISSING: Alert[rust/summary/taint-sources]
sink(target); // $ MISSING: hasTaintFlow="symlink.txt"
}

Ok(())
}

fn test_io_file() -> std::io::Result<()> {
// --- file ---

Expand Down Expand Up @@ -781,6 +813,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
Err(e) => println!("error: {}", e),
}

println!("test_tokio_fs...");
match futures::executor::block_on(test_tokio_fs()) {
Ok(_) => println!("complete"),
Err(e) => println!("error: {}", e),
}

println!("test_io_file...");
match test_io_file() {
Ok(_) => println!("complete"),
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.