codeql icon indicating copy to clipboard operation
codeql copied to clipboard

Java Get Assignment Node In Dataflow Path

Open KylerKatzUH opened this issue 1 year ago • 2 comments
trafficstars

Hello,

I am analyzing the dataflow paths for some of my queries and noticing some steps are being left out—specifically, the steps related to assignments. For example,

String value1 = "Hello";

String value2 = value1;

print(value2)

The dataflow path for this would be

value1 - from String value1 = "Hello"; value1 - from String value2 = value1; value2 from print(value2)

Is there a way to also have value2 from value1 - from String value2 = value1;` inserted as step 3? So that it is

value1 - from String value1 = "Hello"; value1 - from String value2 = value1; value2 - from String value2 = value1; value2 from print(value2)

So that it is easier to follow the assignments? It's simple in this example, however, it can become confusing in more complex situations.

Thank you

KylerKatzUH avatar Oct 11 '24 21:10 KylerKatzUH

Do you mean you want to see that included in the small steps seen by DataFlow::localFlowStep, or in the large steps seen by the VSCode / SARIF-exposed path? Big steps are defined so that for long paths the user isn't drowned in excessive detail.

If indeed you mean big steps, then you can use predicate neverSkip(Node node) of DataFlow::ConfigSig to specify that a particular node should always terminate a flow big-step.

If you mean small steps (DataFlow::localFlowStep) don't include a node for the assignment LHS, then adding these is a more difficult prospect -- it would mean rewriting DataFlow::basicLocalFlowStep and the definition of DataFlow::Node to rewrite how flow node graphs are generated and connected.

smowton avatar Oct 14 '24 11:10 smowton

Hi @smowton, Thank you for pointing these out I will look into them.

KylerKatzUH avatar Oct 14 '24 18:10 KylerKatzUH