mirror of
https://github.com/github/codeql.git
synced 2026-04-26 17:25:19 +02:00
Rust: Add tests for std::fs sources.
This commit is contained in:
@@ -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). |
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user