Skip to content

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 some alternative sinks.
  • Loading branch information
geoffw0 committed May 1, 2025
commit b2339ef0d90550df936188dbceaad3a97414bc37
54 changes: 27 additions & 27 deletions rust/ql/test/library-tests/dataflow/sources/TaintSources.expected
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,30 @@
| test.rs:74:26:74:37 | ...::get | Flow source 'RemoteSource' of type remote (DEFAULT). |
| test.rs:77:26:77:37 | ...::get | Flow source 'RemoteSource' of type remote (DEFAULT). |
| test.rs:80:24:80:35 | ...::get | Flow source 'RemoteSource' of type remote (DEFAULT). |
| test.rs:112:31:112:42 | 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:209:22:209:35 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:215:22:215:35 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:221:22:221:35 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:227:22:227:35 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:233:9:233:22 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:237:17:237:30 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:244:50:244:63 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:250:46:250:59 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:257:50:257:63 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:264:50:264:63 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:271:56:271:69 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:278:46:278:59 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:285:46:285:59 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:291:46:291:59 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:403:31:403:43 | ...::read | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:408:31:408:38 | ...::read | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:413:22:413:39 | ...::read_to_string | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:419:22:419:25 | path | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:420:27:420:35 | file_name | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:426:22:426:34 | ...::read_link | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:436:20:436:38 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:470:21:470:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:471:21:471:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:479:21:479:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:739:16:739:29 | ...::args | Flow source 'CommandLineArgs' of type commandargs (DEFAULT). |
| test.rs:113:31:113:42 | send_request | Flow source 'RemoteSource' of type remote (DEFAULT). |
| test.rs:120:31:120:42 | send_request | Flow source 'RemoteSource' of type remote (DEFAULT). |
| test.rs:210:22:210:35 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:216:22:216:35 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:222:22:222:35 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:228:22:228:35 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:234:9:234:22 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:238:17:238:30 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:245:50:245:63 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:251:46:251:59 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:258:50:258:63 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:265:50:265:63 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:272:56:272:69 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:280:46:280:59 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:287:46:287:59 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:293:46:293:59 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
| test.rs:407:31:407:43 | ...::read | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:412:31:412:38 | ...::read | Flow source 'FileSource' of type file (DEFAULT). |
| test.rs:417:22:417:39 | ...::read_to_string | Flow source 'FileSource' of type file (DEFAULT). |
| 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). |
6 changes: 5 additions & 1 deletion rust/ql/test/library-tests/dataflow/sources/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ async fn test_reqwest() -> Result<(), reqwest::Error> {
sink(remote_string6); // $ MISSING: hasTaintFlow

let mut request1 = reqwest::get("example.com").await?; // $ Alert[rust/summary/taint-sources]
sink(request1.chunk().await?.unwrap()); // $ MISSING: hasTaintFlow
while let Some(chunk) = request1.chunk().await? {
sink(chunk); // $ MISSING: hasTaintFlow
}
Expand Down Expand Up @@ -269,6 +270,7 @@ fn test_io_stdin() -> std::io::Result<()> {

{
let mut reader_split = std::io::BufReader::new(std::io::stdin()).split(b','); // $ Alert[rust/summary/taint-sources]
sink(reader_split.next().unwrap().unwrap()); // $ MISSING: hasTaintFlow
while let Some(chunk) = reader_split.next() {
sink(chunk.unwrap()); // $ MISSING: hasTaintFlow
}
Expand Down Expand Up @@ -380,6 +382,7 @@ async fn test_tokio_stdin() -> Result<(), Box<dyn std::error::Error>> {

{
let mut reader_split = tokio::io::BufReader::new(tokio::io::stdin()).split(b','); // $ MISSING: Alert[rust/summary/taint-sources]
sink(reader_split.next_segment().await?.unwrap()); // $ MISSING: hasTaintFlow
while let Some(chunk) = reader_split.next_segment().await? {
sink(chunk); // $ MISSING: hasTaintFlow
}
Expand All @@ -388,8 +391,9 @@ async fn test_tokio_stdin() -> Result<(), Box<dyn std::error::Error>> {
{
let reader = tokio::io::BufReader::new(tokio::io::stdin()); // $ MISSING: Alert[rust/summary/taint-sources]
let mut lines = reader.lines();
sink(lines.next_line().await?.unwrap()); // $ MISSING: hasTaintFlow
while let Some(line) = lines.next_line().await? {
sink(line); // $ hasTai
sink(line); // $ MISSING: hasTaintFlow
}
}

Expand Down