Skip to content

Commit 5813209

Browse files
committed
Python: Add tests for missing points-to for built-in methods.
1 parent 887f85c commit 5813209

7 files changed

Lines changed: 69 additions & 0 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
| l_calls.py:51 | ControlFlowNode for g() | g |
2424
| l_calls.py:52 | ControlFlowNode for Attribute() | F.m |
2525
| l_calls.py:53 | ControlFlowNode for Attribute() | F.m |
26+
| l_calls.py:59 | ControlFlowNode for Attribute() | int.bit_length |
27+
| l_calls.py:63 | ControlFlowNode for Attribute() | dict.get |
2628
| q_super.py:4 | ControlFlowNode for Attribute() | object.__init__ |
2729
| q_super.py:12 | ControlFlowNode for Attribute() | Base2.__init__ |
2830
| q_super.py:22 | ControlFlowNode for Attribute() | Base1.meth |

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@
123123
| l_calls.py:0 | Module code.l_calls | E | class E |
124124
| l_calls.py:0 | Module code.l_calls | F | class F |
125125
| l_calls.py:0 | Module code.l_calls | Owner | class Owner |
126+
| l_calls.py:0 | Module code.l_calls | a | Builtin-method bit_length |
126127
| l_calls.py:0 | Module code.l_calls | bar | Function bar |
128+
| l_calls.py:0 | Module code.l_calls | c | Builtin-method get |
127129
| l_calls.py:0 | Module code.l_calls | f | Function f |
128130
| l_calls.py:0 | Module code.l_calls | foo | Function foo |
129131
| l_calls.py:0 | Module code.l_calls | g | Function g |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| l_calls.py:64 | ControlFlowNode for d |

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,25 @@ WARNING: Predicate points_to has been deprecated and may be removed in future (P
715715
| l_calls.py:53 | ControlFlowNode for Attribute() | 'b' | builtin-class str | 53 | import |
716716
| l_calls.py:53 | ControlFlowNode for F | class F | builtin-class type | 47 | import |
717717
| l_calls.py:53 | ControlFlowNode for t | Tuple | builtin-class tuple | 41 | import |
718+
| l_calls.py:58 | ControlFlowNode for Attribute | Builtin-method bit_length | builtin-class method_descriptor | 58 | import |
719+
| l_calls.py:58 | ControlFlowNode for a | Builtin-method bit_length | builtin-class method_descriptor | 58 | import |
720+
| l_calls.py:58 | ControlFlowNode for int | builtin-class int | builtin-class type | 58 | import |
721+
| l_calls.py:59 | ControlFlowNode for Attribute | Builtin-method bit_length | builtin-class method_descriptor | 59 | import |
722+
| l_calls.py:59 | ControlFlowNode for Attribute() | Attribute() | builtin-class int | 59 | import |
723+
| l_calls.py:59 | ControlFlowNode for IntegerLiteral | int 5 | builtin-class int | 59 | import |
724+
| l_calls.py:59 | ControlFlowNode for b | Attribute() | builtin-class int | 59 | import |
725+
| l_calls.py:59 | ControlFlowNode for int | builtin-class int | builtin-class type | 59 | import |
726+
| l_calls.py:62 | ControlFlowNode for Attribute | Builtin-method get | builtin-class method_descriptor | 62 | import |
727+
| l_calls.py:62 | ControlFlowNode for c | Builtin-method get | builtin-class method_descriptor | 62 | import |
728+
| l_calls.py:62 | ControlFlowNode for dict | builtin-class dict | builtin-class type | 62 | import |
729+
| l_calls.py:63 | ControlFlowNode for Attribute | Builtin-method get | builtin-class method_descriptor | 63 | import |
730+
| l_calls.py:63 | ControlFlowNode for Dict | Dict | builtin-class dict | 63 | import |
731+
| l_calls.py:63 | ControlFlowNode for IntegerLiteral | int 5 | builtin-class int | 63 | import |
732+
| l_calls.py:63 | ControlFlowNode for Str | 'foo' | builtin-class str | 63 | import |
733+
| l_calls.py:63 | ControlFlowNode for dict | builtin-class dict | builtin-class type | 63 | import |
734+
| l_calls.py:64 | ControlFlowNode for a | Builtin-method bit_length | builtin-class method_descriptor | 58 | import |
735+
| l_calls.py:64 | ControlFlowNode for b | Attribute() | builtin-class int | 59 | import |
736+
| l_calls.py:64 | ControlFlowNode for c | Builtin-method get | builtin-class method_descriptor | 62 | import |
718737
| m_attributes.py:3 | ControlFlowNode for C | class C | builtin-class type | 3 | import |
719738
| m_attributes.py:3 | ControlFlowNode for ClassExpr | class C | builtin-class type | 3 | import |
720739
| m_attributes.py:3 | ControlFlowNode for object | builtin-class object | builtin-class type | 3 | import |

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,25 @@ WARNING: Predicate points_to has been deprecated and may be removed in future (P
788788
| l_calls.py:53 | ControlFlowNode for Attribute() | 'b' | builtin-class str | 53 |
789789
| l_calls.py:53 | ControlFlowNode for F | class F | builtin-class type | 47 |
790790
| l_calls.py:53 | ControlFlowNode for t | Tuple | builtin-class tuple | 41 |
791+
| l_calls.py:58 | ControlFlowNode for Attribute | Builtin-method bit_length | builtin-class method_descriptor | 58 |
792+
| l_calls.py:58 | ControlFlowNode for a | Builtin-method bit_length | builtin-class method_descriptor | 58 |
793+
| l_calls.py:58 | ControlFlowNode for int | builtin-class int | builtin-class type | 58 |
794+
| l_calls.py:59 | ControlFlowNode for Attribute | Builtin-method bit_length | builtin-class method_descriptor | 59 |
795+
| l_calls.py:59 | ControlFlowNode for Attribute() | Attribute() | builtin-class int | 59 |
796+
| l_calls.py:59 | ControlFlowNode for IntegerLiteral | int 5 | builtin-class int | 59 |
797+
| l_calls.py:59 | ControlFlowNode for b | Attribute() | builtin-class int | 59 |
798+
| l_calls.py:59 | ControlFlowNode for int | builtin-class int | builtin-class type | 59 |
799+
| l_calls.py:62 | ControlFlowNode for Attribute | Builtin-method get | builtin-class method_descriptor | 62 |
800+
| l_calls.py:62 | ControlFlowNode for c | Builtin-method get | builtin-class method_descriptor | 62 |
801+
| l_calls.py:62 | ControlFlowNode for dict | builtin-class dict | builtin-class type | 62 |
802+
| l_calls.py:63 | ControlFlowNode for Attribute | Builtin-method get | builtin-class method_descriptor | 63 |
803+
| l_calls.py:63 | ControlFlowNode for Dict | Dict | builtin-class dict | 63 |
804+
| l_calls.py:63 | ControlFlowNode for IntegerLiteral | int 5 | builtin-class int | 63 |
805+
| l_calls.py:63 | ControlFlowNode for Str | 'foo' | builtin-class str | 63 |
806+
| l_calls.py:63 | ControlFlowNode for dict | builtin-class dict | builtin-class type | 63 |
807+
| l_calls.py:64 | ControlFlowNode for a | Builtin-method bit_length | builtin-class method_descriptor | 58 |
808+
| l_calls.py:64 | ControlFlowNode for b | Attribute() | builtin-class int | 59 |
809+
| l_calls.py:64 | ControlFlowNode for c | Builtin-method get | builtin-class method_descriptor | 62 |
791810
| s_scopes.py:4 | ControlFlowNode for True | bool True | builtin-class bool | 4 |
792811
| s_scopes.py:4 | ControlFlowNode for float | bool True | builtin-class bool | 4 |
793812
| s_scopes.py:7 | ControlFlowNode for C2 | class C2 | builtin-class type | 7 |

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,22 @@
575575
| l_calls.py:53 | ControlFlowNode for Attribute() | import | 'b' | builtin-class str |
576576
| l_calls.py:53 | ControlFlowNode for F | import | class F | builtin-class type |
577577
| l_calls.py:53 | ControlFlowNode for t | import | ('a', 'b', 'c', ) | builtin-class tuple |
578+
| l_calls.py:58 | ControlFlowNode for Attribute | import | builtin method bit_length | builtin-class method_descriptor |
579+
| l_calls.py:58 | ControlFlowNode for int | import | builtin-class int | builtin-class type |
580+
| l_calls.py:59 | ControlFlowNode for Attribute | import | builtin method bit_length | builtin-class method_descriptor |
581+
| l_calls.py:59 | ControlFlowNode for Attribute() | import | instance of int | builtin-class int |
582+
| l_calls.py:59 | ControlFlowNode for IntegerLiteral | import | int 5 | builtin-class int |
583+
| l_calls.py:59 | ControlFlowNode for int | import | builtin-class int | builtin-class type |
584+
| l_calls.py:62 | ControlFlowNode for Attribute | import | builtin method get | builtin-class method_descriptor |
585+
| l_calls.py:62 | ControlFlowNode for dict | import | builtin-class dict | builtin-class type |
586+
| l_calls.py:63 | ControlFlowNode for Attribute | import | builtin method get | builtin-class method_descriptor |
587+
| l_calls.py:63 | ControlFlowNode for Dict | import | Dict | builtin-class dict |
588+
| l_calls.py:63 | ControlFlowNode for IntegerLiteral | import | int 5 | builtin-class int |
589+
| l_calls.py:63 | ControlFlowNode for Str | import | 'foo' | builtin-class str |
590+
| l_calls.py:63 | ControlFlowNode for dict | import | builtin-class dict | builtin-class type |
591+
| l_calls.py:64 | ControlFlowNode for a | import | builtin method bit_length | builtin-class method_descriptor |
592+
| l_calls.py:64 | ControlFlowNode for b | import | instance of int | builtin-class int |
593+
| l_calls.py:64 | ControlFlowNode for c | import | builtin method get | builtin-class method_descriptor |
578594
| m_attributes.py:3 | ControlFlowNode for ClassExpr | import | class C | builtin-class type |
579595
| m_attributes.py:3 | ControlFlowNode for object | import | builtin-class object | builtin-class type |
580596
| m_attributes.py:5 | ControlFlowNode for FunctionExpr | import | Function C.__init__ | builtin-class function |

python/ql/test/library-tests/PointsTo/new/code/l_calls.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,13 @@ def m(self, x, y, z=None):
5252
F().m(*t)
5353
F.m(*t)
5454

55+
# Calls to built-in methods
56+
57+
# Methods with a known return type.
58+
a = int.bit_length
59+
b = int.bit_length(5)
60+
61+
# Methods without a known return type.
62+
c = dict.get
63+
d = dict.get({"foo":5}, 5)
64+
check(a,b,c,d)

0 commit comments

Comments
 (0)