Rust: Update expected test output

This commit is contained in:
Tom Hvitved
2026-01-08 13:54:15 +01:00
parent 792908586a
commit 0d0029f5a3
3 changed files with 600 additions and 508 deletions

View File

@@ -1,33 +1,33 @@
| test.rs:12:31:12:43 | ...::read | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:17:31:17:38 | ...::read | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:22:22:22:39 | ...::read_to_string | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:26:18:26:29 | ...::read_dir | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:29:22:29:25 | path | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:43:27:43:35 | file_name | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:51:52:51:59 | read_dir | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:54:22:54:25 | path | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:55:27:55:35 | file_name | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:57:56:57:63 | read_dir | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:60:22:60:25 | path | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:61:27:61:35 | file_name | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:65:22:65:34 | ...::read_link | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:74:31:74:45 | ...::read | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:79:31:79:45 | ...::read | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:84:22:84:46 | ...::read_to_string | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:90:26:90:29 | path | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:91:31:91:39 | file_name | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:97:22:97:41 | ...::read_link | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:107:20:107:38 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:140:50:140:53 | open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:147:67:147:70 | open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:154:101:154:104 | open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:164:21:164:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:165:21:165:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:173:21:173:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:185:20:185:40 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:231:52:231:55 | open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:241:21:241:41 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:242:21:242:41 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:250:21:250:41 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:262:20:262:44 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:273:56:273:59 | open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:27:26:27:37 | ...::read_dir | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:30:22:30:25 | path | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:44:27:44:35 | file_name | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:53:60:53:67 | read_dir | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:56:22:56:25 | path | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:57:27:57:35 | file_name | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:60:64:60:71 | read_dir | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:63:22:63:25 | path | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:64:27:64:35 | file_name | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:68:22:68:34 | ...::read_link | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:77:31:77:45 | ...::read | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:82:31:82:45 | ...::read | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:87:22:87:46 | ...::read_to_string | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:93:26:93:29 | path | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:94:31:94:39 | file_name | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:100:22:100:41 | ...::read_link | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:110:20:110:38 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:143:50:143:53 | open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:152:14:152:17 | open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:165:14:165:17 | open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:176:21:176:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:177:21:177:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:185:21:185:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:197:20:197:40 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:243:52:243:55 | open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:253:21:253:41 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:254:21:254:41 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:262:21:262:41 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:274:20:274:44 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:285:56:285:59 | open | Flow source 'FileSource' of type file (DEFAULT). |

View File

@@ -1,11 +1,11 @@
fn sink<T>(_: T) { }
fn sink<T>(_: T) {}
// --- tests ---
use async_std::io::ReadExt;
use std::fs;
use std::io::Read;
use tokio::io::AsyncReadExt;
use async_std::io::ReadExt;
fn test_fs() -> Result<(), Box<dyn std::error::Error>> {
{
@@ -23,43 +23,46 @@ fn test_fs() -> Result<(), Box<dyn std::error::Error>> {
sink(buffer); // $ hasTaintFlow="file.txt"
}
for entry in fs::read_dir("directory")? { // $ Alert[rust/summary/taint-sources]
#[rustfmt::skip]
let _ = for entry in fs::read_dir("directory")? { // $ Alert[rust/summary/taint-sources]
let e = entry?;
let path = e.path(); // $ Alert[rust/summary/taint-sources]
sink(path.clone()); // $ hasTaintFlow
sink(path.clone().as_path()); // $ hasTaintFlow
sink(path.clone().into_os_string()); // $ MISSING: hasTaintFlow
sink(std::path::PathBuf::from(path.clone().into_boxed_path())); // $ MISSING: hasTaintFlow
sink(path.clone().as_os_str()); // $ MISSING: hasTaintFlow
sink(path.clone().as_mut_os_str()); // $ MISSING: hasTaintFlow
sink(path.to_str()); // $ MISSING: hasTaintFlow
sink(path.to_path_buf()); // $ MISSING: hasTaintFlow
sink(path.file_name().unwrap()); // $ MISSING: hasTaintFlow
sink(path.extension().unwrap()); // $ MISSING: hasTaintFlow
sink(path.clone().into_os_string()); // $ hasTaintFlow
sink(std::path::PathBuf::from(path.clone().into_boxed_path())); // $ hasTaintFlow
sink(path.clone().as_os_str()); // $ hasTaintFlow
sink(path.clone().as_mut_os_str()); // $ hasTaintFlow
sink(path.to_str()); // $ hasTaintFlow
sink(path.to_path_buf()); // $ hasTaintFlow
sink(path.file_name().unwrap()); // $ hasTaintFlow
sink(path.extension().unwrap()); // $ hasTaintFlow
sink(path.canonicalize().unwrap()); // $ hasTaintFlow
sink(path); // $ hasTaintFlow
let file_name = e.file_name(); // $ Alert[rust/summary/taint-sources]
sink(file_name.clone()); // $ hasTaintFlow
sink(file_name.clone().into_string().unwrap()); // $ hasTaintFlow
sink(file_name.to_str().unwrap()); // $ MISSING: hasTaintFlow
sink(file_name.to_string_lossy().to_mut()); // $ MISSING: hasTaintFlow
sink(file_name.clone().as_encoded_bytes()); // $ MISSING: hasTaintFlow
sink(file_name.to_str().unwrap()); // $ hasTaintFlow
sink(file_name.to_string_lossy().to_mut()); // $ hasTaintFlow
sink(file_name.clone().as_encoded_bytes()); // $ hasTaintFlow
sink(file_name); // $ hasTaintFlow
}
for entry in std::path::Path::new("directory").read_dir()? { // $ Alert[rust/summary/taint-sources]
};
#[rustfmt::skip]
let _ = for entry in std::path::Path::new("directory").read_dir()? { // $ Alert[rust/summary/taint-sources]
let e = entry?;
let path = e.path(); // $ Alert[rust/summary/taint-sources]
let file_name = e.file_name(); // $ Alert[rust/summary/taint-sources]
}
for entry in std::path::PathBuf::from("directory").read_dir()? { // $ Alert[rust/summary/taint-sources]
};
#[rustfmt::skip]
let _ = for entry in std::path::PathBuf::from("directory").read_dir()? { // $ Alert[rust/summary/taint-sources]
let e = entry?;
let path = e.path(); // $ Alert[rust/summary/taint-sources]
let file_name = e.file_name(); // $ Alert[rust/summary/taint-sources]
}
};
{
let target = fs::read_link("symlink.txt")?; // $ Alert[rust/summary/taint-sources]
@@ -144,14 +147,23 @@ fn test_io_file() -> std::io::Result<()> {
}
{
let mut f2 = std::fs::OpenOptions::new().create_new(true).open("f2.txt").unwrap(); // $ Alert[rust/summary/taint-sources]
let mut f2 = std::fs::OpenOptions::new()
.create_new(true)
.open("f2.txt") // $ Alert[rust/summary/taint-sources]
.unwrap();
let mut buffer = [0u8; 1024];
let _bytes = f2.read(&mut buffer)?;
sink(&buffer); // $ hasTaintFlow="f2.txt"
}
{
let mut f3 = std::fs::OpenOptions::new().read(true).write(true).truncate(true).create(true).open("f3.txt").unwrap(); // $ Alert[rust/summary/taint-sources]
let mut f3 = std::fs::OpenOptions::new()
.read(true)
.write(true)
.truncate(true)
.create(true)
.open("f3.txt") // $ Alert[rust/summary/taint-sources]
.unwrap();
let mut buffer = [0u8; 1024];
let _bytes = f3.read(&mut buffer)?;
sink(&buffer); // $ hasTaintFlow="f3.txt"