mirror of
https://github.com/github/codeql.git
synced 2026-05-03 12:45:27 +02:00
Merge pull request #1636 from markshannon/python-api-odds-and-ends
Python: Assorted improvements to API.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
| file://:0:0:0:0 | builtin-class bool | bool |
|
||||
| file://:0:0:0:0 | builtin-class classmethod | classmethod |
|
||||
| file://:0:0:0:0 | builtin-class float | float |
|
||||
| file://:0:0:0:0 | builtin-class int | int |
|
||||
| file://:0:0:0:0 | builtin-class object | object |
|
||||
15
python/ql/test/library-tests/PointsTo/api/ClassValue.ql
Normal file
15
python/ql/test/library-tests/PointsTo/api/ClassValue.ql
Normal file
@@ -0,0 +1,15 @@
|
||||
import python
|
||||
|
||||
from ClassValue cls, string description
|
||||
where
|
||||
cls = ClassValue::bool() and description = "bool"
|
||||
or
|
||||
cls = ClassValue::int_() and description = "int"
|
||||
or
|
||||
cls = ClassValue::float_() and description = "float"
|
||||
or
|
||||
cls = ClassValue::classmethod() and description = "classmethod"
|
||||
or
|
||||
cls = ClassValue::bool().getMro().getItem(2) and description = "object"
|
||||
|
||||
select cls, description
|
||||
16
python/ql/test/library-tests/PointsTo/api/Constants.expected
Normal file
16
python/ql/test/library-tests/PointsTo/api/Constants.expected
Normal file
@@ -0,0 +1,16 @@
|
||||
| 1 | file://:0:0:0:0 | int 1 |
|
||||
| 2 | file://:0:0:0:0 | int 2 |
|
||||
| 3 | file://:0:0:0:0 | int 3 |
|
||||
| 4 | file://:0:0:0:0 | int 4 |
|
||||
| 5 | file://:0:0:0:0 | int 5 |
|
||||
| 6 | file://:0:0:0:0 | int 6 |
|
||||
| 7 | file://:0:0:0:0 | int 7 |
|
||||
| 8 | file://:0:0:0:0 | int 8 |
|
||||
| 9 | file://:0:0:0:0 | int 9 |
|
||||
| 10 | file://:0:0:0:0 | int 10 |
|
||||
| 1000 | file://:0:0:0:0 | int 1000 |
|
||||
| 1004 | file://:0:0:0:0 | int 1004 |
|
||||
| b'b' | file://:0:0:0:0 | 'b' |
|
||||
| b'd' | file://:0:0:0:0 | 'd' |
|
||||
| u'a' | file://:0:0:0:0 | 'a' |
|
||||
| u'c' | file://:0:0:0:0 | 'c' |
|
||||
20
python/ql/test/library-tests/PointsTo/api/Constants.ql
Normal file
20
python/ql/test/library-tests/PointsTo/api/Constants.ql
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
import python
|
||||
|
||||
from string txt, Value val
|
||||
where
|
||||
exists(string s |
|
||||
txt = "u'" + s + "'" and val = Value::forUnicode(s)
|
||||
or
|
||||
txt = "b'" + s + "'" and val = Value::forBytes(s)
|
||||
|
|
||||
s = "a" or s = "b" or s = "c" or s = "d"
|
||||
)
|
||||
or
|
||||
exists(int i |
|
||||
txt = i.toString() and val = Value::forInt(i)
|
||||
|
|
||||
i in [1..10] or i in [1000..1010]
|
||||
)
|
||||
|
||||
select txt, val
|
||||
@@ -0,0 +1,5 @@
|
||||
| file://:0:0:0:0 | Builtin-function exit | exit |
|
||||
| file://:0:0:0:0 | Builtin-function len | len |
|
||||
| file://:0:0:0:0 | builtin method append | list.append |
|
||||
| test.py:8:1:8:10 | Function foo | foo |
|
||||
| test.py:13:5:13:19 | Function C.meth | C.meth |
|
||||
16
python/ql/test/library-tests/PointsTo/api/QualifedNames.ql
Normal file
16
python/ql/test/library-tests/PointsTo/api/QualifedNames.ql
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
import python
|
||||
|
||||
from FunctionValue v, string name
|
||||
where name = v.getQualifiedName() and
|
||||
(
|
||||
v = Value::named("len")
|
||||
or
|
||||
v instanceof PythonFunctionValue
|
||||
or
|
||||
v = Value::named("sys.exit")
|
||||
or
|
||||
v = Value::named("list").(ClassValue).lookup("append")
|
||||
)
|
||||
|
||||
select v, name
|
||||
4
python/ql/test/library-tests/PointsTo/api/Value.expected
Normal file
4
python/ql/test/library-tests/PointsTo/api/Value.expected
Normal file
@@ -0,0 +1,4 @@
|
||||
| file://:0:0:0:0 | builtin-class ValueError | ValueError |
|
||||
| file://:0:0:0:0 | builtin-class bool | bool |
|
||||
| file://:0:0:0:0 | builtin-class slice | slice |
|
||||
| file://:0:0:0:0 | list object | sys.argv |
|
||||
12
python/ql/test/library-tests/PointsTo/api/Value.ql
Normal file
12
python/ql/test/library-tests/PointsTo/api/Value.ql
Normal file
@@ -0,0 +1,12 @@
|
||||
import python
|
||||
|
||||
from Value val, string name
|
||||
where
|
||||
val = Value::named(name)
|
||||
and
|
||||
(
|
||||
name = "bool" or name = "sys" or name = "sys.argv" or
|
||||
name = "ValueError" or name = "slice"
|
||||
)
|
||||
|
||||
select val, name
|
||||
14
python/ql/test/library-tests/PointsTo/api/test.py
Normal file
14
python/ql/test/library-tests/PointsTo/api/test.py
Normal file
@@ -0,0 +1,14 @@
|
||||
u"a"
|
||||
b"b"
|
||||
u"c"
|
||||
b"d"
|
||||
1000
|
||||
1004
|
||||
|
||||
def foo():
|
||||
pass
|
||||
|
||||
class C(object):
|
||||
|
||||
def meth(self):
|
||||
pass
|
||||
Reference in New Issue
Block a user