mirror of
https://github.com/github/codeql.git
synced 2026-05-01 03:35:13 +02:00
Python: Add failing test for analysis of property with .setter.
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
| class C | p | property p |
|
||||
| class D | __init__ | Function D.__init__ |
|
||||
| class D | q | property q |
|
||||
| class E | __init__ | Function D.__init__ |
|
||||
| class E | p | property p |
|
||||
| class E | q | property q |
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
import python
|
||||
import semmle.python.pointsto.PointsTo
|
||||
import semmle.python.objects.ObjectInternal
|
||||
|
||||
from ClassObjectInternal cls, string name, ObjectInternal f
|
||||
where cls.lookup(name, f, _) and exists(f.getOrigin())
|
||||
select cls.toString(), name, f.toString()
|
||||
@@ -0,0 +1,27 @@
|
||||
| test.py:3:1:3:16 | test.py:3 | ControlFlowNode for ClassExpr | import | test.py:3:1:3:16 | class C | file://:0:0:0:0 | builtin-class type |
|
||||
| test.py:3:9:3:14 | test.py:3 | ControlFlowNode for object | import | file://:0:0:0:0 | builtin-class object | file://:0:0:0:0 | builtin-class type |
|
||||
| test.py:5:6:5:13 | test.py:5 | ControlFlowNode for property | import | file://:0:0:0:0 | builtin-class property | file://:0:0:0:0 | builtin-class type |
|
||||
| test.py:5:6:5:13 | test.py:5 | ControlFlowNode for property() | import | test.py:5:6:5:13 | property p | file://:0:0:0:0 | builtin-class property |
|
||||
| test.py:6:5:6:16 | test.py:6 | ControlFlowNode for FunctionExpr | import | test.py:6:5:6:16 | Function C.p | file://:0:0:0:0 | builtin-class function |
|
||||
| test.py:7:16:7:16 | test.py:7 | ControlFlowNode for IntegerLiteral | runtime | file://:0:0:0:0 | int 0 | file://:0:0:0:0 | builtin-class int |
|
||||
| test.py:9:1:9:16 | test.py:9 | ControlFlowNode for ClassExpr | import | test.py:9:1:9:16 | class D | file://:0:0:0:0 | builtin-class type |
|
||||
| test.py:9:9:9:14 | test.py:9 | ControlFlowNode for object | import | file://:0:0:0:0 | builtin-class object | file://:0:0:0:0 | builtin-class type |
|
||||
| test.py:11:5:11:23 | test.py:11 | ControlFlowNode for FunctionExpr | import | test.py:11:5:11:23 | Function D.__init__ | file://:0:0:0:0 | builtin-class function |
|
||||
| test.py:12:9:12:12 | test.py:12 | ControlFlowNode for self | runtime | test.py:11:18:11:21 | self instance of D | test.py:9:1:9:16 | class D |
|
||||
| test.py:12:18:12:18 | test.py:12 | ControlFlowNode for IntegerLiteral | runtime | file://:0:0:0:0 | int 0 | file://:0:0:0:0 | builtin-class int |
|
||||
| test.py:14:6:14:13 | test.py:14 | ControlFlowNode for property | import | file://:0:0:0:0 | builtin-class property | file://:0:0:0:0 | builtin-class type |
|
||||
| test.py:14:6:14:13 | test.py:14 | ControlFlowNode for property() | import | test.py:14:6:14:13 | property q | file://:0:0:0:0 | builtin-class property |
|
||||
| test.py:15:5:15:16 | test.py:15 | ControlFlowNode for FunctionExpr | import | test.py:15:5:15:16 | Function D.q | file://:0:0:0:0 | builtin-class function |
|
||||
| test.py:16:16:16:19 | test.py:16 | ControlFlowNode for self | runtime | test.py:15:11:15:14 | self instance of D | test.py:9:1:9:16 | class D |
|
||||
| test.py:18:6:18:6 | test.py:18 | ControlFlowNode for q | import | test.py:14:6:14:13 | property q | file://:0:0:0:0 | builtin-class property |
|
||||
| test.py:19:5:19:23 | test.py:19 | ControlFlowNode for FunctionExpr | import | test.py:19:5:19:23 | Function D.q | file://:0:0:0:0 | builtin-class function |
|
||||
| test.py:20:9:20:12 | test.py:20 | ControlFlowNode for self | runtime | test.py:19:11:19:14 | self instance of D | test.py:9:1:9:16 | class D |
|
||||
| test.py:22:1:22:14 | test.py:22 | ControlFlowNode for ClassExpr | import | test.py:22:1:22:14 | class E | file://:0:0:0:0 | builtin-class type |
|
||||
| test.py:22:9:22:9 | test.py:22 | ControlFlowNode for C | import | test.py:3:1:3:16 | class C | file://:0:0:0:0 | builtin-class type |
|
||||
| test.py:22:12:22:12 | test.py:22 | ControlFlowNode for D | import | test.py:9:1:9:16 | class D | file://:0:0:0:0 | builtin-class type |
|
||||
| test.py:25:1:25:1 | test.py:25 | ControlFlowNode for C | import | test.py:3:1:3:16 | class C | file://:0:0:0:0 | builtin-class type |
|
||||
| test.py:25:1:25:3 | test.py:25 | ControlFlowNode for Attribute | import | test.py:5:6:5:13 | property p | file://:0:0:0:0 | builtin-class property |
|
||||
| test.py:26:1:26:1 | test.py:26 | ControlFlowNode for D | import | test.py:9:1:9:16 | class D | file://:0:0:0:0 | builtin-class type |
|
||||
| test.py:26:1:26:3 | test.py:26 | ControlFlowNode for Attribute | import | test.py:18:6:18:13 | property q | file://:0:0:0:0 | builtin-class property |
|
||||
| test.py:27:1:27:1 | test.py:27 | ControlFlowNode for E | import | test.py:22:1:22:14 | class E | file://:0:0:0:0 | builtin-class type |
|
||||
| test.py:28:1:28:1 | test.py:28 | ControlFlowNode for E | import | test.py:22:1:22:14 | class E | file://:0:0:0:0 | builtin-class type |
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
import python
|
||||
|
||||
|
||||
from ControlFlowNode f, Context ctx, Value v, ControlFlowNode origin
|
||||
where
|
||||
f.pointsTo(ctx, v, origin)
|
||||
select f.getLocation(), f.toString(), ctx, v, v.getClass()
|
||||
28
python/ql/test/library-tests/PointsTo/properties/test.py
Normal file
28
python/ql/test/library-tests/PointsTo/properties/test.py
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
|
||||
class C(object):
|
||||
|
||||
@property
|
||||
def p(self):
|
||||
return 0
|
||||
|
||||
class D(object):
|
||||
|
||||
def __init__(self):
|
||||
self.v = 0
|
||||
|
||||
@property
|
||||
def q(self):
|
||||
return self.v
|
||||
|
||||
@q.setter
|
||||
def q(self, value):
|
||||
self.v = value
|
||||
|
||||
class E(C, D):
|
||||
pass
|
||||
|
||||
C.p
|
||||
D.q
|
||||
E.p
|
||||
E.q
|
||||
Reference in New Issue
Block a user