Skip to content

Go: Use DataFlowIntegration for local SSA flow - #23130

Open
owen-mc wants to merge 8 commits into
github:mainfrom
owen-mc:go/data-flow-integration
Open

owen-mc wants to merge 8 commits into
github:mainfrom
owen-mc:go/data-flow-integration

Conversation

@owen-mc

@owen-mc owen-mc commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Use the shared DataFlowIntegration library for Go’s local SSA flow, following the earlier migration to MakeSsa.

This preserves Go’s field-sensitive barrier guards and closure flow, defines SsaNode.getBasicBlock, and hides internal merge nodes from path explanations.

Because local flow now steps through SSA merge and cycle edges, adapt interface dispatch, go/impossible-interface-nil-check, and go/clear-text-logging to preserve existing behavior.

Also exclude non-rvalue expressions from IR::EvalInstruction.reads and enable SSA consistency checks (remaining single-input phi findings come from synthetic exit reads used to retain captured definitions, which will be removed soon when Go adopts to the shared variable capture library).

DCA looks neutral.

@github-actions github-actions Bot added the Go label Nov 13, 2026
@owen-mc
owen-mc force-pushed the go/data-flow-integration branch from f3daf4e to 135d102 Compare November 13, 2026 16:49
owen-mc and others added 5 commits November 18, 2026 16:45
Do not treat select-receive assignment targets or other pure lvalues as variable reads in EvalInstruction.reads, matching ReadInstruction.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… merges

Record pre-migration behavior across SSA merges, loops, and captured overwrites before switching local SSA flow to DataFlowIntegration.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Propagate unknown or possibly nil origins through SSA cycles and uncertain writes in interface dispatch and nil checks, and exclude SSA phi definitions from cleartext logging variable sources.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use the shared DataFlowIntegration library for local SSA flow while preserving Go's field-sensitive barrier guards and closure flow, hiding synthetic SSA merge nodes from paths, and defining SsaNode.getBasicBlock.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Enable shared SSA and DataFlowIntegration consistency queries and record the remaining capture-retention exit-read phi baselines.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@owen-mc
owen-mc force-pushed the go/data-flow-integration branch from 5ff21cd to 646eeee Compare November 19, 2026 09:36
@owen-mc
owen-mc marked this pull request as ready for review November 19, 2026 09:48
@owen-mc
owen-mc requested a review from a team as a code owner November 19, 2026 09:48
@owen-mc
owen-mc requested review from aschackmull and an adaptive review from Copilot November 19, 2026 09:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Existing FlowSteps expectations are stale because loop-header phi edges are now retained, and the change note incorrectly claims local-flow reachability is unchanged.

2 open issues
What changed in this PR

Migrates Go’s local SSA data flow to the shared DataFlowIntegration library, building on the earlier MakeSsa migration.

Changes:

  • Connects shared SSA nodes and flow steps while preserving Go’s barrier guards and closure flow.
  • Adapts interface dispatch, nil checks, and clear-text logging to merge and cycle edges.
  • Adds regression coverage, enables SSA consistency checks, and documents the changes.
File Description
go/​ql/​test/​query-tests/​Security/​CWE-643/​CONSISTENCY/​SsaConsistency.expected Records known phi consistency diagnostics.
go/​ql/​test/​query-tests/​Security/​CWE-312/​passwords.go Tests password flow through branch merges.
go/​ql/​test/​query-tests/​Security/​CWE-312/​CleartextLogging.expected Records merged-password alerts and paths.
go/​ql/​test/​query-tests/​RedundantCode/​ImpossibleInterfaceNilCheck/​ssa.go Tests loops, typed nils, and captured writes.
go/​ql/​test/​query-tests/​RedundantCode/​ImpossibleInterfaceNilCheck/​ImpossibleInterfaceNilCheck.expected Records expected nil-check alerts.
go/​ql/​test/​library-tests/​semmle/​go/​frameworks/​Twirp/​CONSISTENCY/​SsaConsistency.expected Records Twirp phi consistency diagnostics.
go/​ql/​test/​library-tests/​semmle/​go/​dataflow/​SSADataFlowIntegration/​main.go Adds merge, loop, closure, and guard fixtures.
go/​ql/​test/​library-tests/​semmle/​go/​dataflow/​SSADataFlowIntegration/​HiddenNodes.ql Checks that internal SSA nodes stay hidden from paths.
go/​ql/​test/​library-tests/​semmle/​go/​dataflow/​SSADataFlowIntegration/​HiddenNodes.expected Records flow counts and hidden-node checks.
go/​ql/​test/​library-tests/​semmle/​go/​dataflow/​SSADataFlowIntegration/​Flows.ql Checks value flow, barriers, and node regions.
go/​ql/​test/​library-tests/​semmle/​go/​dataflow/​SSADataFlowIntegration/​Flows.expected Records successful flow and region checks.
go/​ql/​test/​library-tests/​semmle/​go/​dataflow/​SSADataFlowIntegration/​CONSISTENCY/​SsaConsistency.expected Records known capture-related phi diagnostics.
go/​ql/​test/​library-tests/​semmle/​go/​dataflow/​InterfaceDispatch/​Targets.ql Queries viable interface-call targets.
go/​ql/​test/​library-tests/​semmle/​go/​dataflow/​InterfaceDispatch/​Targets.expected Records expected dispatch targets.
go/​ql/​test/​library-tests/​semmle/​go/​dataflow/​InterfaceDispatch/​main.go Adds loop and closure dispatch fixtures.
go/​ql/​test/​library-tests/​semmle/​go/​dataflow/​InterfaceDispatch/​Flows.ql Runs interface-dispatch flow checks.
go/​ql/​test/​library-tests/​semmle/​go/​dataflow/​InterfaceDispatch/​Flows.expected Records no inline flow-test failures.
go/​ql/​test/​library-tests/​semmle/​go/​controlflow/​ControlFlowGraph/​CONSISTENCY/​SsaConsistency.expected Records an epilogue phi diagnostic.
go/​ql/​test/​experimental/​CWE-942/​CONSISTENCY/​SsaConsistency.expected Records a captured-variable phi diagnostic.
go/​ql/​src/​RedundantCode/​ImpossibleInterfaceNilCheck.ql Handles SSA cycles and uncertain writes.
go/​ql/​lib/​semmle/​go/​security/​CleartextLoggingCustomizations.qll Excludes phi definitions from password sources.
go/​ql/​lib/​semmle/​go/​dataflow/​SsaImpl.qll Configures and exposes shared SSA flow integration.
go/​ql/​lib/​semmle/​go/​dataflow/​internal/​DataFlowUtil.qll Consolidates barrier-node lookup.
go/​ql/​lib/​semmle/​go/​dataflow/​internal/​DataFlowPrivate.qll Uses shared flow steps and hides merge nodes.
go/​ql/​lib/​semmle/​go/​dataflow/​internal/​DataFlowNodes.qll Maps shared SSA nodes and supplies basic blocks.
go/​ql/​lib/​semmle/​go/​dataflow/​internal/​DataFlowDispatch.qll Handles cyclic flow and unknown receiver origins.
go/​ql/​lib/​semmle/​go/​controlflow/​IR.qll Restricts expression reads to rvalues.
go/​ql/​lib/​change-notes/​2026-11-18-ssa-data-flow-integration.md Documents flow and basic-block changes.
go/​ql/​consistency-queries/​SsaConsistency.ql Enables shared SSA consistency checks.

Review effort: Max (adaptive)

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants