Repository navigation
Go: Use DataFlowIntegration for local SSA flow
#23130
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
owen-mc
wants to merge
11
commits into
github:main
Choose a base branch
from
owen-mc:go/data-flow-integration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a4696ec
Go: Exclude non-rvalue expressions from IR variable reads
owen-mc 6a56b3b
Go: Test interface dispatch, nil checks, and cleartext logging across…
owen-mc ba05e20
Go: Prepare local analyses and sources for SSA merge and cycle edges
owen-mc 334e222
Go: Use DataFlowIntegration for local SSA flow
owen-mc 67b2034
Go: Add SSA consistency checks
owen-mc e053d3e
Go: Refactor to reduce duplication
owen-mc 646eeee
Go: Fix two bad join orders
owen-mc a2c8ee9
Improve change note
owen-mc c9ea2e6
Edit change note
owen-mc 242992f
Improve tests
owen-mc 20ecb21
Go: Remove unused post-update flow into SSA writes
owen-mc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| import go | ||
| import semmle.go.dataflow.SsaImpl | ||
| import Consistency | ||
| import DataFlowIntegration::DfConsistency |
4 changes: 4 additions & 0 deletions
4
go/ql/lib/change-notes/2026-11-18-ssa-data-flow-integration.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: minorAnalysis | ||
| --- | ||
| * Local SSA data flow now uses the shared `DataFlowIntegration` library, improving performance in pathological cases by avoiding quadratic growth in use-to-use flow edges. `DataFlow::localFlowStep` and `TaintTracking::localTaintStep` may now step through intermediate SSA phi and synthetic merge-read nodes at control-flow joins rather than directly between uses across branches. Local flow can also enter uncertain SSA definitions of captured variables from preceding definitions or reads. Phi and synthetic merge-read nodes are hidden from global path explanations. |
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
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
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
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
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
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
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
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
4 changes: 4 additions & 0 deletions
4
go/ql/test/experimental/CWE-942/CONSISTENCY/SsaConsistency.expected
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| uselessPhiNode | ||
| | CorsMisconfiguration.go:13:1:229:1 | SSA phi(allowedOrigins) | 1 | | ||
| phiWithoutTwoPriorRefs | ||
| | CorsMisconfiguration.go:13:1:229:1 | SSA phi(allowedOrigins) | CorsMisconfiguration.go:13:1:229:1 | Exceptional Exit | CorsMisconfiguration.go:94:3:94:16 | allowedOrigins | 1 | |
4 changes: 4 additions & 0 deletions
4
.../library-tests/semmle/go/controlflow/ControlFlowGraph/CONSISTENCY/SsaConsistency.expected
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| uselessPhiNode | ||
| | epilogues.go:89:3:91:3 | SSA phi(result) | 1 | | ||
| phiWithoutTwoPriorRefs | ||
| | epilogues.go:89:3:91:3 | SSA phi(result) | epilogues.go:89:3:91:3 | After if statement | epilogues.go:87:30:87:35 | result | 1 | |
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
Empty file.
3 changes: 3 additions & 0 deletions
3
go/ql/test/library-tests/semmle/go/dataflow/InterfaceDispatch/Flows.ql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import go | ||
| import utils.test.InlineFlowTest | ||
| import ValueFlowTest<DefaultFlowConfig> |
10 changes: 10 additions & 0 deletions
10
go/ql/test/library-tests/semmle/go/dataflow/InterfaceDispatch/Targets.expected
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| | capturedOverwrite | main.go:20:7:20:15 | call to Greet | main.go:3:6:3:12 | Greeter | | ||
| | capturedOverwrite | main.go:20:7:20:15 | call to Greet | main.go:7:6:7:16 | SafeGreeter | | ||
| | capturedOverwrite | main.go:20:7:20:15 | call to Greet | main.go:8:6:8:19 | TaintedGreeter | | ||
| | overwriteLoop | main.go:38:7:38:15 | call to Greet | main.go:7:6:7:16 | SafeGreeter | | ||
| | overwriteLoop | main.go:38:7:38:15 | call to Greet | main.go:8:6:8:19 | TaintedGreeter | | ||
| | readOnlyLoop | main.go:27:8:27:16 | call to Greet | main.go:7:6:7:16 | SafeGreeter | | ||
| | readOnlyLoop | main.go:30:7:30:15 | call to Greet | main.go:7:6:7:16 | SafeGreeter | | ||
| | unknownReceiver | main.go:45:7:45:15 | call to Greet | main.go:3:6:3:12 | Greeter | | ||
| | unknownReceiver | main.go:45:7:45:15 | call to Greet | main.go:7:6:7:16 | SafeGreeter | | ||
| | unknownReceiver | main.go:45:7:45:15 | call to Greet | main.go:8:6:8:19 | TaintedGreeter | |
9 changes: 9 additions & 0 deletions
9
go/ql/test/library-tests/semmle/go/dataflow/InterfaceDispatch/Targets.ql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import go | ||
| import semmle.go.dataflow.internal.DataFlowDispatch | ||
|
|
||
| from DataFlow::CallNode call, Callable target | ||
| where | ||
| call.getTarget().getName() = "Greet" and | ||
| target = viableCallable(call.asExpr()).asCallable() | ||
| select call.getEnclosingCallable().getName(), call, | ||
| target.asFunction().(Method).getReceiverBaseType() |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these two cases jointly cover exactly
SsaFlow::SsaNode. So they could be replaced byUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your suggestion would drop phi definitions that the shared flow graph bypasses when their next adjacent use is unique, because they don't have a
SsaFlow::SsaNode. I checked and found three places we expect to be able to find anSsaNodefor a phi definition. I could change those places to useSsaDefinitiondirectly instead, if you think it's worth it, but I'd rather do it in a follow-up PR.