Skip to content

Go: (Refactor) Use makeSsa for SSA classes - #22857

Open
owen-mc wants to merge 8 commits into
github:mainfrom
owen-mc:go/make-ssa
Open

owen-mc wants to merge 8 commits into
github:mainfrom
owen-mc:go/make-ssa

Conversation

@owen-mc

@owen-mc owen-mc commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread go/ql/lib/semmle/go/dataflow/SSA.qll Fixed
Comment thread go/ql/lib/semmle/go/dataflow/SSA.qll Fixed
Comment thread go/ql/lib/semmle/go/dataflow/SSA.qll Fixed
Comment thread go/ql/lib/semmle/go/dataflow/internal/DataFlowPrivate.qll Fixed
owen-mc and others added 6 commits October 21, 2026 14:22
These tests fail until type-switch implicit variable assignments are modeled as write instructions in the next commit.

Co-authored-by: Copilot <[email protected]>
@owen-mc
owen-mc marked this pull request as ready for review October 21, 2026 13:25
Copilot AI max review requested due to automatic review settings October 21, 2026 13:25
@owen-mc
owen-mc requested a review from a team as a code owner October 21, 2026 13:25

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.

🔵 Needs a closer look

The foundational SSA/IR migration has unresolved behavior and compatibility regressions that need human validation.

3 open issues
What changed in this PR

Refactors Go’s static single-assignment (SSA) analysis to use shared CodeQL classes.

Changes:

  • Migrates data-flow, control-flow, framework models, and queries to definition-based APIs.
  • Adds deprecated compatibility classes and explicit type-switch write targets.
  • Updates test expectations, annotation comments, and migration notes.
