Skip to content
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 more tests for DirEntry, PathBuf, OsString.
  • Loading branch information
geoffw0 committed Aug 22, 2025
commit 49b4adcc99f151ef1f7d5b2cfc50d04ada3e173c
54 changes: 28 additions & 26 deletions rust/ql/test/library-tests/dataflow/sources/TaintSources.expected
Original file line number Diff line number Diff line change
Expand Up @@ -55,32 +55,34 @@
| test.rs:413:31:413:38 | ...::read | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:418:22:418:39 | ...::read_to_string | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:418:22:418:39 | ...::read_to_string | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:424:22:424:25 | path | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:425:27:425:35 | file_name | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:431:22:431:34 | ...::read_link | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:440:31:440:45 | ...::read | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:445:31:445:45 | ...::read | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:450:22:450:46 | ...::read_to_string | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:456:26:456:29 | path | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:456:26:456:29 | path | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:457:31:457:39 | file_name | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:457:31:457:39 | file_name | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:463:22:463:41 | ...::read_link | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:473:20:473:38 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:530:21:530:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:531:21:531:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:539:21:539:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:551:20:551:40 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:607:21:607:41 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:608:21:608:41 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:616:21:616:41 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:658:26:658:53 | ...::connect | Flow source 'RemoteSource' of type remote (DEFAULT). |
| test.rs:677:26:677:61 | ...::connect_timeout | Flow source 'RemoteSource' of type remote (DEFAULT). |
| test.rs:729:28:729:57 | ...::connect | Flow source 'RemoteSource' of type remote (DEFAULT). |
| test.rs:811:22:811:49 | ...::connect | Flow source 'RemoteSource' of type remote (DEFAULT). |
| test.rs:837:22:837:50 | ...::new | Flow source 'RemoteSource' of type remote (DEFAULT). |
| test.rs:864:16:864:29 | ...::args | Flow source 'CommandLineArgs' of type commandargs (DEFAULT). |
| test.rs:864:16:864:29 | ...::args | Flow source 'CommandLineArgs' of type commandargs (DEFAULT). |
| test.rs:425:22:425:25 | path | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:439:27:439:35 | file_name | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:450:22:450:25 | path | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:451:27:451:35 | file_name | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:461:22:461:34 | ...::read_link | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:470:31:470:45 | ...::read | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:475:31:475:45 | ...::read | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:480:22:480:46 | ...::read_to_string | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:486:26:486:29 | path | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:486:26:486:29 | path | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:487:31:487:39 | file_name | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:487:31:487:39 | file_name | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:493:22:493:41 | ...::read_link | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:503:20:503:38 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:560:21:560:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:561:21:561:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:569:21:569:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:581:20:581:40 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:637:21:637:41 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:638:21:638:41 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:646:21:646:41 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:688:26:688:53 | ...::connect | Flow source 'RemoteSource' of type remote (DEFAULT). |
| test.rs:707:26:707:61 | ...::connect_timeout | Flow source 'RemoteSource' of type remote (DEFAULT). |
| test.rs:759:28:759:57 | ...::connect | Flow source 'RemoteSource' of type remote (DEFAULT). |
| test.rs:841:22:841:49 | ...::connect | Flow source 'RemoteSource' of type remote (DEFAULT). |
| test.rs:867:22:867:50 | ...::new | Flow source 'RemoteSource' of type remote (DEFAULT). |
| test.rs:894:16:894:29 | ...::args | Flow source 'CommandLineArgs' of type commandargs (DEFAULT). |
| test.rs:894:16:894:29 | ...::args | Flow source 'CommandLineArgs' of type commandargs (DEFAULT). |
| test_futures_io.rs:19:15:19:32 | ...::connect | Flow source 'RemoteSource' of type remote (DEFAULT). |
| web_frameworks.rs:11:31:11:31 | a | Flow source 'RemoteSource' of type remote (DEFAULT). |
| web_frameworks.rs:11:31:11:31 | a | Flow source 'RemoteSource' of type remote (DEFAULT). |
Expand Down
32 changes: 31 additions & 1 deletion rust/ql/test/library-tests/dataflow/sources/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,11 +421,41 @@ fn test_fs() -> Result<(), Box<dyn std::error::Error>> {

for entry in fs::read_dir("directory")? {
let e = entry?;

let path = e.path(); // $ Alert[rust/summary/taint-sources]
let file_name = e.file_name(); // $ 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.canonicalize().unwrap()); // $ MISSING: 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()); // $ MISSING: 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); // $ hasTaintFlow
}
for entry in std::path::Path::new("directory").read_dir()? {
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()? {
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]
}

{
let target = fs::read_link("symlink.txt")?; // $ Alert[rust/summary/taint-sources]
Expand Down