Skip to content

Commit f190f83

Browse files
committed
Python: Give most non-self instance attributes the 'unknown' value; improves reachability analysis.
1 parent 54242f4 commit f190f83

File tree

5 files changed

+11
-1
lines changed

5 files changed

+11
-1
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,6 @@ module PointsTo {
610610
points_to(obj_node, context, x, icls, _) and
611611
(not x instanceof ModuleObject and not x instanceof ClassObject) and
612612
not icls.isBuiltin() and
613-
Types::class_has_attribute_bool(icls, name) = false and
614613
value = unknownValue() and cls = theUnknownType() and origin = f
615614
)
616615
)

python/ql/test/library-tests/PointsTo/guarded/PointsTo.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
| test.py | 408 | ControlFlowNode for x | int 1 | 404 |
6262
| test.py | 420 | ControlFlowNode for Attribute | NoneType None | 418 |
6363
| test.py | 427 | ControlFlowNode for Attribute | NoneType None | 418 |
64+
| test.py | 435 | ControlFlowNode for y | int 1 | 433 |
6465
| type_test.py | 5 | ControlFlowNode for d | Dict | 2 |
6566
| type_test.py | 14 | ControlFlowNode for x | int 0 | 11 |
6667
| type_test.py | 16 | ControlFlowNode for x | float 1.0 | 11 |

python/ql/test/library-tests/PointsTo/guarded/PointsToWithType.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
| test.py | 408 | ControlFlowNode for x | int 1 | builtin-class int | 404 |
6262
| test.py | 420 | ControlFlowNode for Attribute | NoneType None | builtin-class NoneType | 418 |
6363
| test.py | 427 | ControlFlowNode for Attribute | NoneType None | builtin-class NoneType | 418 |
64+
| test.py | 435 | ControlFlowNode for y | int 1 | builtin-class int | 433 |
6465
| type_test.py | 5 | ControlFlowNode for d | Dict | builtin-class dict | 2 |
6566
| type_test.py | 14 | ControlFlowNode for x | int 0 | builtin-class int | 11 |
6667
| type_test.py | 16 | ControlFlowNode for x | float 1.0 | builtin-class float | 11 |

python/ql/test/library-tests/PointsTo/guarded/test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,3 +426,10 @@ def meth(self):
426426
else:
427427
use(self.x)
428428
return lambda : use(self.x)
429+
430+
431+
def test_on_unknown_attr():
432+
e = E()
433+
y = 1
434+
if e.attr:
435+
use(y)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,5 @@
225225
| r_regressions.py:52 | ControlFlowNode for msg | 51 |
226226
| r_regressions.py:64 | ControlFlowNode for do_validation | 64 |
227227
| r_regressions.py:64 | ControlFlowNode for do_validation() | 64 |
228+
| r_regressions.py:90 | ControlFlowNode for Attribute | 90 |
229+
| r_regressions.py:90 | ControlFlowNode for Attribute() | 90 |

0 commit comments

Comments
 (0)