Commit 85ba647
Python: switch dataflow library to new (shared) CFG + SSA
Flips the Python dataflow trunk from the legacy CFG (semmle/python/Flow.qll)
and legacy ESSA SSA (semmle/python/essa/*) to the new shared CFG facade
(semmle.python.controlflow.internal.Cfg) and the new SSA adapter
(semmle.python.dataflow.new.internal.SsaImpl), both introduced
additively in the preceding PRs in this stack.
This is the trunk-flip equivalent of the original draft PR #21894 (kept
around as documentation), rebased on top of the four preparatory PRs:
P1: Remove AstNode.getAFlowNode() and rewrite callers (#21919).
P2: Qualify Flow.qll's AST references with Py:: prefix (#21920).
P3: Add new shared-CFG-backed control flow graph (#21921).
P4: Add new shared-SSA-backed SSA adapter (#21923).
The Python dataflow library (semmle/python/dataflow/new/) now imports
the new CFG facade and SSA adapter. All CFG-typed predicates
(ControlFlowNode, CallNode, BasicBlock, NameNode, AttrNode, ...) are
qualified with the Cfg:: prefix; SSA references switch from
EssaVariable/EssaDefinition to SsaImpl::Definition/SourceVariable.
GuardNode is redesigned to use the new CFG's outcome-node model
(isAfterTrue / isAfterFalse) instead of the legacy ConditionBlock +
flipped indirection. Only BarrierGuard<...> is preserved as public
API.
Framework files (Bottle, FastApi, Django, Tornado, Pyramid, Stdlib,
...) are updated to take CFG nodes from the new facade.
A handful of dataflow consistency tweaks for the new CFG:
- Augmented-assignment targets are treated as both load and store.
- 'from X import *' produces uncertain SSA writes for unknown names.
- CFG nodes are canonicalised so dataflow does not see equivalent
pre/post-order pairs as distinct nodes.
Two AST tweaks for the new CFG:
- AstNodeImpl: omit PEP 695 type-parameter names from
FunctionDefExpr / ClassDefExpr children.
- ImportResolution: drop the legacy essa import.
Test churn (~175 files): reblessed library- and query-test .expected
files reflect slightly different CFG granularity, different toString
output, and a handful of true alert deltas in security queries.
Verification: all 367 lib + src + consistency-queries compile clean.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 5ec5178 commit 85ba647
256 files changed
Lines changed: 6457 additions & 6176 deletions
File tree
- python/ql
- consistency-queries
- lib
- change-notes
- semmle/python
- controlflow/internal
- dataflow/new
- internal
- frameworks
- Stdlib
- internal
- regexp/internal
- security/dataflow
- utils/test/dataflow
- src
- Exceptions
- Expressions
- Functions
- Resources
- Security
- CWE-020-ExternalAPIs
- CWE-079
- CWE-327
- CWE-798
- Statements
- experimental
- Security
- CWE-022bis
- CWE-340
- CWE-346
- CWE-770
- semmle/python/security/injection
- meta/analysis-quality
- semmle/python/functions
- test
- 2/query-tests
- Exceptions
- generators
- raising
- Expressions
- experimental
- attrs
- import-resolution-namespace-relative
- import-resolution
- library-tests
- CallGraph-type-annotations
- CallGraph
- code
- FindSubclass
- meta
- query-tests/Security
- CWE-022-TarSlip
- CWE-022-UnsafeUnpacking
- CWE-074-RemoteCommandExecution
- CWE-079
- CWE-091-XsltInjection
- CWE-094
- CWE-1236
- CWE-1427-PromptInjection
- CWE-176
- CWE-208
- TimingAttackAgainstHash
- TimingAttackAgainstHeaderValue
- TimingAttackAgainstSensitiveInfo
- CWE-287-ConstantSecretKey
- CWE-287
- CWE-327-UnsafeUsageOfClientSideEncryptionVersion
- CWE-338
- CWE-346
- CWE-347
- CWE-348
- CWE-409
- CWE-522
- CWE-611-SimpleXmlRpcServer
- CWE-770
- library-tests
- ApiGraphs/py3
- PointsTo/new
- dataflow
- basic
- callgraph_crosstalk
- coverage
- def-use-flow
- enclosing-callable
- fieldflow
- global-flow
- import-star
- method-calls
- module-initialization
- regression
- strange-essaflow
- summaries
- tainttracking
- basic
- customSanitizer
- typetracking-summaries
- typetracking_imports
- typetracking
- use-use-flow
- essa/ssa-compute/CONSISTENCY
- frameworks
- aiohttp
- cryptography
- data
- django-orm
- CONSISTENCY
- django/CONSISTENCY
- fastapi
- gradio
- lxml
- modeling-example
- rest_framework/CONSISTENCY
- sqlalchemy
- stdlib-py2
- stdlib
- query-tests
- Classes
- init-calls-subclass-method
- multiple
- multiple-del
- multiple-init
- subclass-shadowing
- Exceptions/general
- Expressions/super
- Functions/ModificationOfParameterWithDefault
- Imports/deprecated
- Numerics
- Resources/FileNotAlwaysClosed
- Security
- CVE-2018-1281
- CWE-020-CookieInjection
- CWE-020-ExternalAPIs
- CWE-020-IncompleteHostnameRegExp
- CWE-022-PathInjection
- CWE-022-TarSlip
- CWE-074-TemplateInjection
- CWE-078-CommandInjection-py2
- CWE-078-CommandInjection
- CWE-078-UnsafeShellCommandConstruction
- CWE-079-Jinja2WithoutEscaping
- CWE-079-ReflectedXss
- CWE-089-SqlInjection-local-threat-model
- CWE-089-SqlInjection
- CONSISTENCY
- CWE-090-LdapInjection
- CWE-094-CodeInjection
- CWE-1004-NonHttpOnlyCookie
- CWE-113-HeaderInjection
- Tests1
- Tests2-with-wsgi-validator
- CWE-117-LogInjection
- CWE-1275-SameSiteNoneCookie
- CWE-209-StackTraceExposure
- CWE-215-FlaskDebug
- CWE-285-PamAuthorization
- CWE-295-MissingHostKeyValidation
- CWE-295-RequestWithoutValidation
- CWE-312-CleartextLogging
- CWE-312-CleartextStorage-py3
- CWE-312-CleartextStorage
- CWE-326-WeakCryptoKey
- CWE-327-BrokenCryptoAlgorithm
- CWE-327-InsecureDefaultProtocol
- CWE-327-InsecureProtocol
- CWE-327-WeakSensitiveDataHashing
- CWE-502-UnsafeDeserialization
- CWE-601-UrlRedirect
- CWE-611-Xxe
- CWE-614-InsecureCookie
- CWE-643-XPathInjection
- CWE-730-PolynomialReDoS
- CWE-730-RegexInjection
- CWE-732-WeakFilePermissions
- CWE-798-HardcodedCredentials
- CWE-918-ServerSideRequestForgery
- CWE-942-CorsMisconfigurationMiddleware
- CWE-943-NoSqlInjection
- Statements/exit
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
75 | | - | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| |||
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
91 | | - | |
92 | | - | |
| 92 | + | |
| 93 | + | |
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
99 | | - | |
100 | | - | |
| 100 | + | |
| 101 | + | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
282 | 283 | | |
283 | 284 | | |
284 | 285 | | |
285 | | - | |
| 286 | + | |
286 | 287 | | |
287 | 288 | | |
288 | 289 | | |
289 | 290 | | |
290 | 291 | | |
291 | 292 | | |
292 | 293 | | |
293 | | - | |
| 294 | + | |
294 | 295 | | |
295 | 296 | | |
296 | 297 | | |
| |||
684 | 685 | | |
685 | 686 | | |
686 | 687 | | |
687 | | - | |
| 688 | + | |
688 | 689 | | |
689 | 690 | | |
690 | 691 | | |
| |||
775 | 776 | | |
776 | 777 | | |
777 | 778 | | |
778 | | - | |
| 779 | + | |
779 | 780 | | |
780 | 781 | | |
781 | 782 | | |
| |||
805 | 806 | | |
806 | 807 | | |
807 | 808 | | |
808 | | - | |
| 809 | + | |
809 | 810 | | |
810 | 811 | | |
811 | 812 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | | - | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
214 | 215 | | |
215 | 216 | | |
216 | 217 | | |
217 | | - | |
| 218 | + | |
218 | 219 | | |
219 | 220 | | |
220 | 221 | | |
| |||
223 | 224 | | |
224 | 225 | | |
225 | 226 | | |
226 | | - | |
| 227 | + | |
227 | 228 | | |
228 | 229 | | |
229 | 230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
73 | | - | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
102 | | - | |
| 103 | + | |
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
| |||
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
118 | | - | |
| 119 | + | |
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
| |||
203 | 204 | | |
204 | 205 | | |
205 | 206 | | |
206 | | - | |
| 207 | + | |
207 | 208 | | |
208 | 209 | | |
209 | 210 | | |
| |||
413 | 414 | | |
414 | 415 | | |
415 | 416 | | |
416 | | - | |
| 417 | + | |
417 | 418 | | |
418 | 419 | | |
419 | 420 | | |
| |||
480 | 481 | | |
481 | 482 | | |
482 | 483 | | |
483 | | - | |
| 484 | + | |
484 | 485 | | |
485 | 486 | | |
486 | 487 | | |
| |||
587 | 588 | | |
588 | 589 | | |
589 | 590 | | |
590 | | - | |
| 591 | + | |
591 | 592 | | |
592 | 593 | | |
593 | 594 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
157 | 158 | | |
158 | 159 | | |
159 | 160 | | |
160 | | - | |
161 | | - | |
| 161 | + | |
162 | 162 | | |
163 | | - | |
| 163 | + | |
| 164 | + | |
164 | 165 | | |
165 | | - | |
| 166 | + | |
166 | 167 | | |
167 | 168 | | |
168 | 169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
149 | 150 | | |
150 | 151 | | |
151 | 152 | | |
152 | | - | |
| 153 | + | |
153 | 154 | | |
154 | 155 | | |
155 | 156 | | |
| |||
0 commit comments