Skip to content

Rust: Model clone #18676

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

Merged
merged 3 commits into from
Feb 7, 2025
Merged

Rust: Model clone #18676

merged 3 commits into from
Feb 7, 2025

Conversation

paldepind
Copy link
Contributor

@paldepind paldepind commented Feb 4, 2025

The clone method is very common in Rust and implementations should always make an exact clone of the input. So allowing value flow through any clone method seems useful.

I wasn't sure how to implement this. In C/C++ I think we have a way of adding flow that is based on data flow nodes, but here I extended SummarizedCallable::Range which is based on strings and thus feels a bit odd. Maybe we will want another way to add additional flow steps later, but for now this seems to work just fine.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Feb 4, 2025
@paldepind paldepind marked this pull request as ready for review February 5, 2025 08:47
Copy link
Contributor

@hvitved hvitved left a comment

Choose a reason for hiding this comment

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

As discussed offline, I think it would be better if we can do this with MaD, but let's look into that follow-up.

/** A model for `clone` on the `Clone` trait. */

import rust
import codeql.rust.dataflow.FlowSummary
Copy link
Contributor

Choose a reason for hiding this comment

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

private

@paldepind paldepind merged commit 9bcfd01 into github:main Feb 7, 2025
16 checks passed
@paldepind paldepind deleted the rust-model-clone branch February 7, 2025 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants