Rust: Model sources for std::io#19304
Merged
geoffw0 merged 7 commits intogithub:mainfrom Apr 17, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces model sources and corresponding tests for taint flows in Rust’s std::io and filesystem operations. The key changes include:
- New test functions for filesystem and std::io sources covering various read operations and buffer handling.
- Updates to the CodeQL models for std::io and std::fs to incorporate new taint flow mappings.
Reviewed Changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| rust/ql/test/library-tests/dataflow/sources/test.rs | Added tests for filesystem and IO taint sources, ensuring taint flows from reads. |
| rust/ql/lib/codeql/rust/frameworks/stdlib/io.model.yml | Extended model file with additional taint mappings for standard IO functions. |
| rust/ql/lib/codeql/rust/frameworks/stdlib/fs.model.yml | Updated file to include new taint sources for file operations. |
Files not reviewed (2)
- rust/ql/lib/codeql/rust/Concepts.qll: Language not supported
- rust/ql/test/library-tests/dataflow/sources/TaintSources.expected: Language not supported
aibaars
reviewed
Apr 15, 2025
| - ["lang:std", "<crate::io::stdio::Stdin as crate::io::Read>::read_exact", "Argument[self]", "Argument[0].Reference", "taint", "manual"] | ||
| - ["lang:std", "<crate::io::stdio::StdinLock as crate::io::Read>::read_exact", "Argument[self]", "Argument[0].Reference", "taint", "manual"] | ||
| - ["lang:std", "<crate::fs::File as crate::io::Read>::read_exact", "Argument[self]", "Argument[0].Reference", "taint", "manual"] | ||
| - ["lang:std", "crate::io::Read::read_exact", "Argument[self]", "Argument[0].Reference", "taint", "manual"] |
Contributor
There was a problem hiding this comment.
I suppose the repetitive definitions for read_exact could be removed once we have support for models for trait-functions?
Contributor
Author
There was a problem hiding this comment.
Yep, and that will then include any other variations we come across as well.
hvitved
reviewed
Apr 22, 2025
| /** | ||
| * A data flow source corresponding to a file access. | ||
| */ | ||
| final class FileSource = FileSource::Range; |
Contributor
There was a problem hiding this comment.
Aliases inherit the QL doc from the entities that they alias, so it is only needed when different QL doc is needed (same further down).
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 sources + add tests for
std::io. Also added new concept implementations forstdinandfilethreat model sources in Rust, similar to existing implementations in that file.