File Description
go/​ql/​test/​query-tests/​Security/​CWE-601/​BadRedirectCheck/​BadRedirectCheck.expected Updates parameter labels.
go/​ql/​test/​query-tests/​Security/​CWE-347/​MissingJwtSignatureCheck.expected Updates parameter labels.
go/​ql/​test/​query-tests/​Security/​CWE-326/​InsufficientKeySize.expected Updates labels and section ordering.
go/​ql/​test/​query-tests/​Security/​CWE-322/​InsecureHostKeyCallback.expected Updates parameter labels.
go/​ql/​test/​query-tests/​Security/​CWE-312/​CleartextLogging.expected Updates parameter labels.
go/​ql/​test/​query-tests/​Security/​CWE-079/​StoredXss.expected Updates parameter labels.
go/​ql/​test/​query-tests/​Security/​CWE-022/​ZipSlip.expected Updates parameter labels.
go/​ql/​test/​query-tests/​Security/​CWE-022/​UnsafeUnzipSymlink.expected Updates parameter labels.
go/​ql/​test/​query-tests/​InconsistentCode/​UnhandledCloseWritableHandle/​UnhandledCloseWritableHandle.expected Updates parameter and capture labels.
go/​ql/​test/​library-tests/​semmle/​go/​frameworks/​Twirp/​RequestForgery.expected Updates parameter and capture labels.
go/​ql/​test/​library-tests/​semmle/​go/​frameworks/​gqlgen/​graph/​schema.resolvers.go Updates an expectation comment only.
go/​ql/​test/​library-tests/​semmle/​go/​frameworks/​GoMicro/​main.go Updates an expectation comment only.
go/​ql/​test/​library-tests/​semmle/​go/​frameworks/​GoMicro/​LogInjection.expected Updates request-parameter labels.
go/​ql/​test/​library-tests/​semmle/​go/​frameworks/​GoKit/​main.go Updates expectation comments only.
go/​ql/​test/​library-tests/​semmle/​go/​frameworks/​Beego/​CleartextLogging.expected Updates parameter labels.
go/​ql/​test/​library-tests/​semmle/​go/​dataflow/​SSA/​SsaWithFields.expected Updates definition labels.
go/​ql/​test/​library-tests/​semmle/​go/​dataflow/​SSA/​SsaDefinition.expected Updates definition labels.
go/​ql/​test/​library-tests/​semmle/​go/​dataflow/​SSA/​DefUse.ql Queries definition-based expression reads.
go/​ql/​test/​library-tests/​semmle/​go/​dataflow/​SSA/​DefUse.expected Reflects expression-read results.
go/​ql/​test/​library-tests/​semmle/​go/​dataflow/​FunctionInputsAndOutputs/​FunctionInput_getExitNode.expected Updates parameter labels.
go/​ql/​test/​library-tests/​semmle/​go/​dataflow/​FlowSteps/​LocalFlowStep.expected Updates parameter and capture labels.
go/​ql/​test/​library-tests/​semmle/​go/​dataflow/​ExternalValueFlow/​srcs.expected Updates source-parameter labels.
go/​ql/​test/​library-tests/​semmle/​go/​dataflow/​ExternalTaintFlow/​srcs.expected Updates source-parameter labels.
go/​ql/​test/​experimental/​Unsafe/​WrongUsageOfUnsafe.expected Updates parameter labels.
go/​ql/​test/​experimental/​CWE-522-DecompressionBombs/​DecompressionBombs.expected Updates parameter labels.
go/​ql/​test/​example-tests/​snippets/​typeinfo.expected Updates a parameter label.
go/​ql/​src/​RedundantCode/​DeadStoreOfLocal.ql Uses explicit-write definitions.
go/​ql/​src/​RedundantCode/​DeadStoreOfField.ql Uses the renamed definition predicate.
go/​ql/​src/​InconsistentCode/​WrappedErrorAlwaysNil.ql Uses definition-based reads.
go/​ql/​src/​InconsistentCode/​MissingErrorCheck.ql Migrates phi-input lookup.
go/​ql/​src/​experimental/​IntegerOverflow/​RangeAnalysis.qll Migrates range analysis to shared definitions.
go/​ql/​lib/​semmle/​go/​frameworks/​stdlib/​NetHttp.qll Uses base definitions.
go/​ql/​lib/​semmle/​go/​frameworks/​RsCors.qll Migrates configuration-definition lookup.
go/​ql/​lib/​semmle/​go/​frameworks/​Macaron.qll Uses base definitions.
go/​ql/​lib/​semmle/​go/​frameworks/​GinCors.qll Migrates configuration-definition lookup.
go/​ql/​lib/​semmle/​go/​frameworks/​Fasthttp.qll Uses base definitions.
go/​ql/​lib/​semmle/​go/​frameworks/​Beego.qll Uses base definitions.
go/​ql/​lib/​semmle/​go/​dataflow/​SsaImpl.qll Instantiates shared SSA classes.
go/​ql/​lib/​semmle/​go/​dataflow/​SSA.qll Exports shared classes and compatibility wrappers.
go/​ql/​lib/​semmle/​go/​dataflow/​internal/​DataFlowUtil.qll Accepts definitions in the SSA-node helper.
go/​ql/​lib/​semmle/​go/​dataflow/​internal/​DataFlowPrivate.qll Migrates local flow and capture handling.
go/​ql/​lib/​semmle/​go/​dataflow/​internal/​DataFlowNodes.qll Integrates shared definitions into flow nodes.
go/​ql/​lib/​semmle/​go/​dataflow/​GlobalValueNumbering.qll Uses shared explicit-write definitions.
go/​ql/​lib/​semmle/​go/​controlflow/​IR.qll Models type-switch write targets.
go/​ql/​lib/​semmle/​go/​controlflow/​Guards.qll Reuses shared SSA classes.
go/​ql/​lib/​semmle/​go/​controlflow/​ControlFlowGraph.qll Renames the definition predicate.
go/​ql/​lib/​change-notes/​2026-10-20-shared-ssa.md Documents the breaking API migration.

Review effort: Max

Comment thread go/ql/lib/semmle/go/dataflow/SSA.qll
Comment thread go/ql/lib/semmle/go/dataflow/SSA.qll Outdated
Comment thread go/ql/lib/semmle/go/dataflow/internal/DataFlowNodes.qll Outdated

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.

Comment on lines +143 to 147
/** Holds if this node defines SSA definition `def` to be `rhs`. */
predicate definesSsaDefinition(SsaDefinition def, DataFlow::Node rhs) {
super.getLhs().asSsaDefinition() = def and
super.getRhs() = rhs.asInstruction()
}
Comment on lines +1141 to +1142
/** Gets the SSA definition being written to, if any. */
SsaDefinition asSsaDefinition() { this.getWrite() = result.(SsaExplicitWrite).getDefinition() }
* corresponding to `a.b`.
*/
SsaVariable getBaseVariable() {
SsaDefinition getBaseDefinition() {
Comment on lines +990 to +991
predicate readsSsaDefinition(SsaDefinition def) {
exists(SsaNode ssa | ssa.getDefinition() = def and this = ssa.getAUse())

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.

3 participants