Repository navigation
Make DataFlowNode locations deterministic by construction (private constructor) - #11953
Merged
Merged
Conversation
Taint resolution previously ran a fixed 40-round BFS and stopped at a hard-coded nesting limit, so flows longer than 40 hops were silently missed and the round count was unrelated to convergence. Run to a true fixed point instead: loop while sources and sinks remain, relying on the existing (id, taints) visited guard -- whose state space is finite -- to guarantee termination. This removes the resolution-depth limit entirely, so deep taint flows are no longer missed. Propagation semantics are otherwise unchanged: each (id, taints) state is explored exactly as before. Adds tests for a flow deeper than the old 40-hop cap (via plain assignments and via a chain of distinct specialized function calls) and for a sanitized array value that must not be reported. Co-Authored-By: Claude Opus 4.8
Restrict resolution to the sub-graph from which a sink is actually reachable, via a backward reachability pass from the sinks over the forward edges: a node from which no sink is reachable can never produce an issue, so propagating taint into it is wasted work. On real codebases the full taint graph is huge while this relevant sub-graph is tiny, which is what keeps running to convergence cheap. Specialized and unspecialized nodes are linked both by their authoritative unspecialized_id field and by the id-string separator, so the prune never drops a node whose specialized or de-specialized form can reach a sink (the resolution walk maps freely between the two). Co-Authored-By: Claude Opus 4.8
When analysis runs across forked workers, each builds a partial DataFlowGraph the parent merges with `+=` (first value per key wins). The same node id could be created at several sites with different code_locations and sink taints, so which survived the merge depended on worker scheduling. Since a taint issue is reported at its node's code_location, this shifted reported locations and per-file occurrence counts between identical runs, so baselined issues silently reappeared and --set-baseline never converged. Make a node's location and sink taints a pure function of its identity: * getForCallableArg()/getForCallableReturn() no longer accept an independent CodeLocation (breaking). A callable node has no storage to derive a canonical location from, so its location is now always its specialization (the callsite), which is already part of the node id. * getForMethodArgument() derives its sink taints from the parameter's storage rather than a caller-supplied argument (breaking). * The inherited-method return-node kind is dropped: MethodCallReturnType- Fetcher always builds return nodes via getForMethodReturn(), resolving the declaring storage, so the location is the canonical return location wherever the id is produced. Co-Authored-By: Claude Opus 4.8
The argument sink node id (`Class::method#offset`) is shared by every call of the method, so its location must be a function of that identity. When the caller has no storage in hand (e.g. an inherited method has no storage under its own id), resolve the declaring method's storage from the cased method id itself, rather than leaving the location unset here and letting it differ between the forked-worker graphs. Every site that mints the node then agrees on the canonical parameter location. Co-Authored-By: Claude Opus 4.8
Add withSpecialization() and withFlow() to DataFlowNode and use them in TaintFlowGraph and VariableUseGraph in place of `new DataFlowNode(...)`, so a node re-keyed or advanced during resolution carries its location, label and identity-derived fields over from an existing node unchanged rather than having them re-supplied by the caller. Also fold a taint source/sink's location into its id (as getForAssignment() already does), so the same $taint_id reused at several sites maps to one location per site; the human-readable label keeps the bare $taint_id. This removes every remaining external `new DataFlowNode(...)`, preparing the constructor to be made private. Co-Authored-By: Claude Opus 4.8
With every construction now going through a factory, make __construct private so a CodeLocation can only reach a node through a factory that derives it deterministically from the node's identity. This structurally enforces the invariant that a node's location is a pure function of its id, which is what makes taint findings reproducible across forked workers. Document the invariant on the class. External code (including plugins) can no longer `new DataFlowNode(...)` -- hence a breaking change. Co-Authored-By: Claude Opus 4.8
This was referenced Sep 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on the previous PR to enforce, structurally, that a node's location is a pure function of its id.
withSpecialization()andwithFlow(), used inTaintFlowGraphandVariableUseGraphin place ofnew DataFlowNode(...), so a node re-keyed or advanced during resolution carries its location/label/identity over from an existing node unchanged. Also folds a taint source/sink's location into its id (asgetForAssignment()already does). This removes every remaining externalnew DataFlowNode(...).__constructbecomes private so aCodeLocationcan only reach a node through a factory that derives it deterministically from the node's identity. The class-level invariant is documented. External code (including plugins) can no longernew DataFlowNode(...).TaintTest passes unchanged.
Part 3 of a 4-PR stack. Stacked on #11952 — review/merge that first; the diff here includes its commits until it merges.
🤖 Generated with Claude Code