mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Python: support for with-definitions
This commit is contained in:
@@ -42,6 +42,19 @@ module EssaFlow {
|
||||
// nodeTo is `x`, essa var
|
||||
nodeFrom.asCfgNode() = nodeTo.asEssaNode().getDefinition().(AssignmentDefinition).getValue()
|
||||
or
|
||||
// With definition
|
||||
// `with f(42) as x:`
|
||||
// nodeFrom is `f(42)`, cfg node
|
||||
// nodeTo is `x`, essa var
|
||||
exists(With with, ControlFlowNode contextManager, ControlFlowNode var |
|
||||
nodeFrom.asCfgNode() = contextManager and
|
||||
nodeTo.asEssaNode().getDefinition().(WithDefinition).getDefiningNode() = var and
|
||||
// see `with_flow`
|
||||
with.getContextExpr() = contextManager.getNode() and
|
||||
with.getOptionalVars() = var.getNode() and
|
||||
contextManager.strictlyDominates(var)
|
||||
)
|
||||
or
|
||||
// Use
|
||||
// `y = 42`
|
||||
// `x = f(y)`
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
| test.py:37:13:37:18 | ControlFlowNode for SOURCE | test.py:41:14:41:14 | ControlFlowNode for t |
|
||||
| test.py:76:9:76:14 | ControlFlowNode for SOURCE | test.py:78:10:78:10 | ControlFlowNode for t |
|
||||
| test.py:108:13:108:18 | ControlFlowNode for SOURCE | test.py:112:14:112:14 | ControlFlowNode for t |
|
||||
| test.py:139:10:139:15 | ControlFlowNode for SOURCE | test.py:140:14:140:14 | ControlFlowNode for t |
|
||||
| test.py:143:9:143:14 | ControlFlowNode for SOURCE | test.py:145:10:145:10 | ControlFlowNode for s |
|
||||
| test.py:158:9:158:14 | ControlFlowNode for SOURCE | test.py:160:14:160:14 | ControlFlowNode for t |
|
||||
| test.py:158:9:158:14 | ControlFlowNode for SOURCE | test.py:162:14:162:14 | ControlFlowNode for t |
|
||||
|
||||
@@ -4,7 +4,6 @@ from
|
||||
DataFlow::Node source,
|
||||
DataFlow::Node sink
|
||||
where
|
||||
// source != sink and
|
||||
exists(TestConfiguration cfg | cfg.hasFlow(source, sink))
|
||||
select
|
||||
source, sink
|
||||
|
||||
Reference in New Issue
Block a user