Skip to content

Rust: Add core::fmt::Write models - #22390

Open
geoffw0 wants to merge 5 commits into
github:redsun82-rust-analyzer-updatefrom
geoffw0:formatflow
Open

Rust: Add core::fmt::Write models#22390
geoffw0 wants to merge 5 commits into
github:redsun82-rust-analyzer-updatefrom
geoffw0:formatflow

Conversation

@geoffw0

@geoffw0 geoffw0 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Add models for core::fmt::Write, which is having a larger effect on taint analysis following recent changes. For #22346.

@redsun82

Copilot AI balanced review requested due to automatic review settings August 19, 2026 17:06
@geoffw0
geoffw0 requested a review from a team as a code owner August 19, 2026 17:06
@geoffw0 geoffw0 added the Rust Pull requests that update Rust code label Aug 19, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Rust taint-flow models for formatted writes into output buffers.

Changes:

  • Models core::fmt::Write methods and core::fmt::write.
  • Expands legacy format-macro flow tests.
  • Adds a change note.
Show a summary per file
File Description
rust/ql/lib/codeql/rust/frameworks/stdlib/core.model.yml Adds formatting flow summaries.
rust/ql/test/library-tests/format-macros-legacy/main.rs Adds formatted-write flow cases.
rust/ql/test/library-tests/format-macros-legacy/inline-taint-flow.expected Updates flow expectations.
rust/ql/test/library-tests/format-macros-legacy/FormatArgs.expected Updates format-argument expectations.
rust/ql/test/library-tests/format-macros-legacy/LogInjection.expected Updates shifted result locations.
rust/ql/lib/change-notes/2026-08-19-rust-core-fmt-flow-models.md Documents the analysis improvement.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 6/6 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread rust/ql/test/library-tests/format-macros-legacy/main.rs
# Fmt
- ["<_ as core::fmt::Write>::write_fmt", "Argument[0]", "Argument[self].Reference", "taint", "manual"]
- ["<_ as core::fmt::Write>::write_str", "Argument[0].Reference", "Argument[self].Reference", "taint", "manual"]
- ["<_ as core::fmt::Write>::write_char", "Argument[0]", "Argument[self].Reference", "taint", "manual"]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to test every single model individually.

# Fmt
- ["<_ as core::fmt::Write>::write_fmt", "Argument[0]", "Argument[self].Reference", "taint", "manual"]
- ["<_ as core::fmt::Write>::write_str", "Argument[0].Reference", "Argument[self].Reference", "taint", "manual"]
- ["<_ as core::fmt::Write>::write_char", "Argument[0]", "Argument[self].Reference", "taint", "manual"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will have a semantic merge conflict with #22376.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot. I suggest when either #22376 or #22346 is merge, we update the other for this and any other outdated models.

- ["<core::str>::trim", "Argument[self].Reference", "ReturnValue.Reference", "taint", "manual"]
- ["<core::str>::to_string", "Argument[self].Reference", "ReturnValue", "taint", "manual"]
# Fmt
- ["<_ as core::fmt::Write>::write_fmt", "Argument[0]", "Argument[self].Reference", "taint", "manual"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a way of getting taint into an Arguments struct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have test cases along the lines of format_args!("{}", source()). Do you mean that or something else?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I see that it somehow works, I'm just curious which model enables taint to get into an Arguments struct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants