Skip to content

Commit c007c94

Browse files
authored
Merge pull request #6843 from RasmusWL/dataflow-bool-expr
Python: Add data-flow for `x or y` and `x and y`
2 parents 97bbb12 + 8444388 commit c007c94

File tree

6 files changed

+619
-578
lines changed

6 files changed

+619
-578
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
lgtm,codescanning
2+
* Added data-flow from both `x` and `y` to `x or y` and `x and y`, as a slight over-approximation of what is described in the
3+
[Python Language Reference](https://docs.python.org/3/reference/expressions.html#boolean-operations).

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPrivate.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ module EssaFlow {
200200
// If expressions
201201
nodeFrom.asCfgNode() = nodeTo.asCfgNode().(IfExprNode).getAnOperand()
202202
or
203+
// boolean inline expressions such as `x or y` or `x and y`
204+
nodeFrom.asCfgNode() = nodeTo.asCfgNode().(BoolExprNode).getAnOperand()
205+
or
203206
// Flow inside an unpacking assignment
204207
iterableUnpackingFlowStep(nodeFrom, nodeTo)
205208
or

0 commit comments

Comments
 (0)