Title: Python: add new shared-CFG-backed control flow graph (additive) by yoff · Pull Request #21921 · github/codeql · GitHub
Open Graph Title: Python: add new shared-CFG-backed control flow graph (additive) by yoff · Pull Request #21921 · github/codeql
X Title: Python: add new shared-CFG-backed control flow graph (additive) by yoff · Pull Request #21921 · github/codeql
Description: Summary Preparatory refactor for the shared-CFG dataflow migration (#21894). Based on #21920 — merge that first. Adds the new Python CFG library additively, without changing any production behaviour. Library additions semmle.python.controlflow.internal.AstNodeImpl — mediates between the Python AST and the shared codeql.controlflow.ControlFlowGraph signature. Wraps Python's Stmt/Expr/Scope/Pattern and adds two synthetic kinds of node (BlockStmt for body slots, intermediate nodes for multi-operand boolean expressions). semmle.python.controlflow.internal.Cfg — public facade re-exposing the same API surface as semmle/python/Flow.qll (ControlFlowNode, CallNode, BasicBlock, NameNode, DefinitionNode, CompareNode, ...), backed by the shared CFG. Intended as a drop-in replacement for use by the upcoming dataflow migration. lib/printCfgNew.ql — debug/visualisation query for the new CFG. consistency-queries/CfgConsistency.ql — runs the shared CFG's standard structural checks against Python. Shared library shared/controlflow/.../ControlFlowGraph.qll — adds two defaulted predicates getWhileElse / getForeachElse to AstSig so Python can model while-else / for-else. The defaults are none(), so existing languages are unaffected. Test additions ControlFlow/bindings/* — annotation-driven SSA-binding tests for the new CFG (annassign, compound, comprehension, decorated, except_handler, imports, match_pattern, parameters, simple, type_params, walrus_starred, with_stmt, dead_under_no_raise). ControlFlow/store-load/* — basic store/load coverage. ControlFlow/evaluation-order/NewCfg*.ql — mirrors of the existing OldCfg evaluation-order self-validation suite, run against the new CFG via NewCfgImpl.qll. Minor extensions to existing test_if.py / test_boolean.py plus cosmetic .expected churn on a handful of OldCfg tests (to add more annotation coverage). Production impact None. No dataflow, SSA, or production query is migrated yet — that lands in follow-up PRs. The new CFG library has zero callers in lib/ and src/ after this PR. Verification All 367 lib/ + src/ + consistency-queries/ queries compile clean. All 56 ControlFlow library-tests pass. All 474 dataflow + PointsTo library-tests + consistency tests pass. syntax_error/CONSISTENCY/CfgConsistency passes. Notes for reviewers AstNodeImpl.qll is the bulk of the new code (~1.7k LOC) and is the file most worth careful review. Most of it is the AST→CFG mapping table (getChild, isExpressionNode, beginAbruptCompletion, etc.) plus the synthetic BlockStmt newtype. Cfg.qll is the facade and is mostly mechanical class-by-class shadowing of Flow.qll's public API on top of the shared library.
Open Graph Description: Summary Preparatory refactor for the shared-CFG dataflow migration (#21894). Based on #21920 — merge that first. Adds the new Python CFG library additively, without changing any production behaviou...
X Description: Summary Preparatory refactor for the shared-CFG dataflow migration (#21894). Based on #21920 — merge that first. Adds the new Python CFG library additively, without changing any production behaviou...
Opengraph URL: https://github.com/github/codeql/pull/21921
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:14e31222-c063-0e6b-4af4-59a1e61ce475 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 94FE:2EB4CD:29229CB:38BEB4F:6A4EFC57 |
| html-safe-nonce | 4f8d3976d09e3a8d4494bad7ff628b4f740a0d15e74769c52225e7b2255c203c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NEZFOjJFQjRDRDoyOTIyOUNCOjM4QkVCNEY6NkE0RUZDNTciLCJ2aXNpdG9yX2lkIjoiMTI5NjgxNDY0ODk1MjAyODI0NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 12ee01ecf624bb95ba6bc615c1fd2c5afa050a8a407912eccfe4b0c6efcb4268 |
| hovercard-subject-tag | pull_request:3780721054 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/github/codeql/pull/21921/files |
| twitter:image | https://avatars.githubusercontent.com/u/647347?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/647347?s=400&v=4 |
| og:image:alt | Summary Preparatory refactor for the shared-CFG dataflow migration (#21894). Based on #21920 — merge that first. Adds the new Python CFG library additively, without changing any production behaviou... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/github/codeql git https://github.com/github/codeql.git |
| octolytics-dimension-user_id | 9919 |
| octolytics-dimension-user_login | github |
| octolytics-dimension-repository_id | 143040428 |
| octolytics-dimension-repository_nwo | github/codeql |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 143040428 |
| octolytics-dimension-repository_network_root_nwo | github/codeql |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2b8f23afb982271f1b22258a94aede67a6b77760 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width