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

Ruby: More precise flow into splat parameters #13938

Merged
merged 6 commits into from
Aug 18, 2023
Merged

Conversation

hmac
Copy link
Contributor

@hmac hmac commented Aug 10, 2023

We now precisely track flow from positional arguments to splat parameters, provided that splat arguments are not used and there are no positional parameters after the splat parameter. For example, in this case:

def f(x, y, *z); end

f(a, b, c, d)

we get flow from c to z[0] and d to z[1].

We get false flow if there are positional parameters after the splat parameter. For example in this case:

def g(x, y, *z, w); end

g(a, b, c, d)

we get flow from d to z[0] instead of w.

We also track flow in this case

def f(a, *b)
  sink b[0]
end

f(1, *[taint, 2])

I'm not sure what is causing the DCA OOM failures, and whether it is related to these changes or something else.

@github-actions github-actions bot added the Ruby label Aug 10, 2023
We now precisely track flow from positional arguments to splat
parameters, provided that splat arguments are not used and there are no
positional parameters after the splat parameter. For example, in this
case:

    def f(x, y, *z); end

    f(a, b, c, d)

we get flow from `c` to `z[0]` and `d` to `z[1]`.

We get false flow if there are positional parameters after the splat
parameter. For example in this case:

    def g(x, y, *z, w); end

    g(a, b, c, d)

we get flow from `d` to `z[0]` instead of `w`.

We also track flow in this case

    def f(a, *b)
      sink b[0]
    end

    f(1, *[taint, 2])
Make this class into a proper subclass of `ParameterNodeImpl`, to
prevent some consistency test failures.
@hmac hmac marked this pull request as ready for review August 14, 2023 12:21
@hmac hmac requested a review from a team as a code owner August 14, 2023 12:21
@hmac hmac changed the title More precise flow into splat parameters Ruby: More precise flow into splat parameters Aug 16, 2023
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.

LGTM, I have pushed a small set of review suggestions. Let me know what you think.

@hmac hmac merged commit 222aa41 into github:main Aug 18, 2023
20 checks passed
@hmac hmac deleted the splat-flow-2 branch August 23, 2023 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants