test(flow): cover Java FLOWS_TO edges (#714)#754
Conversation
|
@greptile review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new integration test suite, test_java_flow_e2e.py, to verify Java data flow tracking, including environment variables flowing to stdout, argument passing, return values, and taint killing via reassignment. It also bumps the package version in uv.lock. The reviewer suggested a performance optimization to cache the results of load_parsers() at the module level instead of reloading parsers and queries for every test case, which would speed up the integration test suite.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Greptile SummaryThis PR adds Java end-to-end coverage for
Confidence Score: 5/5Safe to merge with minimal risk. The changes are test-only plus lockfile version alignment, and no functional issues were identified. No files require special attention.
What T-Rex did
Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Test as Java flow test
participant Builder as _build helper
participant Updater as GraphUpdater
participant Graph as Memgraph
Test->>Builder: provide Java snippet
Builder->>Updater: run with IO capture
Updater->>Graph: write FLOWS_TO edges
Test->>Graph: query FLOWS_TO relationships
Graph-->>Test: resource / ARG / RETURN flow rows
Test->>Test: assert expected Java flow behavior
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Test as Java flow test
participant Builder as _build helper
participant Updater as GraphUpdater
participant Graph as Memgraph
Test->>Builder: provide Java snippet
Builder->>Updater: run with IO capture
Updater->>Graph: write FLOWS_TO edges
Test->>Graph: query FLOWS_TO relationships
Graph-->>Test: resource / ARG / RETURN flow rows
Test->>Test: assert expected Java flow behavior
Reviews (2): Last reviewed commit: "test(flow): cover Java FLOWS_TO edges (#..." | Re-trigger Greptile |
|



What
Adds e2e coverage proving Java FLOWS_TO (data-flow / taint edges) works: an env read reaching a print emits
resource -> resource, a tainted local passed to a first-party method emits acaller -> calleeARG edge, and a method returning a tainted value emits acallee -> callerRETURN edge (resolved cross-method through the shared #712 fixpoint).Why no production code changed
The lean non-Python flow walk (
FlowProcessor._process_lean_flow/_flat_flow_walk) already dispatches for any language with an IO sink table and aLanguageDescriptor. Java gained both in #750 (io READS_FROM/WRITES_TO), and the sharedcall_namereconstruction for Javamethod_invocation(nofunctionfield) plusvariable_declarator/assignment_expressionbinding cover the flow shapes with no new code. This PR pins that behavior against regression.Tests (
test_java_flow_e2e.py)test_java_env_flows_to_stdout—System.getenvlocal carried toSystem.out.println: ENV -> STDOUTtest_java_direct_env_argument_flows_to_stdout— env read nested directly in the print calltest_java_tainted_value_arg_edge_to_callee— tainted local passed to a sibling method (ARG edge)test_java_return_taint_edge— method returning a tainted value (RETURN edge to its caller)test_java_reassignment_kills_taint— overwriting the tainted local with a clean literal kills the flowtest_java_untainted_local_no_flow— a plain local emits no resource flowScope
Java uses the flat source-order walk (not in
_HOISTED_DECL_LANGS), matching Go's initial FLOWS_TO increment (#747). Path-sensitivity for the flat-walk languages (Go and Java) remains a separate follow-up.