Java dataflow configuration - redirecting method calls made to subinterfaces #19665
-
Hi, When doing dataflow analysis in Java, is it possible to "redirect" calls made to a method on a subinterface to a specific implementation? I'm working in a microservices codebase where each service's client has interfaces that are generally organised like this;
The actual plumbing/implementation differences between sync and async calls happens at the transport layer (and is not relevant to my analysis), so on the server side only a single implementation exists for
Dataflow analysis is working out of the box as expected in simple cases where the base interface is used and the corresponding implementation can be found
However I also want CodeQL to follow the flow in these scenarios where a subinterface is used, and guide it to the implementation found in
And
I've tried (and failed 😭) for a a few hours now to define an |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Maybe I'm missing something, so let me see if I got things straight. In |
Beta Was this translation helpful? Give feedback.
Yes, you can do that by wiring up individual arguments to the corresponding parameter nodes, but beware that call context will be lost so you lose some precision. Similarly, you'd need to wire up return values to the output of the call. In your snippet above you'd use something like
n1.asExpr() = call.getArgument(pos) and n2.asParameter() = impl.getParameter(pos)
. It's not exactly pretty nor something I'd recommend, but it could maybe work for you.