Python: DCA validation baseline for rebased shared-SSA adapter - #153
Draft
yoff wants to merge 11 commits into
Draft
Python: DCA validation baseline for rebased shared-SSA adapter#153yoff wants to merge 11 commits into
yoff wants to merge 11 commits into
Conversation
Preparatory refactor for the shared-CFG dataflow migration. Adds the new Python SSA adapter additively, without changing any production behaviour. Library additions: - semmle.python.dataflow.new.internal.SsaImpl — Python SSA implementation built on the new (shared) CFG. Mirrors the Java SSA adapter (java/ql/lib/semmle/code/java/dataflow/internal/SsaImpl.qll): an InputSig is defined in terms of positional (BasicBlock, int) variable references, and the shared codeql.ssa.Ssa::Make<Location, Cfg, Input> module is then instantiated. SourceVariable is the AST-level Py::Variable. Variable references are looked up via the new CFG facade's NameNode.defines/uses/deletes predicates (added in the preceding PR), which themselves are one-line bridges to AST-level Name.defines/uses/deletes. Implicit-entry definitions are inserted for non-local/global/builtin reads, captured variables, and (when needed) parameters. Test additions: - library-tests/dataflow-new-ssa/ — exercises the new SSA over a representative test corpus and checks expected def/use chains. - library-tests/dataflow-new-ssa-vs-legacy/ — runs both new SSA and legacy ESSA over the same corpus and diffs the results, so any semantic divergence shows up as a test failure. Production impact: None. The new SSA adapter has zero callers in lib/ and src/ — the legacy ESSA SSA (semmle/python/essa/*) remains the default. The dataflow library is not migrated yet; that lands in a follow-up PR. Verified by: - All 367 lib + src + consistency-queries compile clean. - All 641 ControlFlow + PointsTo + dataflow + essa + consistency library-tests pass. - Both new dataflow-new-ssa[/vs-legacy] test packs pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- part of the ESSA adapter layer still refers to the raw SSA (now called Impl)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
DCA validation baseline
This draft is an experiment-only baseline for DCA validation. It is not a merge proposal.
Immutable base
yoff-python-main-22380-dca-snapshot1fe0cb5f172c24d40b02fd70fcea69e83618be33(exact upstreamgithub/codeqlmainsnapshot)54415ad446366d6cfe456d55a1fd8b449a0d90e1.Source
Rebased from the current open, non-draft upstream PR github#21923 without modifying it:
yoff-fix-shared-cfg-ssa-regressions3dfc77e96f525dc742953e7b97e18cd514dcae78yoff/python-add-new-ssaf49429a4c4fa9c1676ecb70e4ee47bb0d446823aIncluded additive content
semmle.python.dataflow.new.internal.SsaImpl.SsaTestinline def/use/phi/exit-use coverage.CmpTestcontract comparison against legacy ESSA.The aggregate patch is byte-for-byte equivalent to the unique additive patch from the exact github#21923 base/head range and is present exactly once.
Exclusions and adaptations
Tests
codeql query format --check-only -- python/ql/lib/semmle/python/dataflow/new/internal/SsaImpl.qll python/ql/test/library-tests/dataflow-new-ssa/SsaTest.ql python/ql/test/library-tests/dataflow-new-ssa-vs-legacy/CmpTest.qlcodeql test run --search-path . -- python/ql/test/library-tests/dataflow-new-ssa python/ql/test/library-tests/dataflow-new-ssa-vs-legacySsaTest.ql: passedCmpTest.ql: passedStack metadata is intentionally not registered at this layer.