Skip to content

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Rust: Model sources for std::io #19304

wants to merge 7 commits into from

Conversation

geoffw0
Copy link
Contributor

@geoffw0 geoffw0 commented Apr 14, 2025

Model sources + add tests for std::io. Also added new concept implementations for stdin and file threat model sources in Rust, similar to existing implementations in that file.

@geoffw0 geoffw0 added no-change-note-required This PR does not need a change note Rust Pull requests that update Rust code labels Apr 14, 2025
@Copilot Copilot bot review requested due to automatic review settings April 14, 2025 13:32
Copy link
Contributor

@Copilot Copilot AI left a 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

@geoffw0 geoffw0 requested a review from a team as a code owner April 15, 2025 11:37
- ["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"]
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@aibaars aibaars left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-change-note-required This PR does not need a change note Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants