Conversation
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The foundational CFG and data-flow migration has broad compatibility implications that warrant final human validation.
Review effort: Balanced
Findings: None
What changed in this PR
Migrates GitHub Actions control-flow analysis to the shared CFG framework while retaining compatibility APIs.
Changes:
- Rebuilds CFG scopes, nodes, basic blocks, and data-flow integration on shared infrastructure.
- Corrects environment-expression ownership and adds consistency/regression checks.
- Documents intentional API and raw-CFG compatibility changes.
| File | Description |
|---|---|
actions/ql/lib/codeql/actions/controlflow/internal/Cfg.qll |
Implements the shared CFG integration. |
actions/ql/lib/codeql/actions/controlflow/BasicBlocks.qll |
Adapts existing basic-block APIs. |
actions/ql/lib/codeql/actions/Cfg.qll |
Re-exports the new implementation. |
actions/ql/lib/codeql/actions/dataflow/internal/DataFlowPrivate.qll |
Selects unique injected CFG nodes for data flow. |
actions/ql/lib/change-notes/2026-09-29-shared-cfg.md |
Documents breaking changes. |
actions/ql/consistency-queries/qlpack.yml |
Defines the Actions consistency pack. |
actions/ql/consistency-queries/CfgConsistency.ql |
Enables shared CFG checks. |
actions/ql/test/library-tests/cfg-environment/test.ql |
Tests environment CFG integrity. |
actions/ql/test/library-tests/cfg-environment/test.expected |
Records environment test results. |
actions/ql/test/library-tests/cfg-environment/.github/workflows/test.yml |
Supplies environment ownership cases. |
actions/ql/test/library-tests/basic/test.ql |
Extends CFG API regression coverage. |
actions/ql/test/library-tests/basic/test.expected |
Updates shared-CFG expectations. |
actions/ql/test/query-tests/Security/CWE-078/CONSISTENCY/CfgConsistency.expected |
Records empty consistency findings. |
actions/ql/test/query-tests/Security/CWE-088/CONSISTENCY/CfgConsistency.expected |
Records empty consistency findings. |
actions/ql/test/query-tests/Security/CWE-094/CONSISTENCY/CfgConsistency.expected |
Records empty consistency findings. |
actions/ql/test/query-tests/Security/CWE-829/CONSISTENCY/CfgConsistency.expected |
Records empty consistency findings. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
2e616bb to
c5f521d
Compare
| Callable getEnclosingCallable(AstNode node) { | ||
| result = node.(Callable) | ||
| or | ||
| result = getEnclosingCallable(node.getParentNode()) |
There was a problem hiding this comment.
I don't know about actions, but in most languages this is wrong. If a callable is nested inside another callable then the innermost nodes get 2 enclosing callables.
There was a problem hiding this comment.
I see what you mean. However, for actions, Callable is either a Workflow or a CompositeAction and these are both the root node of the file, so there isn't the kind of nesting you can have in other programming languages. I've added not node instanceof Callable and to make it clearer, as it makes no difference and is easier to understand for those not familiar with actions (which is most of us). I've also updated the QLDoc for getEnclosingCallable to document that it although getParentNode can have multiple results, all paths with give the same root callable.
Actually, it is technically possible to make a file that is both, though no one would do this in practice. I have updated the definition of Callable to always choose CompositeAction in that case. I've added a test for this.
c5f521d to
a913e57
Compare
Replace the legacy Actions CFG implementation with the shared CFG pipeline, keep data-flow nodes canonical, and ensure callable roots are connected without scalar-expression cycles. Co-authored-by: Copilot <[email protected]>
Attach environment expressions once to their declaring workflow, job, or step so shared CFG nodes do not acquire multiple parents or form cycles. Co-authored-by: Copilot <[email protected]>
Prefer the composite-action interpretation when a YAML document is recognized as both a workflow and a composite action, ensuring each CFG node has a unique enclosing callable. Co-authored-by: Copilot <[email protected]>
a913e57 to
755e78b
Compare
Migrates the GitHub Actions control-flow graph to the shared CFG construction library already used by Java, C#, Ruby and Go.
Meaningful CFG changes
Ignoring the synthetic before/after and entry/exit nodes introduced by the shared library, there are two intentional topology changes relative to the old CFG:
Environment expressions are evaluated at their declaration site.
Run,UsesStep, or reusable-workflow job that could consume it. An inherited workflow- or job-level expression could therefore appear under many consumers, giving the same AST node multiple structural parents and successors.envmapping declares it. Consumers no longer become structural CFG parents of inherited expressions.Expressions embedded in run scripts have a single structural path.
Runand a child of the scriptScalarValue, creating duplicate paths to the same AST expression.ScalarValueis now a CFG leaf. Script expressions remain direct children of theRun, so no expression is lost; only the redundant parent/edge is removed.Compatibility
The shared implementation introduces explicit before/after and entry/exit nodes, so code relying on exact raw CFG nodes, edges, textual representations, or basic-block boundaries may need updating.
The obsolete
Completion,NormalCompletion,SimpleCompletion,BooleanCompletion, andReturnCompletionclasses are intentionally removed. Callers should inspect successor edge types such asDirectSuccessor,BooleanSuccessor, andReturnSuccessorinstead. Other established Actions CFG APIs are retained on top of the shared implementation.Commit structure
The history is organized into three independently testable commits: