Skip to content

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

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
@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