Rust: Model std::net and tokio fs, io, net#19446
Merged
geoffw0 merged 19 commits intogithub:mainfrom May 21, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR extends the CodeQL Rust taint models to cover std::net and Tokio’s fs, io, and net APIs, reorganizes some existing test inputs, and refines the reqwest model for async responses.
- Add
bytescrate dependency to test options - Update expected DataFlow outputs for new sources (
stdin, file, network) - Introduce YAML model files for Tokio and standard library networking, FS, IO, plus enhanced
reqwestasync return modeling
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| rust/ql/test/library-tests/dataflow/sources/options.yml | Added bytes crate to test dependencies |
| rust/ql/test/library-tests/dataflow/sources/TaintSources.expected | Updated expected taint sources ordering and entries |
| rust/ql/test/library-tests/dataflow/local/DataFlowStep.expected | Extended local dataflow summary with new TcpStream, Tokio async read, split, lines, reqwest futures, etc. |
| rust/ql/lib/codeql/rust/frameworks/tokio/net.model.yml | New source and summary model for Tokio TCP connect and read variants |
| rust/ql/lib/codeql/rust/frameworks/tokio/io.model.yml | New source and summary model for Tokio async IO primitives |
| rust/ql/lib/codeql/rust/frameworks/tokio/fs.model.yml | New source model for Tokio async file read APIs |
| rust/ql/lib/codeql/rust/frameworks/stdlib/net.model.yml | New source and summary model for std::net::TcpStream connect and IO |
| rust/ql/lib/codeql/rust/frameworks/stdlib/io.model.yml | Added summary model for std::io::Split iterator next |
| rust/ql/lib/codeql/rust/frameworks/reqwest.model.yml | Adjusted crate::get to return a future; added async and blocking response methods |
Comments suppressed due to low confidence (2)
rust/ql/lib/codeql/rust/frameworks/tokio/net.model.yml:6
- Consider adding a source model for
<crate::net::tcp::stream::TcpStream>::connect_timeoutsimilar toconnectto cover timed-out connection flows.
- ["repo:https://github.com/tokio-rs/tokio:tokio", "<crate::net::tcp::stream::TcpStream>::connect", "ReturnValue.Future.Field[crate::result::Result::Ok(0)]", "remote", "manual"]
rust/ql/lib/codeql/rust/frameworks/reqwest.model.yml:27
- Add a mapping for
<crate::async_impl::response::Response>::text_with_charsetin the async model to ensure coverage of all async response body methods.
- ["repo:https://github.com/seanmonstar/reqwest:reqwest", "<crate::async_impl::response::Response>::chunk", "Argument[self]", "ReturnValue.Future.Field[crate::result::Result::Ok(0)].Field[crate::option::Option::Some(0)]", "taint", "manual"]
Contributor
Author
|
DCA shows a 4.3x increase in taint sources, 4.5x increase in taint reach 🎉 |
Contributor
Author
|
Fixed merge conflicts with #19466 . There's still a test failure. |
paldepind
reviewed
May 20, 2025
paldepind
previously approved these changes
May 20, 2025
Contributor
paldepind
left a comment
There was a problem hiding this comment.
CI has some small diffs, but otherwise this looks good to be with a nice impact on DCA 🎉
paldepind
approved these changes
May 21, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Model
std::netand tokiofs,io,net. This includes a good number of high value taint sources. There are lots of test cases, particularly since at present it's tricky to get the repo / path correct in the model without a test to examine first.I've also moved some stuff around in the
dataflow/sourcestests as it was getting large and disorganized. And I've improved modelling ofreqwest.A DCA run will reveal how well this all works...