Rust: Add tests for std::fs sources.

This commit is contained in:
Geoffrey White
2025-04-11 10:06:49 +01:00
parent cef3cd9b54
commit 258c1afe27
2 changed files with 35 additions and 1 deletions

View File

@@ -22,4 +22,4 @@
| test.rs:80:24:80:35 | ...::get | Flow source 'RemoteSource' of type remote (DEFAULT). |
| test.rs:112:35:112:46 | send_request | Flow source 'RemoteSource' of type remote (DEFAULT). |
| test.rs:119:31:119:42 | send_request | Flow source 'RemoteSource' of type remote (DEFAULT). |
| test.rs:352:16:352:29 | ...::args | Flow source 'CommandLineArgs' of type commandargs (DEFAULT). |
| test.rs:386:16:386:29 | ...::args | Flow source 'CommandLineArgs' of type commandargs (DEFAULT). |

View File

@@ -198,6 +198,40 @@ async fn test_hyper_http(case: i64) -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}
use std::fs;
fn test_fs() -> Result<(), Box<dyn std::error::Error>> {
{
let buffer: Vec<u8> = std::fs::read("file.bin")?; // $ MISSING: Alert[rust/summary/taint-sources]
sink(buffer); // $ MISSING: hasTaintFlow
}
{
let buffer: Vec<u8> = fs::read("file.bin")?; // $ MISSING: Alert[rust/summary/taint-sources]
sink(buffer); // $ MISSING: hasTaintFlow
}
{
let buffer = fs::read_to_string("file.txt")?; // $ MISSING: Alert[rust/summary/taint-sources]
sink(buffer); // $ MISSING: hasTaintFlow
}
for entry in fs::read_dir("directory")? {
let e = entry?;
let path = e.path(); // $ MISSING: Alert[rust/summary/taint-sources]
let file_name = e.file_name(); // $ MISSING: Alert[rust/summary/taint-sources]
sink(path); // $ MISSING: hasTaintFlow
sink(file_name); // $ MISSING: hasTaintFlow
}
{
let target = fs::read_link("symlink.txt")?; // $ MISSING: Alert[rust/summary/taint-sources]
sink(target); // $ MISSING: hasTaintFlow
}
Ok(())
}
use std::io::Read;
use std::io::BufRead;