Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4145b19

Browse files
committed
Python points-to: update some test results.
1 parent ddc4ada commit 4145b19

12 files changed

Lines changed: 65 additions & 79 deletions

File tree

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,8 +1533,15 @@ cached module Types {
15331533
result.getBuiltin() = cls.getBuiltin().getBaseClass() and n = 0
15341534
or
15351535
exists(Class pycls |
1536-
pycls = cls.(PythonClassObjectInternal).getScope() |
1537-
PointsToInternal::pointsTo(pycls.getBase(n).getAFlowNode(), _, result, _)
1536+
pycls = cls.(PythonClassObjectInternal).getScope()
1537+
|
1538+
exists(ObjectInternal base |
1539+
PointsToInternal::pointsTo(pycls.getBase(n).getAFlowNode(), _, base, _)
1540+
|
1541+
result = base and base != ObjectInternal::unknown()
1542+
or
1543+
base = ObjectInternal::unknown() and result = ObjectInternal::unknownClass()
1544+
)
15381545
or
15391546
not exists(pycls.getABase()) and n = 0 and
15401547
isNewStyle(cls) and result = ObjectInternal::builtin("object")
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
| class Base | meth | Function meth | 3 |
2-
| class Derived1 | meth | Function meth | 8 |
3-
| class Derived2 | meth | Function meth | 13 |
4-
| class Derived4 | meth | Function meth | 21 |
5-
| class Derived5 | meth | Function meth | 26 |
6-
| class Derived6 | meth | Function meth | 31 |
7-
| class Missing1 | a | Function a | 49 |
8-
| class Missing2 | b | Function b | 53 |
9-
| class Missing3 | c | Function c | 57 |
10-
| class Wrong1 | meth | Function meth | 37 |
11-
| class Wrong2 | meth | Function meth | 42 |
1+
| class Base | meth | Function Base.meth | 3 |
2+
| class Derived1 | meth | Function Derived1.meth | 8 |
3+
| class Derived2 | meth | Function Derived2.meth | 13 |
4+
| class Derived4 | meth | Function Derived4.meth | 21 |
5+
| class Derived5 | meth | Function Derived5.meth | 26 |
6+
| class Derived6 | meth | Function Derived6.meth | 31 |
7+
| class Missing1 | a | Function Missing1.a | 49 |
8+
| class Missing2 | b | Function Missing2.b | 53 |
9+
| class Missing3 | c | Function Missing3.c | 57 |
10+
| class Wrong1 | meth | Function Wrong1.meth | 37 |
11+
| class Wrong2 | meth | Function Wrong2.meth | 42 |
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11

22
import python
33
import semmle.python.pointsto.PointsTo
4+
import semmle.python.objects.ObjectInternal
45

5-
from ClassObject cls, string name, PyFunctionObject f
6-
where PointsTo::Types::class_declared_attribute(cls, name, f, _, _)
7-
select cls.toString(), name, f.toString(), f.getFunction().getLocation().getStartLine()
6+
from ClassObjectInternal cls, string name, PythonFunctionObjectInternal f
7+
where Types::declaredAttribute(cls, name, f, _)
8+
select cls.toString(), name, f.toString(), f.getScope().getLocation().getStartLine()
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
| class Base | meth | Function meth | 3 |
2-
| class Derived1 | meth | Function meth | 8 |
3-
| class Derived2 | meth | Function meth | 13 |
4-
| class Derived3 | meth | Function meth | 8 |
5-
| class Derived4 | meth | Function meth | 21 |
6-
| class Derived5 | meth | Function meth | 26 |
7-
| class Derived6 | meth | Function meth | 31 |
8-
| class Missing1 | a | Function a | 49 |
9-
| class Missing2 | b | Function b | 53 |
10-
| class Missing2 | meth | Function meth | 3 |
11-
| class Missing3 | c | Function c | 57 |
12-
| class Wrong1 | meth | Function meth | 37 |
13-
| class Wrong2 | meth | Function meth | 42 |
1+
| class Base | meth | Function Base.meth | 3 |
2+
| class Derived1 | meth | Function Derived1.meth | 8 |
3+
| class Derived2 | meth | Function Derived2.meth | 13 |
4+
| class Derived3 | meth | Function Derived1.meth | 8 |
5+
| class Derived4 | meth | Function Derived4.meth | 21 |
6+
| class Derived5 | meth | Function Derived5.meth | 26 |
7+
| class Derived6 | meth | Function Derived6.meth | 31 |
8+
| class Missing1 | a | Function Missing1.a | 49 |
9+
| class Missing2 | b | Function Missing2.b | 53 |
10+
| class Missing2 | meth | Function Base.meth | 3 |
11+
| class Missing3 | c | Function Missing3.c | 57 |
12+
| class Wrong1 | meth | Function Wrong1.meth | 37 |
13+
| class Wrong2 | meth | Function Wrong2.meth | 42 |
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11

22
import python
33
import semmle.python.pointsto.PointsTo
4+
import semmle.python.objects.ObjectInternal
45

5-
from ClassObject cls, string name, PyFunctionObject f
6-
where PointsTo::Types::class_attribute_lookup(cls, name, f, _, _)
7-
select cls.toString(), name, f.toString(), f.getFunction().getLocation().getStartLine()
6+
from ClassObjectInternal cls, string name, PythonFunctionObjectInternal f
7+
where cls.lookup(name, f, _)
8+
select cls.toString(), name, f.toString(), f.getScope().getLocation().getStartLine()

python/ql/test/library-tests/PointsTo/inheritance/MetaClass.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55
| class Derived4 | builtin-class type |
66
| class Derived5 | builtin-class type |
77
| class Derived6 | builtin-class type |
8+
| class Missing1 | builtin-class type |
9+
| class Missing2 | builtin-class type |
10+
| class Missing3 | builtin-class type |
811
| class Wrong1 | builtin-class type |
912
| class Wrong2 | builtin-class type |

python/ql/test/library-tests/PointsTo/inheritance/Mro.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import python
33

44
private import semmle.python.objects.ObjectInternal
5-
private import semmle.python.pointsto.PointsTo2
5+
private import semmle.python.pointsto.PointsTo
66

77
/** Make unknown type visible */
88
class UnknownType extends UnknownClassInternal {

python/ql/test/library-tests/PointsTo/instances/LocalPointsTo.expected

Whitespace-only changes.

python/ql/test/library-tests/PointsTo/instances/LocalPointsTo.ql

Lines changed: 0 additions & 10 deletions
This file was deleted.

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

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)