mirror of
https://github.com/github/codeql.git
synced 2026-05-02 04:05:14 +02:00
Merge branch 'master' into python-add-points-to-for-missing-builtin-return-types
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
|
||||
import python
|
||||
|
||||
from ExceptFlowNode ex, Object obj
|
||||
where ex.handledException(obj, _, _)
|
||||
select ex.getLocation().getStartLine(), ex.toString(), obj.toString()
|
||||
from ExceptFlowNode ex, Value val
|
||||
where ex.handledException(val, _, _)
|
||||
select ex.getLocation().getStartLine(), ex.toString(), val.toString()
|
||||
@@ -1 +1 @@
|
||||
| nonsense.py:1:14:1:14 | Syntax Error | Syntax Error (in Python 2.7). |
|
||||
| nonsense.py:1:14:1:14 | Syntax Error | Syntax Error (in Python 2). |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
import python
|
||||
|
||||
from ExceptFlowNode ex, Object obj
|
||||
where ex.handledException(obj, _, _)
|
||||
select ex.getLocation().getStartLine(), ex.toString(), obj.toString()
|
||||
from ExceptFlowNode ex, Value val
|
||||
where ex.handledException(val, _, _)
|
||||
select ex.getLocation().getStartLine(), ex.toString(), val.toString()
|
||||
@@ -0,0 +1,3 @@
|
||||
| mwe_failure.py:7:1:7:23 | class MyTest | <MISSING BASE TYPE> |
|
||||
| mwe_failure_2.py:7:1:7:23 | class MyTest | <MISSING BASE TYPE> |
|
||||
| mwe_success.py:7:1:7:23 | class MyTest | class TestCase |
|
||||
@@ -0,0 +1,10 @@
|
||||
import python
|
||||
|
||||
// as used in semmle.python.filters.Tests
|
||||
|
||||
from ClassValue c, string base
|
||||
where
|
||||
c.getScope().getLocation().getFile().getShortName().matches("mwe%.py") and
|
||||
c.getName() = "MyTest" and
|
||||
if exists(c.getABaseType()) then base = c.getABaseType().toString() else base = "<MISSING BASE TYPE>"
|
||||
select c, base
|
||||
@@ -0,0 +1,10 @@
|
||||
import subprocess
|
||||
assert subprocess.call(['run-backup']) == 0
|
||||
|
||||
class TestCase:
|
||||
pass
|
||||
|
||||
class MyTest(TestCase):
|
||||
pass
|
||||
|
||||
# found by /home/rasmus/code/ql/python/ql/test/query-tests/Statements/asserts/AssertLiteralConstant.qlref
|
||||
@@ -0,0 +1,8 @@
|
||||
import subprocess
|
||||
assert subprocess.call(['run-backup'])
|
||||
|
||||
class TestCase:
|
||||
pass
|
||||
|
||||
class MyTest(TestCase):
|
||||
pass
|
||||
@@ -0,0 +1,8 @@
|
||||
import subprocess
|
||||
subprocess.call(['run-backup'])
|
||||
|
||||
class TestCase:
|
||||
pass
|
||||
|
||||
class MyTest(TestCase):
|
||||
pass
|
||||
@@ -0,0 +1 @@
|
||||
semmle-extractor-options: --lang=3 --max-import-depth=1
|
||||
@@ -1 +1 @@
|
||||
| nonsense.py:1:2:1:2 | Syntax Error | Syntax Error (in Python 3.5). |
|
||||
| nonsense.py:1:2:1:2 | Syntax Error | Syntax Error (in Python 3). |
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
| async_iterator.py:26:11:26:34 | For | $@ of class '$@' may be used in for-loop. | async_iterator.py:26:20:26:33 | ControlFlowNode for MissingAiter() | Non-iterator | async_iterator.py:13:1:13:19 | class MissingAiter | MissingAiter |
|
||||
| statements_test.py:34:5:34:19 | For | $@ of class '$@' may be used in for-loop. | statements_test.py:34:18:34:18 | ControlFlowNode for IntegerLiteral | Non-iterator | file://:0:0:0:0 | builtin-class int | int |
|
||||
| async_iterator.py:26:11:26:34 | For | $@ of class '$@' may be used in for-loop. | async_iterator.py:26:20:26:33 | ControlFlowNode for MissingAiter() | Non-iterable | async_iterator.py:13:1:13:19 | class MissingAiter | MissingAiter |
|
||||
| statements_test.py:34:5:34:19 | For | $@ of class '$@' may be used in for-loop. | statements_test.py:34:18:34:18 | ControlFlowNode for IntegerLiteral | Non-iterable | file://:0:0:0:0 | builtin-class int | int |
|
||||
|
||||
@@ -62,6 +62,10 @@
|
||||
| a_simple.py:49 | g_0 = a |
|
||||
| a_simple.py:49 | h_0 = b |
|
||||
| a_simple.py:49 | i_0 = c |
|
||||
| a_simple.py:53 | l_0 = BinaryExpr[0] |
|
||||
| a_simple.py:53 | m_0 = BinaryExpr[1] |
|
||||
| a_simple.py:56 | s_0 = a[0] |
|
||||
| a_simple.py:56 | u_0 = a[1] |
|
||||
| b_condition.py:0 | __name___0 = ScopeEntryDefinition |
|
||||
| b_condition.py:0 | __package___0 = ScopeEntryDefinition |
|
||||
| b_condition.py:0 | double_attr_check_0 = ScopeEntryDefinition |
|
||||
|
||||
@@ -45,6 +45,10 @@
|
||||
| a_simple.py:49 | Local Variable g | AssignmentDefinition |
|
||||
| a_simple.py:49 | Local Variable h | AssignmentDefinition |
|
||||
| a_simple.py:49 | Local Variable i | AssignmentDefinition |
|
||||
| a_simple.py:53 | Local Variable l | MultiAssignmentDefinition |
|
||||
| a_simple.py:53 | Local Variable m | MultiAssignmentDefinition |
|
||||
| a_simple.py:56 | Local Variable s | MultiAssignmentDefinition |
|
||||
| a_simple.py:56 | Local Variable u | MultiAssignmentDefinition |
|
||||
| b_condition.py:0 | Global Variable __name__ | ScopeEntryDefinition |
|
||||
| b_condition.py:0 | Global Variable __package__ | ScopeEntryDefinition |
|
||||
| b_condition.py:0 | Global Variable double_attr_check | ScopeEntryDefinition |
|
||||
|
||||
@@ -1,19 +1,29 @@
|
||||
| a_simple.py:20 | ControlFlowNode for For | 20 |
|
||||
| a_simple.py:20 | ControlFlowNode for seq | 18 |
|
||||
| a_simple.py:21 | ControlFlowNode for x | 20 |
|
||||
| a_simple.py:24 | ControlFlowNode for x | 23 |
|
||||
| a_simple.py:29 | ControlFlowNode for For | 29 |
|
||||
| a_simple.py:29 | ControlFlowNode for x | 27 |
|
||||
| a_simple.py:30 | ControlFlowNode for p | 29 |
|
||||
| a_simple.py:35 | ControlFlowNode for Subscript | 35 |
|
||||
| a_simple.py:36 | ControlFlowNode for Subscript | 36 |
|
||||
| a_simple.py:40 | ControlFlowNode for a | 38 |
|
||||
| a_simple.py:40 | ControlFlowNode for b | 38 |
|
||||
| a_simple.py:40 | ControlFlowNode for c | 38 |
|
||||
| a_simple.py:46 | ControlFlowNode for x | 42 |
|
||||
| a_simple.py:47 | ControlFlowNode for y | 42 |
|
||||
| a_simple.py:48 | ControlFlowNode for z | 42 |
|
||||
| a_simple.py:49 | ControlFlowNode for a | 38 |
|
||||
| a_simple.py:49 | ControlFlowNode for b | 38 |
|
||||
| a_simple.py:49 | ControlFlowNode for c | 38 |
|
||||
| a_simple.py:50 | ControlFlowNode for g | 38 |
|
||||
| a_simple.py:51 | ControlFlowNode for h | 38 |
|
||||
| a_simple.py:52 | ControlFlowNode for i | 38 |
|
||||
| a_simple.py:54 | ControlFlowNode for l | 53 |
|
||||
| a_simple.py:55 | ControlFlowNode for m | 53 |
|
||||
| a_simple.py:56 | ControlFlowNode for a | 38 |
|
||||
| a_simple.py:57 | ControlFlowNode for s | 56 |
|
||||
| a_simple.py:58 | ControlFlowNode for u | 56 |
|
||||
| b_condition.py:5 | ControlFlowNode for IfExp | 5 |
|
||||
| b_condition.py:5 | ControlFlowNode for cond | 5 |
|
||||
| b_condition.py:5 | ControlFlowNode for unknown | 5 |
|
||||
@@ -231,6 +241,7 @@
|
||||
| r_regressions.py:39 | ControlFlowNode for y | 27 |
|
||||
| r_regressions.py:43 | ControlFlowNode for x | 43 |
|
||||
| r_regressions.py:43 | ControlFlowNode for x() | 43 |
|
||||
| r_regressions.py:44 | ControlFlowNode for data | 43 |
|
||||
| r_regressions.py:52 | ControlFlowNode for msg | 51 |
|
||||
| r_regressions.py:64 | ControlFlowNode for do_validation | 64 |
|
||||
| r_regressions.py:64 | ControlFlowNode for do_validation() | 64 |
|
||||
|
||||
@@ -56,6 +56,11 @@ WARNING: Predicate points_to has been deprecated and may be removed in future (P
|
||||
| a_simple.py:41 | ControlFlowNode for t | Tuple | builtin-class tuple | 39 | runtime |
|
||||
| a_simple.py:42 | ControlFlowNode for Tuple | Tuple | builtin-class tuple | 40 | runtime |
|
||||
| a_simple.py:42 | ControlFlowNode for w | Tuple | builtin-class tuple | 40 | runtime |
|
||||
| a_simple.py:43 | ControlFlowNode for p | int 1 | builtin-class int | 41 | runtime |
|
||||
| a_simple.py:44 | ControlFlowNode for q | int 2 | builtin-class int | 41 | runtime |
|
||||
| a_simple.py:45 | ControlFlowNode for r | int 3 | builtin-class int | 41 | runtime |
|
||||
| a_simple.py:47 | ControlFlowNode for y | 'b' | builtin-class str | 42 | runtime |
|
||||
| a_simple.py:48 | ControlFlowNode for z | 'c' | builtin-class str | 42 | runtime |
|
||||
| a_simple.py:49 | ControlFlowNode for Tuple | Tuple | builtin-class tuple | 49 | runtime |
|
||||
| a_simple.py:49 | ControlFlowNode for b | 'b' | builtin-class str | 38 | runtime |
|
||||
| a_simple.py:49 | ControlFlowNode for c | 'c' | builtin-class str | 38 | runtime |
|
||||
@@ -63,6 +68,11 @@ WARNING: Predicate points_to has been deprecated and may be removed in future (P
|
||||
| a_simple.py:49 | ControlFlowNode for i | 'c' | builtin-class str | 38 | runtime |
|
||||
| a_simple.py:51 | ControlFlowNode for h | 'b' | builtin-class str | 38 | runtime |
|
||||
| a_simple.py:52 | ControlFlowNode for i | 'c' | builtin-class str | 38 | runtime |
|
||||
| a_simple.py:53 | ControlFlowNode for BinaryExpr | BinaryExpr | builtin-class tuple | 53 | runtime |
|
||||
| a_simple.py:53 | ControlFlowNode for IntegerLiteral | int 1 | builtin-class int | 53 | runtime |
|
||||
| a_simple.py:53 | ControlFlowNode for IntegerLiteral | int 2 | builtin-class int | 53 | runtime |
|
||||
| a_simple.py:53 | ControlFlowNode for Tuple | BinaryExpr | builtin-class tuple | 53 | runtime |
|
||||
| a_simple.py:53 | ControlFlowNode for Tuple | Tuple | builtin-class tuple | 53 | runtime |
|
||||
| b_condition.py:4 | ControlFlowNode for FunctionExpr | Function f | builtin-class function | 4 | import |
|
||||
| b_condition.py:4 | ControlFlowNode for f | Function f | builtin-class function | 4 | import |
|
||||
| b_condition.py:5 | ControlFlowNode for IfExp | NoneType None | builtin-class NoneType | 5 | runtime |
|
||||
|
||||
@@ -56,6 +56,11 @@ WARNING: Predicate points_to has been deprecated and may be removed in future (P
|
||||
| a_simple.py:41 | ControlFlowNode for t | Tuple | builtin-class tuple | 39 |
|
||||
| a_simple.py:42 | ControlFlowNode for Tuple | Tuple | builtin-class tuple | 40 |
|
||||
| a_simple.py:42 | ControlFlowNode for w | Tuple | builtin-class tuple | 40 |
|
||||
| a_simple.py:43 | ControlFlowNode for p | int 1 | builtin-class int | 41 |
|
||||
| a_simple.py:44 | ControlFlowNode for q | int 2 | builtin-class int | 41 |
|
||||
| a_simple.py:45 | ControlFlowNode for r | int 3 | builtin-class int | 41 |
|
||||
| a_simple.py:47 | ControlFlowNode for y | 'b' | builtin-class str | 42 |
|
||||
| a_simple.py:48 | ControlFlowNode for z | 'c' | builtin-class str | 42 |
|
||||
| a_simple.py:49 | ControlFlowNode for Tuple | Tuple | builtin-class tuple | 49 |
|
||||
| a_simple.py:49 | ControlFlowNode for b | 'b' | builtin-class str | 38 |
|
||||
| a_simple.py:49 | ControlFlowNode for c | 'c' | builtin-class str | 38 |
|
||||
@@ -63,6 +68,11 @@ WARNING: Predicate points_to has been deprecated and may be removed in future (P
|
||||
| a_simple.py:49 | ControlFlowNode for i | 'c' | builtin-class str | 38 |
|
||||
| a_simple.py:51 | ControlFlowNode for h | 'b' | builtin-class str | 38 |
|
||||
| a_simple.py:52 | ControlFlowNode for i | 'c' | builtin-class str | 38 |
|
||||
| a_simple.py:53 | ControlFlowNode for BinaryExpr | BinaryExpr | builtin-class tuple | 53 |
|
||||
| a_simple.py:53 | ControlFlowNode for IntegerLiteral | int 1 | builtin-class int | 53 |
|
||||
| a_simple.py:53 | ControlFlowNode for IntegerLiteral | int 2 | builtin-class int | 53 |
|
||||
| a_simple.py:53 | ControlFlowNode for Tuple | BinaryExpr | builtin-class tuple | 53 |
|
||||
| a_simple.py:53 | ControlFlowNode for Tuple | Tuple | builtin-class tuple | 53 |
|
||||
| b_condition.py:4 | ControlFlowNode for FunctionExpr | Function f | builtin-class function | 4 |
|
||||
| b_condition.py:4 | ControlFlowNode for f | Function f | builtin-class function | 4 |
|
||||
| b_condition.py:5 | ControlFlowNode for IfExp | NoneType None | builtin-class NoneType | 5 |
|
||||
|
||||
@@ -31,6 +31,11 @@ WARNING: Predicate ssa_variable_points_to has been deprecated and may be removed
|
||||
| a_simple.py:38 | multi_assign_and_packing_0 = FunctionExpr | Function multi_assign_and_packing | builtin-class function |
|
||||
| a_simple.py:39 | t_0 = Tuple | Tuple | builtin-class tuple |
|
||||
| a_simple.py:40 | w_0 = Tuple | Tuple | builtin-class tuple |
|
||||
| a_simple.py:41 | p_0 = t[0] | int 1 | builtin-class int |
|
||||
| a_simple.py:41 | q_0 = t[1] | int 2 | builtin-class int |
|
||||
| a_simple.py:41 | r_0 = t[2] | int 3 | builtin-class int |
|
||||
| a_simple.py:42 | y_0 = w[1] | 'b' | builtin-class str |
|
||||
| a_simple.py:42 | z_0 = w[2] | 'c' | builtin-class str |
|
||||
| a_simple.py:49 | h_0 = b | 'b' | builtin-class str |
|
||||
| a_simple.py:49 | i_0 = c | 'c' | builtin-class str |
|
||||
| b_condition.py:0 | __name___0 = ScopeEntryDefinition | 'code.b_condition' | builtin-class str |
|
||||
|
||||
@@ -46,10 +46,14 @@
|
||||
| a_simple.py:38 | Local Variable g | Entry node for Function multi_assign_and_packing | definition |
|
||||
| a_simple.py:38 | Local Variable h | Entry node for Function multi_assign_and_packing | definition |
|
||||
| a_simple.py:38 | Local Variable i | Entry node for Function multi_assign_and_packing | definition |
|
||||
| a_simple.py:38 | Local Variable l | Entry node for Function multi_assign_and_packing | definition |
|
||||
| a_simple.py:38 | Local Variable m | Entry node for Function multi_assign_and_packing | definition |
|
||||
| a_simple.py:38 | Local Variable p | Entry node for Function multi_assign_and_packing | definition |
|
||||
| a_simple.py:38 | Local Variable q | Entry node for Function multi_assign_and_packing | definition |
|
||||
| a_simple.py:38 | Local Variable r | Entry node for Function multi_assign_and_packing | definition |
|
||||
| a_simple.py:38 | Local Variable s | Entry node for Function multi_assign_and_packing | definition |
|
||||
| a_simple.py:38 | Local Variable t | Entry node for Function multi_assign_and_packing | definition |
|
||||
| a_simple.py:38 | Local Variable u | Entry node for Function multi_assign_and_packing | definition |
|
||||
| a_simple.py:38 | Local Variable w | Entry node for Function multi_assign_and_packing | definition |
|
||||
| a_simple.py:38 | Local Variable x | Entry node for Function multi_assign_and_packing | definition |
|
||||
| a_simple.py:38 | Local Variable y | Entry node for Function multi_assign_and_packing | definition |
|
||||
@@ -65,6 +69,10 @@
|
||||
| a_simple.py:49 | Local Variable g | ControlFlowNode for g | definition |
|
||||
| a_simple.py:49 | Local Variable h | ControlFlowNode for h | definition |
|
||||
| a_simple.py:49 | Local Variable i | ControlFlowNode for i | definition |
|
||||
| a_simple.py:53 | Local Variable l | ControlFlowNode for l | definition |
|
||||
| a_simple.py:53 | Local Variable m | ControlFlowNode for m | definition |
|
||||
| a_simple.py:56 | Local Variable s | ControlFlowNode for s | definition |
|
||||
| a_simple.py:56 | Local Variable u | ControlFlowNode for u | definition |
|
||||
| b_condition.py:0 | Global Variable __name__ | Entry node for Module code.b_condition | definition |
|
||||
| b_condition.py:0 | Global Variable __package__ | Entry node for Module code.b_condition | definition |
|
||||
| b_condition.py:0 | Global Variable double_attr_check | Entry node for Module code.b_condition | definition |
|
||||
|
||||
@@ -62,10 +62,14 @@
|
||||
| a_simple.py:38 | g_0 | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | h_0 | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | i_0 | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | l_0 | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | m_0 | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | p_0 | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | q_0 | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | r_0 | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | s_0 | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | t_0 | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | u_0 | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | w_0 | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | x_0 | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | y_0 | Exit node for Function multi_assign_and_packing |
|
||||
@@ -87,6 +91,11 @@
|
||||
| a_simple.py:50 | g_0 | ControlFlowNode for g |
|
||||
| a_simple.py:51 | h_0 | ControlFlowNode for h |
|
||||
| a_simple.py:52 | i_0 | ControlFlowNode for i |
|
||||
| a_simple.py:54 | l_0 | ControlFlowNode for l |
|
||||
| a_simple.py:55 | m_0 | ControlFlowNode for m |
|
||||
| a_simple.py:56 | a_0 | ControlFlowNode for a |
|
||||
| a_simple.py:57 | s_0 | ControlFlowNode for s |
|
||||
| a_simple.py:58 | u_0 | ControlFlowNode for u |
|
||||
| b_condition.py:0 | __name___0 | Exit node for Module code.b_condition |
|
||||
| b_condition.py:0 | __package___0 | Exit node for Module code.b_condition |
|
||||
| b_condition.py:0 | double_attr_check_1 | Exit node for Module code.b_condition |
|
||||
|
||||
@@ -41,6 +41,11 @@
|
||||
| a_simple.py:42 | ControlFlowNode for w | runtime | (Unknown value, 'b', Unknown value, ) | builtin-class tuple |
|
||||
| a_simple.py:42 | ControlFlowNode for w | runtime | (Unknown value, Unknown value, 'c', ) | builtin-class tuple |
|
||||
| a_simple.py:42 | ControlFlowNode for w | runtime | (Unknown value, Unknown value, Unknown value, ) | builtin-class tuple |
|
||||
| a_simple.py:43 | ControlFlowNode for p | runtime | int 1 | builtin-class int |
|
||||
| a_simple.py:44 | ControlFlowNode for q | runtime | int 2 | builtin-class int |
|
||||
| a_simple.py:45 | ControlFlowNode for r | runtime | int 3 | builtin-class int |
|
||||
| a_simple.py:47 | ControlFlowNode for y | runtime | 'b' | builtin-class str |
|
||||
| a_simple.py:48 | ControlFlowNode for z | runtime | 'c' | builtin-class str |
|
||||
| a_simple.py:49 | ControlFlowNode for Tuple | runtime | (Unknown value, 'b', 'c', ) | builtin-class tuple |
|
||||
| a_simple.py:49 | ControlFlowNode for Tuple | runtime | (Unknown value, 'b', Unknown value, ) | builtin-class tuple |
|
||||
| a_simple.py:49 | ControlFlowNode for Tuple | runtime | (Unknown value, Unknown value, 'c', ) | builtin-class tuple |
|
||||
@@ -49,6 +54,11 @@
|
||||
| a_simple.py:49 | ControlFlowNode for c | runtime | 'c' | builtin-class str |
|
||||
| a_simple.py:51 | ControlFlowNode for h | runtime | 'b' | builtin-class str |
|
||||
| a_simple.py:52 | ControlFlowNode for i | runtime | 'c' | builtin-class str |
|
||||
| a_simple.py:53 | ControlFlowNode for BinaryExpr | runtime | instance of tuple | builtin-class tuple |
|
||||
| a_simple.py:53 | ControlFlowNode for IntegerLiteral | runtime | int 1 | builtin-class int |
|
||||
| a_simple.py:53 | ControlFlowNode for IntegerLiteral | runtime | int 2 | builtin-class int |
|
||||
| a_simple.py:53 | ControlFlowNode for Tuple | runtime | (int 1, ) | builtin-class tuple |
|
||||
| a_simple.py:53 | ControlFlowNode for Tuple | runtime | (int 2, ) | builtin-class tuple |
|
||||
| b_condition.py:4 | ControlFlowNode for FunctionExpr | import | Function f | builtin-class function |
|
||||
| b_condition.py:5 | ControlFlowNode for IfExp | runtime | None | builtin-class NoneType |
|
||||
| b_condition.py:5 | ControlFlowNode for None | runtime | None | builtin-class NoneType |
|
||||
|
||||
@@ -47,10 +47,14 @@
|
||||
| a_simple.py:38 | g | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | h | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | i | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | l | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | m | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | p | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | q | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | r | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | s | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | t | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | u | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | w | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | x | Exit node for Function multi_assign_and_packing |
|
||||
| a_simple.py:38 | y | Exit node for Function multi_assign_and_packing |
|
||||
@@ -72,6 +76,11 @@
|
||||
| a_simple.py:50 | g | ControlFlowNode for g |
|
||||
| a_simple.py:51 | h | ControlFlowNode for h |
|
||||
| a_simple.py:52 | i | ControlFlowNode for i |
|
||||
| a_simple.py:54 | l | ControlFlowNode for l |
|
||||
| a_simple.py:55 | m | ControlFlowNode for m |
|
||||
| a_simple.py:56 | a | ControlFlowNode for a |
|
||||
| a_simple.py:57 | s | ControlFlowNode for s |
|
||||
| a_simple.py:58 | u | ControlFlowNode for u |
|
||||
| b_condition.py:0 | Exception | Exit node for Module code.b_condition |
|
||||
| b_condition.py:0 | TypeError | Exit node for Module code.b_condition |
|
||||
| b_condition.py:0 | __name__ | Exit node for Module code.b_condition |
|
||||
|
||||
@@ -50,3 +50,10 @@ def multi_assign_and_packing(a, b="b", c="c"):
|
||||
g
|
||||
h
|
||||
i
|
||||
l, m = (1,) + (2,)
|
||||
l
|
||||
m
|
||||
s, u = a
|
||||
s
|
||||
u
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
| test.py:5:7:5:9 | ControlFlowNode for foo | int 42 |
|
||||
| test.py:11:11:11:13 | ControlFlowNode for foo | int 1 |
|
||||
| test.py:17:11:17:13 | ControlFlowNode for foo | <MISSING pointsTo()> |
|
||||
| test.py:17:11:17:13 | ControlFlowNode for foo | int 2 |
|
||||
|
||||
@@ -14,4 +14,4 @@ def func(url):
|
||||
return # using `pass` here instead makes points-to work
|
||||
|
||||
foo = 2
|
||||
check(foo) # no points-to information
|
||||
check(foo) # Points-to was missing here. Fixed by https://github.com/Semmle/ql/pull/2922
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
| 16 | classmethod() | 17 | Function c1 |
|
||||
| 23 | classmethod() | 20 | Function c2 |
|
||||
| 24 | classmethod() | 20 | Function c2 |
|
||||
| 26 | staticmethod() | 27 | Function s1 |
|
||||
| 33 | staticmethod() | 30 | Function s2 |
|
||||
| 34 | staticmethod() | 30 | Function s2 |
|
||||
| 104 | classmethod() | 105 | Function c1 |
|
||||
| 111 | classmethod() | 108 | Function c2 |
|
||||
| 112 | classmethod() | 108 | Function c2 |
|
||||
| 114 | staticmethod() | 115 | Function s1 |
|
||||
| 121 | staticmethod() | 118 | Function s2 |
|
||||
| 122 | staticmethod() | 118 | Function s2 |
|
||||
|
||||
@@ -1 +1,8 @@
|
||||
| 6 | Property f | 7 | Function f | 11 | Function f |
|
||||
| test.py:6:5:6:16 | Function WithDecorator.x | getter | test.py:5:6:5:13 | property x |
|
||||
| test.py:11:5:11:23 | Function WithDecorator.x | setter | test.py:5:6:5:13 | property x |
|
||||
| test.py:15:5:15:16 | Function WithDecorator.x | deleter | test.py:5:6:5:13 | property x |
|
||||
| test.py:21:5:21:16 | Function WithDecoratorOnlyGetter.x | getter | test.py:20:6:20:13 | property x |
|
||||
| test.py:28:5:28:19 | Function WithoutDecorator.getx | getter | test.py:37:9:37:59 | property getx |
|
||||
| test.py:31:5:31:26 | Function WithoutDecorator.setx | setter | test.py:37:9:37:59 | property getx |
|
||||
| test.py:34:5:34:19 | Function WithoutDecorator.delx | deleter | test.py:37:9:37:59 | property getx |
|
||||
| test.py:41:5:41:19 | Function WithoutDecoratorOnlyGetter.getx | getter | test.py:44:9:44:22 | property getx |
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
|
||||
import python
|
||||
import semmle.python.types.Descriptors
|
||||
|
||||
int lineof(Object o) {
|
||||
result = o.getOrigin().getLocation().getStartLine()
|
||||
}
|
||||
|
||||
from PropertyObject p, FunctionObject getter, FunctionObject setter
|
||||
from PropertyValue p, string method_name, FunctionValue method
|
||||
where
|
||||
getter = p.getGetter() and setter = p.getSetter()
|
||||
select lineof(p), p.toString(), lineof(getter), getter.toString(), lineof(setter), setter.toString()
|
||||
|
||||
method_name = "getter" and method = p.getGetter()
|
||||
or
|
||||
method_name = "setter" and method = p.getSetter()
|
||||
or
|
||||
method_name = "deleter" and method = p.getDeleter()
|
||||
select method, method_name, p
|
||||
|
||||
@@ -1,15 +1,103 @@
|
||||
|
||||
|
||||
|
||||
class C(object):
|
||||
class WithDecorator(object):
|
||||
def __init__(self):
|
||||
self._x = None
|
||||
|
||||
@property
|
||||
def f(self):
|
||||
return self._f
|
||||
def x(self):
|
||||
"""I'm the 'x' property."""
|
||||
return self._x
|
||||
|
||||
@f.setter
|
||||
def f(self):
|
||||
return self._f
|
||||
@x.setter
|
||||
def x(self, value):
|
||||
self._x = value
|
||||
|
||||
@x.deleter
|
||||
def x(self):
|
||||
del self._x
|
||||
|
||||
class WithDecoratorOnlyGetter(object):
|
||||
|
||||
@property
|
||||
def x(self):
|
||||
return 42
|
||||
|
||||
class WithoutDecorator(object):
|
||||
def __init__(self):
|
||||
self._x = None
|
||||
|
||||
def getx(self):
|
||||
return self._x
|
||||
|
||||
def setx(self, value):
|
||||
self._x = value
|
||||
|
||||
def delx(self):
|
||||
del self._x
|
||||
|
||||
x = property(getx, setx, delx, "I'm the 'x' property.")
|
||||
|
||||
class WithoutDecoratorOnlyGetter(object):
|
||||
|
||||
def getx(self):
|
||||
return 42
|
||||
|
||||
x = property(getx)
|
||||
|
||||
class WithoutDecoratorOnlyGetterKWArg(object):
|
||||
|
||||
def getx(self):
|
||||
return 42
|
||||
|
||||
x = property(fget=getx)
|
||||
|
||||
class WithoutDecoratorOnlySetter(object):
|
||||
|
||||
def setx(self, value):
|
||||
self._x = value
|
||||
|
||||
x = property(fset=setx) # TODO: Not handled
|
||||
|
||||
class WithDecoratorOnlySetter(object):
|
||||
|
||||
x = property()
|
||||
|
||||
@x.setter
|
||||
def x(self, value):
|
||||
print('{} setting value to {}'.format(self.__class__, value))
|
||||
|
||||
class FunkyButValid(object):
|
||||
|
||||
def delx(self):
|
||||
print("deleting x")
|
||||
|
||||
x = property(fdel=delx)
|
||||
|
||||
@x.setter
|
||||
def y(self, value):
|
||||
print('setting value to {}'.format(value))
|
||||
|
||||
@y.getter
|
||||
def z(self):
|
||||
return 42
|
||||
|
||||
|
||||
wat = FunkyButValid()
|
||||
try:
|
||||
wat.x
|
||||
except AttributeError as e:
|
||||
print("x can't be read")
|
||||
del wat.x
|
||||
|
||||
try:
|
||||
wat.y
|
||||
except AttributeError as e:
|
||||
print("y can't be read")
|
||||
wat.y = 1234
|
||||
del wat.y
|
||||
|
||||
print(wat.z)
|
||||
wat.z = 10
|
||||
del wat.z
|
||||
|
||||
class D(object):
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import python
|
||||
|
||||
from ExceptFlowNode ex, Object t
|
||||
where ex.handledException(t, _, _)
|
||||
select ex.getLocation().getStartLine(), ex.toString(), t.toString()
|
||||
from ExceptFlowNode ex, Value val
|
||||
where ex.handledException(val, _, _)
|
||||
select ex.getLocation().getStartLine(), ex.toString(), val.toString()
|
||||
@@ -0,0 +1,5 @@
|
||||
| file://:0:0:0:0 | Module sys | isUsedAsModule |
|
||||
| imported.py:0:0:0:0 | Module imported | isUsedAsModule |
|
||||
| main.py:0:0:0:0 | Module main | isUsedAsScript |
|
||||
| myscript.py:0:0:0:0 | Script myscript | isUsedAsScript |
|
||||
| script:0:0:0:0 | Script script | isUsedAsScript |
|
||||
16
python/ql/test/library-tests/modules/usage/ModuleUsage.ql
Normal file
16
python/ql/test/library-tests/modules/usage/ModuleUsage.ql
Normal file
@@ -0,0 +1,16 @@
|
||||
import python
|
||||
|
||||
from ModuleValue mv, string usage
|
||||
where
|
||||
// builtin module has different name in Python 2 and 3
|
||||
not mv = Module::builtinModule() and
|
||||
(
|
||||
mv.isUsedAsModule() and usage = "isUsedAsModule"
|
||||
or
|
||||
mv.isUsedAsScript() and usage = "isUsedAsScript"
|
||||
or
|
||||
not mv.isUsedAsModule() and
|
||||
not mv.isUsedAsScript() and
|
||||
usage = "<UNKNOWN>"
|
||||
)
|
||||
select mv, usage
|
||||
6
python/ql/test/library-tests/modules/usage/imported.py
Normal file
6
python/ql/test/library-tests/modules/usage/imported.py
Normal file
@@ -0,0 +1,6 @@
|
||||
def func():
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("I could have done something interesting...")
|
||||
print("but I didn't")
|
||||
5
python/ql/test/library-tests/modules/usage/main.py
Normal file
5
python/ql/test/library-tests/modules/usage/main.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import imported
|
||||
|
||||
if __name__ == "__main__":
|
||||
imported.func()
|
||||
print('Done')
|
||||
3
python/ql/test/library-tests/modules/usage/myscript.py
Executable file
3
python/ql/test/library-tests/modules/usage/myscript.py
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
print("I'm actually a script you see ;)")
|
||||
1
python/ql/test/library-tests/modules/usage/options
Normal file
1
python/ql/test/library-tests/modules/usage/options
Normal file
@@ -0,0 +1 @@
|
||||
semmle-extractor-options: -F script
|
||||
3
python/ql/test/library-tests/modules/usage/script
Executable file
3
python/ql/test/library-tests/modules/usage/script
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
print('Under construction :)')
|
||||
@@ -1 +1 @@
|
||||
| str_fmt_test.py:5:26:5:26 | x | Right hand side of a % operator must be a mapping, not class $@. | file://:Compiled Code:0:0:0:0 | builtin-class list | list |
|
||||
| str_fmt_test.py:5:26:5:26 | x | Right hand side of a % operator must be a mapping, not class $@. | file://:0:0:0:0 | builtin-class list | list |
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
| functions_test.py:99:5:99:40 | Function __getslice__ | __getslice__ method has been deprecated since Python 2.0 |
|
||||
| functions_test.py:102:5:102:47 | Function __setslice__ | __setslice__ method has been deprecated since Python 2.0 |
|
||||
| functions_test.py:105:5:105:40 | Function __delslice__ | __delslice__ method has been deprecated since Python 2.0 |
|
||||
| functions_test.py:99:5:99:40 | Function DeprecatedSliceMethods.__getslice__ | __getslice__ method has been deprecated since Python 2.0 |
|
||||
| functions_test.py:102:5:102:47 | Function DeprecatedSliceMethods.__setslice__ | __setslice__ method has been deprecated since Python 2.0 |
|
||||
| functions_test.py:105:5:105:40 | Function DeprecatedSliceMethods.__delslice__ | __delslice__ method has been deprecated since Python 2.0 |
|
||||
|
||||
1
python/ql/test/query-tests/Imports/unused/options
Normal file
1
python/ql/test/query-tests/Imports/unused/options
Normal file
@@ -0,0 +1 @@
|
||||
semmle-extractor-options: --max-import-depth=0
|
||||
@@ -1,2 +1,3 @@
|
||||
| assert.py:5:5:5:20 | Assert | This 'assert' statement contains $@ which may have side effects. | assert.py:5:13:5:19 | Yield | an expression |
|
||||
| assert.py:8:5:8:22 | Assert | This 'assert' statement contains $@ which may have side effects. | assert.py:8:12:8:22 | Attribute() | an expression |
|
||||
| side_effect.py:5:1:5:43 | Assert | This 'assert' statement contains $@ which may have side effects. | side_effect.py:5:8:5:38 | Attribute() | an expression |
|
||||
|
||||
@@ -103,4 +103,4 @@ def error_assert_in_intermediate_branch(x):
|
||||
elif yks(x):
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
pass
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
# For now, this test lives in its own file, since including them in the top of assert.py
|
||||
# messes up the results of the refers-to/points-to analysis
|
||||
# see /home/rasmus/code/ql/python/ql/test/library-tests/PointsTo/regressions/subprocess-assert/mwe_failure.py
|
||||
import subprocess
|
||||
assert subprocess.call(['run-backup']) == 0
|
||||
@@ -1,4 +1,4 @@
|
||||
| statements_test.py:19:5:19:18 | AssignStmt | Left hand side of assignment contains 3 variables, but right hand side is a $@ of length 2. | statements_test.py:19:15:19:18 | statements_test.py:19 | tuple |
|
||||
| statements_test.py:163:5:163:23 | AssignStmt | Left hand side of assignment contains 3 variables, but right hand side is a $@ of length 5. | statements_test.py:163:13:163:23 | statements_test.py:163 | list |
|
||||
| statements_test.py:172:5:172:48 | AssignStmt | Left hand side of assignment contains 3 variables, but right hand side is a $@ of length 5. | statements_test.py:167:16:167:24 | statements_test.py:167 | tuple |
|
||||
| statements_test.py:172:5:172:48 | AssignStmt | Left hand side of assignment contains 3 variables, but right hand side is a $@ of length 6. | statements_test.py:169:16:169:26 | statements_test.py:169 | tuple |
|
||||
| statements_test.py:169:5:169:23 | AssignStmt | Left hand side of assignment contains 3 variables, but right hand side is a $@ of length 5. | statements_test.py:169:13:169:23 | statements_test.py:169 | list |
|
||||
| statements_test.py:178:5:178:48 | AssignStmt | Left hand side of assignment contains 3 variables, but right hand side is a $@ of length 5. | statements_test.py:173:16:173:24 | statements_test.py:173 | tuple |
|
||||
| statements_test.py:178:5:178:48 | AssignStmt | Left hand side of assignment contains 3 variables, but right hand side is a $@ of length 6. | statements_test.py:175:16:175:26 | statements_test.py:175 | tuple |
|
||||
|
||||
@@ -1 +1 @@
|
||||
| test.py:50:1:50:23 | For | $@ of class '$@' may be used in for-loop. | test.py:50:10:50:22 | ControlFlowNode for NonIterator() | Non-iterator | test.py:45:1:45:26 | class NonIterator | NonIterator |
|
||||
| test.py:50:1:50:23 | For | $@ of class '$@' may be used in for-loop. | test.py:50:10:50:22 | ControlFlowNode for NonIterator() | Non-iterable | test.py:45:1:45:26 | class NonIterator | NonIterator |
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
| statements_test.py:54:5:54:9 | AssignStmt | This assignment assigns a variable to itself. |
|
||||
| statements_test.py:57:9:57:19 | AssignStmt | This assignment assigns a variable to itself. |
|
||||
| statements_test.py:117:9:117:23 | AssignStmt | This assignment assigns a variable to itself. |
|
||||
| statements_test.py:119:9:119:23 | AssignStmt | This assignment assigns a variable to itself. |
|
||||
|
||||
@@ -1 +1 @@
|
||||
| statements_test.py:181:5:181:9 | Delete | Unnecessary deletion of local variable $@ in function $@. | statements_test.py:181:9:181:9 | statements_test.py:181 | x | statements_test.py:179:1:179:31 | statements_test.py:179 | error_unnecessary_delete |
|
||||
| statements_test.py:187:5:187:9 | Delete | Unnecessary deletion of local variable $@ in function $@. | statements_test.py:187:9:187:9 | statements_test.py:187 | x | statements_test.py:185:1:185:31 | statements_test.py:185 | error_unnecessary_delete |
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
| statements_test.py:63:1:63:19 | For | This 'for' statement has a redundant 'else' as no 'break' is present in the body. |
|
||||
| statements_test.py:68:1:68:13 | While | This 'while' statement has a redundant 'else' as no 'break' is present in the body. |
|
||||
| statements_test.py:65:1:65:19 | For | This 'for' statement has a redundant 'else' as no 'break' is present in the body. |
|
||||
| statements_test.py:70:1:70:13 | While | This 'while' statement has a redundant 'else' as no 'break' is present in the body. |
|
||||
|
||||
@@ -56,27 +56,29 @@ class Redundant(object):
|
||||
def __init__(self, args):
|
||||
args = args # violation
|
||||
|
||||
#Non redundant assignment
|
||||
len = len
|
||||
if sys.version_info < (3,):
|
||||
bytes = str
|
||||
else:
|
||||
bytes = bytes # Should not be flagged
|
||||
|
||||
#Pointless else clauses
|
||||
for x in range(10):
|
||||
func(x)
|
||||
else:
|
||||
do_something()
|
||||
|
||||
|
||||
while x < 10:
|
||||
func(x)
|
||||
else:
|
||||
do_something()
|
||||
|
||||
|
||||
#OK else clauses:
|
||||
for x in range(10):
|
||||
if func(x):
|
||||
break
|
||||
else:
|
||||
do_something()
|
||||
|
||||
|
||||
while x < 10:
|
||||
if func(x):
|
||||
break
|
||||
@@ -95,24 +97,24 @@ else:
|
||||
|
||||
#Not a redundant assignment if a property.
|
||||
class WithProp(object):
|
||||
|
||||
|
||||
@property
|
||||
def x(self):
|
||||
return self._x
|
||||
|
||||
|
||||
@prop.setter
|
||||
def set_x(self, x):
|
||||
side_effect(x)
|
||||
self._x = x
|
||||
|
||||
|
||||
def meth(self):
|
||||
self.x = self.x
|
||||
|
||||
|
||||
def maybe_property(x):
|
||||
x.y = x.y
|
||||
|
||||
|
||||
class WithoutProp(object):
|
||||
|
||||
|
||||
def meth(self):
|
||||
self.x = self.x
|
||||
|
||||
@@ -143,8 +145,12 @@ for e in EnumDerived:
|
||||
|
||||
class SideEffectingAttr(object):
|
||||
|
||||
def __init__(self):
|
||||
self.foo = 'foo'
|
||||
|
||||
def __setattr__(self, name, val):
|
||||
print("hello!")
|
||||
super().__setattr__(name, val)
|
||||
|
||||
s = SideEffectingAttr()
|
||||
s.foo = s.foo
|
||||
|
||||
@@ -1 +1 @@
|
||||
| 1185 |
|
||||
| 1183 |
|
||||
|
||||
Reference in New Issue
Block a user