Skip to content
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

Rust: Setup inline flow test library #17959

Merged
merged 2 commits into from
Nov 12, 2024

Conversation

paldepind
Copy link
Contributor

@paldepind paldepind commented Nov 11, 2024

Setup inline flow test library for Rust. It doesn't output anything, but it should once other things begin to work 😉

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Nov 11, 2024
@@ -1,4 +1,4 @@
fn source() -> &'static str {
fn source(i: i64) -> &'static str {

Check notice

Code scanning / CodeQL

Unused variable Note test

Variable 'i' is not used.
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.

Missing a bindingset, otherwise LGTM.

result = src.asExpr().(CallExpr).getArgList().getArg(0).toString()
}

string getArgString(DataFlow::Node src, DataFlow::Node sink) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing bindingset[src, sink].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What does the bindingset do here? From the documentation I thought that it was only to be used for predicates over infinite types. For several of the other language there is no bindingset annotation on getArgString. Go for instance. Should it ideally also be added there? Or is it not needed there for some reason?

Copy link
Contributor

Choose a reason for hiding this comment

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

It is needed to avoid creating a Cartesian product. It should also be added for Go.

}

string getArgString(DataFlow::Node src, DataFlow::Node sink) {
(if exists(getSourceArgString(src)) then result = getSourceArgString(src) else result = "") and
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this was copied from Ruby, but the idiomatic way to write things like this is

result = getSourceArgString(src)
or
not exists(getSourceArgString(src)) and
result = ""

@paldepind paldepind merged commit 7517ad3 into github:main Nov 12, 2024
13 checks passed
@paldepind paldepind deleted the rust-inline-flow-test branch November 12, 2024 10:55
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