Skip to content

Commit 24d678b

Browse files
committed
Python: Points-to; let values with no boolean constant value flow through pi-nodes.
1 parent f190f83 commit 24d678b

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

python/ql/src/semmle/python/pointsto/PointsTo.qll

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,10 +2116,15 @@ module PointsTo {
21162116
private boolean truth_test_evaluates_boolean(ControlFlowNode expr, ControlFlowNode use, PointsToContext context, Object val, ClassObject cls, ControlFlowNode origin) {
21172117
contains_interesting_expression_within_test(expr, use) and
21182118
points_to(use, context, val, cls, origin) and
2119+
expr = use and
21192120
(
2120-
expr = use and val.booleanValue() = result
2121+
val.booleanValue() = result
21212122
or
2122-
expr = use and Types::instances_always_true(cls) and result = true
2123+
Types::instances_always_true(cls) and result = true
2124+
or
2125+
val.maybe() and result = true
2126+
or
2127+
val.maybe() and result = false
21232128
)
21242129
}
21252130

python/ql/test/library-tests/PointsTo/new/PointsToUnknown.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
| b_condition.py:88 | ControlFlowNode for y | 87 |
107107
| b_condition.py:90 | ControlFlowNode for x | 87 |
108108
| b_condition.py:90 | ControlFlowNode for y | 87 |
109+
| b_condition.py:92 | ControlFlowNode for x | 87 |
109110
| b_condition.py:93 | ControlFlowNode for use | 93 |
110111
| b_condition.py:93 | ControlFlowNode for use() | 93 |
111112
| b_condition.py:93 | ControlFlowNode for y | 87 |
@@ -115,6 +116,7 @@
115116
| b_condition.py:96 | ControlFlowNode for y | 87 |
116117
| b_condition.py:97 | ControlFlowNode for use | 97 |
117118
| b_condition.py:97 | ControlFlowNode for use() | 97 |
119+
| b_condition.py:97 | ControlFlowNode for x | 87 |
118120
| b_condition.py:99 | ControlFlowNode for use | 99 |
119121
| b_condition.py:99 | ControlFlowNode for use() | 99 |
120122
| b_condition.py:102 | ControlFlowNode for a | 101 |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
| 0 | 29 | 29 | 100.0 |
1+
| 0 | 31 | 31 | 100.0 |
22
| 1 | 4 | 40 | 10.0 |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
| 0 | 29 | 29 | 100.0 |
1+
| 0 | 31 | 31 | 100.0 |
22
| 1 | 3 | 40 | 7.5 |

0 commit comments

Comments
 (0)