-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rust: Test and model some string and iterator methods #18701
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
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.
PR Overview
This PR adds dataflow coverage for string parsing and iterator methods. It introduces new tests covering .parse, .to_string, and iterator usage in the local code, while also adding corresponding dataflow models in lang-core.model.yml.
- Adds tests for .parse and .to_string in main.rs
- Augments the dataflow model for parse and to_string in lang-core.model.yml
- Extends environment argument tests in sources/test.rs
Changes
File | Description |
---|---|
rust/ql/test/library-tests/dataflow/local/main.rs | Adds new functions to test .parse, .to_string, and iterator behavior |
rust/ql/lib/codeql/rust/frameworks/stdlib/lang-core.model.yml | Adds dataflow modeling lines for parse and to_string |
rust/ql/test/library-tests/dataflow/sources/test.rs | Adds an additional arg parse test case |
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Tip: Copilot code review supports C#, Go, Java, JavaScript, Markdown, Python, Ruby and TypeScript, with more languages coming soon. Learn more
The model looks fine to me and my guess would be the same as yours, that it's the |
I'll have a closer look at those |
Ah, it looks like there's some overlap between this and #18621 . It probably makes sense to get that merged first, then merge latest |
vs.iter().map(|x| sink(*x)); // $ MISSING: hasValueFlow=91 | ||
vs.iter().for_each(|x| sink(*x)); // $ MISSING: hasValueFlow=91 | ||
|
||
for v in vs.into_iter() { |
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.
For this call to into_iter()
(from the IntoIter
trait), we don't seem to have a result for resolvable_resolved_paths
.
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.
@hvitved would you mind taking a quick look?
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.
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've created an issue to track this (to separate this concern from merging the PR). I'm keen to hear what people think we need to do.
…es of this query at some point; it's good that flow reaches it now).
note to self: I need to replace |
Done:
|
I didn't have much luck fixing the models with data flow as it is now - I can see nothing obviously wrong with them, writing them a few different ways (including in QL) didn't seem to help, and guessing that some things should be a |
Fixed merge conflict. There's some follow-up work, but it's all written up in issues. The sooner we merge this the better. |
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 :)
I decided to take a moment to test and model some string and iterator methods that I'm coming across frequently, in particular I want to get flow through the chain:
(
std::env::args()
being a flow source)Modelling the string methods I wanted went fine (
.parse
and its inverse.to_string
), but I don't seem to be able to produce a working MaD model (that is, one producing any flow edges) for any of the iterator methods (.iter
,.next
,.nth
etc). I'm suspicious of the paths I've been using, for example for.iter
for example I get:suggesting a model along the lines of:
I'm also suspicious of the reference return values causing problems.
@hvitved @paldepind do you have any thoughts?