Skip to content

Java: static field access of unknown class breaks dataflow (build-mode=none) #19597

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

Open
odipar opened this issue May 27, 2025 · 0 comments
Open
Labels
question Further information is requested

Comments

@odipar
Copy link

odipar commented May 27, 2025

This is another issue we encountered when analysing databases created with build-mode=none.
It appears that dataflow graphs are broken when static fields are accessed on unknown classes.
Please take a look codeql_issue2.zip for more information.

Here is the example java code:

// This import is from a dependency that is not resolved
import com.foo.mycompany.UnknownClass;

public class DataFlowNotConnected {
    static class MyClass {
        public static String staticField = "static";
    }

    private int run() {
        // data source 1 should flow to sink e and f, but dataflow is broken by UnknownClass.staticField
        int a = 1;
        int b = a;

        // static class field access from known class
        String staticField1 = MyClass.staticField;

        int c = b;
        int d = c;

        // static class field access from unknown class breaks dataflow
        String staticField2 = UnknownClass.staticField;

        int e = d;
        int f = e;

        return f;
    }
}
@odipar odipar added the question Further information is requested label May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant