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

Flow between two methods marks two sources instead of one #74

Open
BoykoAlex opened this issue Jan 5, 2025 · 4 comments
Open

Flow between two methods marks two sources instead of one #74

BoykoAlex opened this issue Jan 5, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@BoykoAlex
Copy link
Contributor

See below:

import java.util.LinkedList;
class Test {
    void test() {
        Integer x = Integer.parseInt("10");
        LinkedList<Integer> l = /*~~(source)~~>*/new LinkedList<>();
        LinkedList<Integer> m = /*~~(source)~~>*/new LinkedList<>();
        System.out.println(x);
        System.out.println(m);
        System.out.println(/*~~>*/l);
        /*~~(sink)~~>*/l.remove();
    }
}

The test is:

    @Test
    void taintFlowBetweenArgumentsAndSubject_FakeSource() {
        rewriteRun(
          spec -> spec.recipe(new FindFlowBetweenMethods(
              "java.util.LinkedList <constructor>()",
              true,
              "java.util.LinkedList remove()",
              true,
              "Both",
              "Taint"
            )
          ),
          //language=java
          java(
            """
              import java.util.LinkedList;
              class Test {
                  void test() {
                      Integer x = Integer.parseInt("10");
                      LinkedList<Integer> l = new LinkedList<>();
                      LinkedList<Integer> m = new LinkedList<>();
                      System.out.println(x);
                      System.out.println(m);
                      System.out.println(l);
                      l.remove();
                  }
              }
              """,
            """
              import java.util.LinkedList;
              class Test {
                  void test() {
                      Integer x = Integer.parseInt("10");
                      LinkedList<Integer> l = /*~~(source)~~>*/new LinkedList<>();
                      LinkedList<Integer> m = new LinkedList<>();
                      System.out.println(x);
                      System.out.println(m);
                      System.out.println(/*~~>*/l);
                      /*~~(sink)~~>*/l.remove();
                  }
              }
              """
          )
        );
    }
@BoykoAlex BoykoAlex added the bug Something isn't working label Jan 5, 2025
@timtebeek timtebeek moved this to Backlog in OpenRewrite Jan 5, 2025
@timtebeek
Copy link
Contributor

Ah wow, that's a bug indeed, thanks for reporting it. Had you already explored a cause?

@BoykoAlex
Copy link
Contributor Author

I've tried during the holidays but gave that up ;-) Going away for a week now. If you'd like me to get to the bottom of it let me know - I can resume my investigation upon return.
I also tried to reproduce the issue with the Gradle build file with the same recipe but my unit test has passed so far... (if you recall i had an issue with Gradle build file with the same recipe... just couldn't convert my issue into a unit test yet ;-)

@timtebeek
Copy link
Contributor

Thanks and enjoy your time off first! I must say I'm not too familiar with the code here, but perhaps @JLLeitschuh can provide some guidance (although he's traveling as well). Any help appreciated. What's the wider use case you're after here? Perhaps there's alternatives still.

@JLLeitschuh
Copy link
Contributor

Fascinating! I have no idea what's going on here. I'd need to fire up the debugger to drill into what's going on here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

3 participants