-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rust: Model sources for std::io #19304
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
- ["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"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose the repetitive definitions for read_exact
could be removed once we have support for models for trait-functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, and that will then include any other variations we come across as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Model sources + add tests for
std::io
. Also added new concept implementations forstdin
andfile
threat model sources in Rust, similar to existing implementations in that file.