Skip to content

Commit 3839719

Browse files
committed
Rust: Add further source test cases for tokio.
1 parent b57375a commit 3839719

File tree

3 files changed

+48
-11
lines changed

3 files changed

+48
-11
lines changed

rust/ql/test/library-tests/dataflow/sources/TaintSources.expected

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636
| test.rs:278:46:278:59 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
3737
| test.rs:285:46:285:59 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
3838
| test.rs:291:46:291:59 | ...::stdin | Flow source 'StdInSource' of type stdin (DEFAULT). |
39-
| test.rs:384:31:384:43 | ...::read | Flow source 'FileSource' of type file (DEFAULT). |
40-
| test.rs:389:31:389:38 | ...::read | Flow source 'FileSource' of type file (DEFAULT). |
41-
| test.rs:394:22:394:39 | ...::read_to_string | Flow source 'FileSource' of type file (DEFAULT). |
42-
| test.rs:400:22:400:25 | path | Flow source 'FileSource' of type file (DEFAULT). |
43-
| test.rs:401:27:401:35 | file_name | Flow source 'FileSource' of type file (DEFAULT). |
44-
| test.rs:407:22:407:34 | ...::read_link | Flow source 'FileSource' of type file (DEFAULT). |
45-
| test.rs:417:20:417:38 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
46-
| test.rs:451:21:451:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
47-
| test.rs:452:21:452:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
48-
| test.rs:460:21:460:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
49-
| test.rs:621:16:621:29 | ...::args | Flow source 'CommandLineArgs' of type commandargs (DEFAULT). |
39+
| test.rs:403:31:403:43 | ...::read | Flow source 'FileSource' of type file (DEFAULT). |
40+
| test.rs:408:31:408:38 | ...::read | Flow source 'FileSource' of type file (DEFAULT). |
41+
| test.rs:413:22:413:39 | ...::read_to_string | Flow source 'FileSource' of type file (DEFAULT). |
42+
| test.rs:419:22:419:25 | path | Flow source 'FileSource' of type file (DEFAULT). |
43+
| test.rs:420:27:420:35 | file_name | Flow source 'FileSource' of type file (DEFAULT). |
44+
| test.rs:426:22:426:34 | ...::read_link | Flow source 'FileSource' of type file (DEFAULT). |
45+
| test.rs:436:20:436:38 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
46+
| test.rs:470:21:470:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
47+
| test.rs:471:21:471:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
48+
| test.rs:479:21:479:39 | ...::open | Flow source 'FileSource' of type file (DEFAULT). |
49+
| test.rs:657:16:657:29 | ...::args | Flow source 'CommandLineArgs' of type commandargs (DEFAULT). |

rust/ql/test/library-tests/dataflow/sources/options.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ qltest_dependencies:
77
- http = { version = "1.2.0" }
88
- tokio = { version = "1.43.0", features = ["full"] }
99
- futures = { version = "0.3" }
10+
- bytes = { version = "1.10.1" }

rust/ql/test/library-tests/dataflow/sources/test.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,25 @@ async fn test_tokio_stdin() -> Result<(), Box<dyn std::error::Error>> {
330330
sink(&buffer); // $ MISSING: hasTaintFlow
331331
}
332332

333+
{
334+
let mut stdin = tokio::io::stdin(); // $ MISSING: Alert[rust/summary/taint-sources]
335+
let v1 = stdin.read_u8().await?;
336+
let v2 = stdin.read_i16().await?;
337+
let v3 = stdin.read_f32().await?;
338+
let v4 = stdin.read_i64_le().await?;
339+
sink(v1); // $ MISSING: hasTaintFlow
340+
sink(v2); // $ MISSING: hasTaintFlow
341+
sink(v3); // $ MISSING: hasTaintFlow
342+
sink(v4); // $ MISSING: hasTaintFlow
343+
}
344+
345+
{
346+
let mut stdin = tokio::io::stdin(); // $ MISSING: Alert[rust/summary/taint-sources]
347+
let mut buffer = bytes::BytesMut::new();
348+
stdin.read_buf(&mut buffer).await?;
349+
sink(&buffer); // $ MISSING: hasTaintFlow
350+
}
351+
333352
// --- async reading from stdin (BufReader) ---
334353

335354
{
@@ -495,6 +514,23 @@ async fn test_tokio_file() -> std::io::Result<()> {
495514
sink(&buffer); // $ MISSING: hasTaintFlow="file.txt"
496515
}
497516

517+
{
518+
let v1 = file.read_u8().await?;
519+
let v2 = file.read_i16().await?;
520+
let v3 = file.read_f32().await?;
521+
let v4 = file.read_i64_le().await?;
522+
sink(v1); // $ MISSING: hasTaintFlow
523+
sink(v2); // $ MISSING: hasTaintFlow
524+
sink(v3); // $ MISSING: hasTaintFlow
525+
sink(v4); // $ MISSING: hasTaintFlow
526+
}
527+
528+
{
529+
let mut buffer = bytes::BytesMut::new();
530+
file.read_buf(&mut buffer).await?;
531+
sink(&buffer); // $ MISSING: hasTaintFlow
532+
}
533+
498534
// --- misc operations ---
499535

500536
{

0 commit comments

Comments
 (0)