mirror of
https://github.com/github/codeql.git
synced 2026-05-05 21:55:19 +02:00
Python: Add 2/3 specific query tests.
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
| test.py:5:11:5:11 | x | x may have a different value in Python 3, as the $@ will not be in scope. | test.py:4:12:4:12 | x | list comprehension variable |
|
||||
| test.py:10:11:10:11 | y | y may have a different value in Python 3, as the $@ will not be in scope. | test.py:9:12:9:12 | y | list comprehension variable |
|
||||
@@ -0,0 +1 @@
|
||||
Variables/LeakingListComprehension.ql
|
||||
49
python/ql/test/2/query-tests/Variables/LeakyComp/test.py
Normal file
49
python/ql/test/2/query-tests/Variables/LeakyComp/test.py
Normal file
@@ -0,0 +1,49 @@
|
||||
from __future__ import print_function
|
||||
|
||||
def undefined_in_3():
|
||||
[x for x in range(3)]
|
||||
print(x)
|
||||
|
||||
def different_in_3():
|
||||
y = 10
|
||||
[y for y in range(3)]
|
||||
print(y)
|
||||
|
||||
def ok():
|
||||
[z for z in range(4)]
|
||||
|
||||
#FP observed in sembuild
|
||||
def use_in_loop(seq):
|
||||
[x for x in range(3)]
|
||||
for x in seq:
|
||||
use(x) #x redefined -- fine in 2 and 3.
|
||||
|
||||
def test_6395(dev):
|
||||
ret = {}
|
||||
|
||||
res = foo(dev)
|
||||
if not res:
|
||||
return False
|
||||
|
||||
for line in res.splitlines(): # pylint: disable=no-member
|
||||
line = line.strip()
|
||||
if not line:
|
||||
continue
|
||||
|
||||
key, val = [val.strip() for val in bar(line)]
|
||||
if not (key and val):
|
||||
continue
|
||||
|
||||
mval = None
|
||||
if ' ' in val:
|
||||
rval, mval = [val.strip() for val in bar(val)]
|
||||
mval = mval[1:-1]
|
||||
else:
|
||||
rval = val
|
||||
|
||||
return ret
|
||||
|
||||
def test_6441(seq):
|
||||
for var in seq:
|
||||
foo(var)
|
||||
[var for var in bar()]
|
||||
Reference in New Issue
Block a user