mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Python: Add copy of extractor tests
These get to live next to the existing library and query tests, and are run as part of both the Python 2 and Python 3 language tests.
This commit is contained in:
364
python/ql/test/extractor-tests/ast/Child.expected
Normal file
364
python/ql/test/extractor-tests/ast/Child.expected
Normal file
@@ -0,0 +1,364 @@
|
||||
| test.py:0:0 | Module test | test.py:5:1 | ClassDef |
|
||||
| test.py:0:0 | Module test | test.py:11:1 | FunctionDef |
|
||||
| test.py:0:0 | Module test | test.py:14:1 | FunctionDef |
|
||||
| test.py:0:0 | Module test | test.py:17:1 | FunctionDef |
|
||||
| test.py:0:0 | Module test | test.py:51:1 | FunctionDef |
|
||||
| test.py:0:0 | Module test | test.py:96:1 | ClassDef |
|
||||
| test.py:0:0 | Module test | test.py:100:1 | AnnAssign |
|
||||
| test.py:0:0 | Module test | test.py:101:1 | AnnAssign |
|
||||
| test.py:0:0 | Module test | test.py:102:1 | AnnAssign |
|
||||
| test.py:0:0 | Module test | test.py:103:1 | AnnAssign |
|
||||
| test.py:0:0 | Module test | test.py:107:1 | ExprStmt |
|
||||
| test.py:0:0 | Module test | test.py:108:1 | ExprStmt |
|
||||
| test.py:0:0 | Module test | test.py:111:1 | ExprStmt |
|
||||
| test.py:0:0 | Module test | test.py:115:1 | ExprStmt |
|
||||
| test.py:0:0 | Module test | test.py:116:1 | ExprStmt |
|
||||
| test.py:0:0 | Module test | test.py:119:1 | FunctionDef |
|
||||
| test.py:0:0 | Module test | test.py:141:1 | ExprStmt |
|
||||
| test.py:0:0 | Module test | test.py:142:1 | ExprStmt |
|
||||
| test.py:2:2 | deco1() | test.py:2:2 | deco1 |
|
||||
| test.py:2:2 | deco1() | test.py:3:2 | deco2()() |
|
||||
| test.py:3:2 | deco2() | test.py:3:2 | deco2 |
|
||||
| test.py:3:2 | deco2()() | test.py:3:2 | deco2() |
|
||||
| test.py:3:2 | deco2()() | test.py:4:2 | Attribute() |
|
||||
| test.py:4:2 | Attribute | test.py:4:2 | Attribute |
|
||||
| test.py:4:2 | Attribute | test.py:4:2 | deco3 |
|
||||
| test.py:4:2 | Attribute() | test.py:4:2 | Attribute |
|
||||
| test.py:4:2 | Attribute() | test.py:5:1 | ClassExpr |
|
||||
| test.py:5:1 | Class C | test.py:7:5 | FunctionDef |
|
||||
| test.py:5:1 | ClassDef | test.py:2:2 | deco1() |
|
||||
| test.py:5:1 | ClassDef | test.py:5:7 | C |
|
||||
| test.py:5:1 | ClassExpr | test.py:5:1 | Class C |
|
||||
| test.py:5:1 | ClassExpr | test.py:5:9 | Base |
|
||||
| test.py:7:5 | Function __init__ | test.py:7:18 | self |
|
||||
| test.py:7:5 | Function __init__ | test.py:8:9 | Pass |
|
||||
| test.py:7:5 | FunctionDef | test.py:7:5 | FunctionExpr |
|
||||
| test.py:7:5 | FunctionDef | test.py:7:9 | __init__ |
|
||||
| test.py:7:5 | FunctionExpr | test.py:7:5 | Function __init__ |
|
||||
| test.py:10:2 | Attribute | test.py:10:2 | deco4 |
|
||||
| test.py:10:2 | Attribute() | test.py:10:2 | Attribute |
|
||||
| test.py:10:2 | Attribute()() | test.py:10:2 | Attribute() |
|
||||
| test.py:10:2 | Attribute()() | test.py:11:1 | FunctionExpr |
|
||||
| test.py:11:1 | Function f | test.py:12:5 | Pass |
|
||||
| test.py:11:1 | FunctionDef | test.py:10:2 | Attribute()() |
|
||||
| test.py:11:1 | FunctionDef | test.py:11:5 | f |
|
||||
| test.py:11:1 | FunctionExpr | test.py:11:1 | Function f |
|
||||
| test.py:14:1 | Function f | test.py:14:7 | pos0 |
|
||||
| test.py:14:1 | Function f | test.py:14:13 | pos1 |
|
||||
| test.py:14:1 | Function f | test.py:14:20 | args |
|
||||
| test.py:14:1 | Function f | test.py:14:28 | kwargs |
|
||||
| test.py:14:1 | Function f | test.py:15:5 | Pass |
|
||||
| test.py:14:1 | FunctionDef | test.py:14:1 | FunctionExpr |
|
||||
| test.py:14:1 | FunctionDef | test.py:14:5 | f |
|
||||
| test.py:14:1 | FunctionExpr | test.py:14:1 | Function f |
|
||||
| test.py:17:1 | Function simple_stmts | test.py:18:5 | Pass |
|
||||
| test.py:17:1 | Function simple_stmts | test.py:19:5 | ExprStmt |
|
||||
| test.py:17:1 | Function simple_stmts | test.py:19:13 | Delete |
|
||||
| test.py:17:1 | Function simple_stmts | test.py:19:20 | Pass |
|
||||
| test.py:17:1 | Function simple_stmts | test.py:20:5 | If |
|
||||
| test.py:17:1 | Function simple_stmts | test.py:24:5 | AssignStmt |
|
||||
| test.py:17:1 | Function simple_stmts | test.py:44:5 | ExprStmt |
|
||||
| test.py:17:1 | Function simple_stmts | test.py:45:5 | ExprStmt |
|
||||
| test.py:17:1 | Function simple_stmts | test.py:46:5 | ExprStmt |
|
||||
| test.py:17:1 | Function simple_stmts | test.py:47:5 | ExprStmt |
|
||||
| test.py:17:1 | Function simple_stmts | test.py:48:5 | ExprStmt |
|
||||
| test.py:17:1 | Function simple_stmts | test.py:49:5 | ExprStmt |
|
||||
| test.py:17:1 | FunctionDef | test.py:17:1 | FunctionExpr |
|
||||
| test.py:17:1 | FunctionDef | test.py:17:5 | simple_stmts |
|
||||
| test.py:17:1 | FunctionExpr | test.py:17:1 | Function simple_stmts |
|
||||
| test.py:19:5 | ExprStmt | test.py:19:5 | foo() |
|
||||
| test.py:19:5 | foo() | test.py:19:5 | foo |
|
||||
| test.py:19:13 | Delete | test.py:19:17 | x |
|
||||
| test.py:20:5 | If | test.py:20:8 | thing |
|
||||
| test.py:20:5 | If | test.py:21:9 | For |
|
||||
| test.py:21:9 | For | test.py:21:13 | a |
|
||||
| test.py:21:9 | For | test.py:21:18 | b |
|
||||
| test.py:21:9 | For | test.py:22:13 | Pass |
|
||||
| test.py:24:5 | AssignStmt | test.py:24:5 | tmp |
|
||||
| test.py:24:5 | AssignStmt | test.py:25:9 | Yield |
|
||||
| test.py:25:9 | Yield | test.py:25:15 | Tuple |
|
||||
| test.py:25:15 | Tuple | test.py:25:15 | IntegerLiteral |
|
||||
| test.py:25:15 | Tuple | test.py:26:9 | name |
|
||||
| test.py:25:15 | Tuple | test.py:27:9 | Attribute |
|
||||
| test.py:25:15 | Tuple | test.py:28:9 | BinaryExpr |
|
||||
| test.py:25:15 | Tuple | test.py:29:9 | BinaryExpr |
|
||||
| test.py:25:15 | Tuple | test.py:30:9 | BinaryExpr |
|
||||
| test.py:25:15 | Tuple | test.py:31:9 | Attribute |
|
||||
| test.py:25:15 | Tuple | test.py:32:9 | Subscript |
|
||||
| test.py:25:15 | Tuple | test.py:33:9 | Lambda |
|
||||
| test.py:25:15 | Tuple | test.py:34:9 | BoolExpr |
|
||||
| test.py:25:15 | Tuple | test.py:35:9 | Compare |
|
||||
| test.py:25:15 | Tuple | test.py:36:9 | DictComp |
|
||||
| test.py:25:15 | Tuple | test.py:37:9 | SetComp |
|
||||
| test.py:25:15 | Tuple | test.py:38:9 | ListComp |
|
||||
| test.py:25:15 | Tuple | test.py:39:9 | List |
|
||||
| test.py:25:15 | Tuple | test.py:40:9 | Dict |
|
||||
| test.py:25:15 | Tuple | test.py:41:9 | Tuple |
|
||||
| test.py:25:15 | Tuple | test.py:42:10 | Tuple |
|
||||
| test.py:27:9 | Attribute | test.py:27:9 | attr |
|
||||
| test.py:28:9 | BinaryExpr | test.py:28:9 | a |
|
||||
| test.py:28:9 | BinaryExpr | test.py:28:13 | b |
|
||||
| test.py:29:9 | BinaryExpr | test.py:29:9 | IntegerLiteral |
|
||||
| test.py:29:9 | BinaryExpr | test.py:29:13 | IntegerLiteral |
|
||||
| test.py:30:9 | BinaryExpr | test.py:30:9 | FloatLiteral |
|
||||
| test.py:30:9 | BinaryExpr | test.py:30:15 | IntegerLiteral |
|
||||
| test.py:31:9 | Attribute | test.py:31:9 | Attribute |
|
||||
| test.py:31:9 | Attribute | test.py:31:9 | a |
|
||||
| test.py:32:9 | Attribute | test.py:32:9 | a() |
|
||||
| test.py:32:9 | Subscript | test.py:32:9 | Attribute |
|
||||
| test.py:32:9 | Subscript | test.py:32:15 | c |
|
||||
| test.py:32:9 | a() | test.py:32:9 | a |
|
||||
| test.py:33:9 | Function lambda | test.py:33:16 | x |
|
||||
| test.py:33:9 | Function lambda | test.py:33:19 | Return |
|
||||
| test.py:33:9 | Lambda | test.py:33:9 | Function lambda |
|
||||
| test.py:33:19 | BinaryExpr | test.py:33:19 | x |
|
||||
| test.py:33:19 | BinaryExpr | test.py:33:21 | IntegerLiteral |
|
||||
| test.py:33:19 | Return | test.py:33:19 | BinaryExpr |
|
||||
| test.py:34:9 | BoolExpr | test.py:34:9 | p |
|
||||
| test.py:34:9 | BoolExpr | test.py:34:14 | BoolExpr |
|
||||
| test.py:34:14 | BoolExpr | test.py:34:14 | q |
|
||||
| test.py:34:14 | BoolExpr | test.py:34:20 | BinaryExpr |
|
||||
| test.py:34:20 | BinaryExpr | test.py:34:20 | r |
|
||||
| test.py:34:20 | BinaryExpr | test.py:34:24 | s |
|
||||
| test.py:35:9 | Compare | test.py:35:9 | a |
|
||||
| test.py:35:9 | Compare | test.py:35:13 | b |
|
||||
| test.py:35:9 | Compare | test.py:35:17 | c |
|
||||
| test.py:35:9 | Compare | test.py:35:22 | IntegerLiteral |
|
||||
| test.py:36:9 | DictComp | test.py:36:9 | Function dictcomp |
|
||||
| test.py:36:9 | DictComp | test.py:36:26 | x |
|
||||
| test.py:36:9 | For | test.py:36:9 | .0 |
|
||||
| test.py:36:9 | For | test.py:36:9 | For |
|
||||
| test.py:36:9 | For | test.py:36:11 | ExprStmt |
|
||||
| test.py:36:9 | For | test.py:36:21 | z |
|
||||
| test.py:36:9 | For | test.py:36:32 | y |
|
||||
| test.py:36:9 | For | test.py:36:37 | z |
|
||||
| test.py:36:9 | Function dictcomp | test.py:36:9 | .0 |
|
||||
| test.py:36:9 | Function dictcomp | test.py:36:9 | For |
|
||||
| test.py:36:11 | ExprStmt | test.py:36:11 | Yield |
|
||||
| test.py:36:11 | Tuple | test.py:36:11 | IntegerLiteral |
|
||||
| test.py:36:11 | Tuple | test.py:36:15 | y |
|
||||
| test.py:36:11 | Yield | test.py:36:11 | Tuple |
|
||||
| test.py:37:9 | For | test.py:37:9 | .0 |
|
||||
| test.py:37:9 | For | test.py:37:9 | For |
|
||||
| test.py:37:9 | For | test.py:37:12 | ExprStmt |
|
||||
| test.py:37:9 | For | test.py:37:22 | z |
|
||||
| test.py:37:9 | For | test.py:37:33 | y |
|
||||
| test.py:37:9 | For | test.py:37:38 | z |
|
||||
| test.py:37:9 | Function setcomp | test.py:37:9 | .0 |
|
||||
| test.py:37:9 | Function setcomp | test.py:37:9 | For |
|
||||
| test.py:37:9 | SetComp | test.py:37:9 | Function setcomp |
|
||||
| test.py:37:9 | SetComp | test.py:37:27 | x |
|
||||
| test.py:37:12 | ExprStmt | test.py:37:12 | Yield |
|
||||
| test.py:37:12 | Tuple | test.py:37:12 | IntegerLiteral |
|
||||
| test.py:37:12 | Tuple | test.py:37:15 | y |
|
||||
| test.py:37:12 | Yield | test.py:37:12 | Tuple |
|
||||
| test.py:38:9 | For | test.py:38:9 | .0 |
|
||||
| test.py:38:9 | For | test.py:38:11 | ExprStmt |
|
||||
| test.py:38:9 | For | test.py:38:20 | y |
|
||||
| test.py:38:9 | Function listcomp | test.py:38:9 | .0 |
|
||||
| test.py:38:9 | Function listcomp | test.py:38:9 | For |
|
||||
| test.py:38:9 | ListComp | test.py:38:9 | Function listcomp |
|
||||
| test.py:38:9 | ListComp | test.py:38:25 | z |
|
||||
| test.py:38:11 | BinaryExpr | test.py:38:11 | y |
|
||||
| test.py:38:11 | BinaryExpr | test.py:38:14 | IntegerLiteral |
|
||||
| test.py:38:11 | ExprStmt | test.py:38:11 | Yield |
|
||||
| test.py:38:11 | Yield | test.py:38:11 | BinaryExpr |
|
||||
| test.py:42:10 | Tuple | test.py:42:10 | IntegerLiteral |
|
||||
| test.py:44:5 | ExprStmt | test.py:44:5 | foo() |
|
||||
| test.py:44:5 | foo() | test.py:44:5 | foo |
|
||||
| test.py:44:5 | foo() | test.py:44:9 | IntegerLiteral |
|
||||
| test.py:45:5 | ExprStmt | test.py:45:5 | foo() |
|
||||
| test.py:45:5 | foo() | test.py:45:5 | foo |
|
||||
| test.py:45:5 | foo() | test.py:45:9 | Keyword |
|
||||
| test.py:45:9 | Keyword | test.py:45:11 | IntegerLiteral |
|
||||
| test.py:46:5 | ExprStmt | test.py:46:5 | foo() |
|
||||
| test.py:46:5 | foo() | test.py:46:5 | foo |
|
||||
| test.py:46:5 | foo() | test.py:46:9 | IntegerLiteral |
|
||||
| test.py:46:5 | foo() | test.py:46:11 | IntegerLiteral |
|
||||
| test.py:46:5 | foo() | test.py:46:13 | Starred |
|
||||
| test.py:46:13 | Starred | test.py:46:14 | t |
|
||||
| test.py:47:5 | ExprStmt | test.py:47:5 | foo() |
|
||||
| test.py:47:5 | foo() | test.py:47:5 | foo |
|
||||
| test.py:47:5 | foo() | test.py:47:9 | IntegerLiteral |
|
||||
| test.py:47:5 | foo() | test.py:47:11 | Keyword |
|
||||
| test.py:47:5 | foo() | test.py:47:15 | Starred |
|
||||
| test.py:47:11 | Keyword | test.py:47:13 | IntegerLiteral |
|
||||
| test.py:47:15 | Starred | test.py:47:16 | t |
|
||||
| test.py:48:5 | ExprStmt | test.py:48:5 | foo() |
|
||||
| test.py:48:5 | foo() | test.py:48:5 | foo |
|
||||
| test.py:48:5 | foo() | test.py:48:9 | IntegerLiteral |
|
||||
| test.py:48:5 | foo() | test.py:48:11 | Keyword |
|
||||
| test.py:48:5 | foo() | test.py:48:15 | Starred |
|
||||
| test.py:48:5 | foo() | test.py:48:18 | DictUnpacking |
|
||||
| test.py:48:11 | Keyword | test.py:48:13 | IntegerLiteral |
|
||||
| test.py:48:15 | Starred | test.py:48:16 | t |
|
||||
| test.py:48:18 | DictUnpacking | test.py:48:20 | d |
|
||||
| test.py:49:5 | ExprStmt | test.py:49:5 | f() |
|
||||
| test.py:49:5 | f() | test.py:49:5 | f |
|
||||
| test.py:49:5 | f() | test.py:49:7 | DictUnpacking |
|
||||
| test.py:49:7 | DictUnpacking | test.py:49:9 | d |
|
||||
| test.py:51:1 | Function compound_stmts | test.py:52:5 | If |
|
||||
| test.py:51:1 | Function compound_stmts | test.py:56:5 | While |
|
||||
| test.py:51:1 | Function compound_stmts | test.py:61:5 | For |
|
||||
| test.py:51:1 | Function compound_stmts | test.py:63:5 | With |
|
||||
| test.py:51:1 | Function compound_stmts | test.py:65:5 | Try |
|
||||
| test.py:51:1 | Function compound_stmts | test.py:69:5 | Try |
|
||||
| test.py:51:1 | Function compound_stmts | test.py:73:5 | Try |
|
||||
| test.py:51:1 | Function compound_stmts | test.py:77:5 | Try |
|
||||
| test.py:51:1 | Function compound_stmts | test.py:81:5 | Try |
|
||||
| test.py:51:1 | Function compound_stmts | test.py:87:5 | Try |
|
||||
| test.py:51:1 | FunctionDef | test.py:51:1 | FunctionExpr |
|
||||
| test.py:51:1 | FunctionDef | test.py:51:5 | compound_stmts |
|
||||
| test.py:51:1 | FunctionExpr | test.py:51:1 | Function compound_stmts |
|
||||
| test.py:52:5 | If | test.py:52:8 | cond |
|
||||
| test.py:52:5 | If | test.py:53:9 | Return |
|
||||
| test.py:52:5 | If | test.py:55:9 | Raise |
|
||||
| test.py:53:9 | Return | test.py:53:16 | x |
|
||||
| test.py:55:9 | Raise | test.py:55:15 | y |
|
||||
| test.py:56:5 | While | test.py:56:11 | True |
|
||||
| test.py:56:5 | While | test.py:57:9 | If |
|
||||
| test.py:57:9 | If | test.py:57:12 | cond |
|
||||
| test.py:57:9 | If | test.py:58:13 | Break |
|
||||
| test.py:57:9 | If | test.py:60:13 | Continue |
|
||||
| test.py:61:5 | For | test.py:61:9 | x |
|
||||
| test.py:61:5 | For | test.py:61:14 | y |
|
||||
| test.py:61:5 | For | test.py:62:9 | Pass |
|
||||
| test.py:63:5 | With | test.py:63:10 | a |
|
||||
| test.py:63:5 | With | test.py:63:15 | b |
|
||||
| test.py:63:5 | With | test.py:63:18 | With |
|
||||
| test.py:63:18 | With | test.py:63:18 | c |
|
||||
| test.py:63:18 | With | test.py:63:23 | d |
|
||||
| test.py:63:18 | With | test.py:64:9 | ExprStmt |
|
||||
| test.py:64:9 | ExprStmt | test.py:64:9 | body |
|
||||
| test.py:65:5 | Try | test.py:66:9 | ExprStmt |
|
||||
| test.py:65:5 | Try | test.py:67:5 | ExceptStmt |
|
||||
| test.py:66:9 | ExprStmt | test.py:66:9 | t1 |
|
||||
| test.py:67:5 | ExceptStmt | test.py:68:9 | ExprStmt |
|
||||
| test.py:68:9 | ExprStmt | test.py:68:9 | e1 |
|
||||
| test.py:69:5 | Try | test.py:70:9 | ExprStmt |
|
||||
| test.py:69:5 | Try | test.py:71:5 | ExceptStmt |
|
||||
| test.py:70:9 | ExprStmt | test.py:70:9 | t2 |
|
||||
| test.py:71:5 | ExceptStmt | test.py:71:12 | Exception |
|
||||
| test.py:71:5 | ExceptStmt | test.py:72:9 | ExprStmt |
|
||||
| test.py:72:9 | ExprStmt | test.py:72:9 | e2 |
|
||||
| test.py:73:5 | Try | test.py:74:9 | ExprStmt |
|
||||
| test.py:73:5 | Try | test.py:75:5 | ExceptStmt |
|
||||
| test.py:74:9 | ExprStmt | test.py:74:9 | t3 |
|
||||
| test.py:75:5 | ExceptStmt | test.py:75:12 | Exception |
|
||||
| test.py:75:5 | ExceptStmt | test.py:75:25 | ex |
|
||||
| test.py:75:5 | ExceptStmt | test.py:76:9 | ExprStmt |
|
||||
| test.py:76:9 | ExprStmt | test.py:76:9 | e3 |
|
||||
| test.py:77:5 | Try | test.py:78:9 | ExprStmt |
|
||||
| test.py:77:5 | Try | test.py:80:9 | ExprStmt |
|
||||
| test.py:78:9 | ExprStmt | test.py:78:9 | t4 |
|
||||
| test.py:80:9 | ExprStmt | test.py:80:9 | f4 |
|
||||
| test.py:81:5 | Try | test.py:82:9 | ExprStmt |
|
||||
| test.py:81:5 | Try | test.py:83:5 | ExceptStmt |
|
||||
| test.py:81:5 | Try | test.py:86:9 | ExprStmt |
|
||||
| test.py:82:9 | ExprStmt | test.py:82:9 | t5 |
|
||||
| test.py:83:5 | ExceptStmt | test.py:83:12 | Exception |
|
||||
| test.py:83:5 | ExceptStmt | test.py:83:25 | ex |
|
||||
| test.py:83:5 | ExceptStmt | test.py:84:9 | ExprStmt |
|
||||
| test.py:84:9 | ExprStmt | test.py:84:9 | e5 |
|
||||
| test.py:86:9 | ExprStmt | test.py:86:9 | f5 |
|
||||
| test.py:87:5 | Try | test.py:88:9 | ExprStmt |
|
||||
| test.py:87:5 | Try | test.py:90:9 | Try |
|
||||
| test.py:88:9 | ExprStmt | test.py:88:9 | t6 |
|
||||
| test.py:90:9 | Try | test.py:91:13 | ExprStmt |
|
||||
| test.py:90:9 | Try | test.py:93:13 | ExprStmt |
|
||||
| test.py:91:13 | ExprStmt | test.py:91:13 | t7 |
|
||||
| test.py:93:13 | ExprStmt | test.py:93:13 | f7 |
|
||||
| test.py:96:1 | Class WhyUseParens | test.py:97:5 | Pass |
|
||||
| test.py:96:1 | ClassDef | test.py:96:1 | ClassExpr |
|
||||
| test.py:96:1 | ClassDef | test.py:96:7 | WhyUseParens |
|
||||
| test.py:96:1 | ClassExpr | test.py:96:1 | Class WhyUseParens |
|
||||
| test.py:100:1 | AnnAssign | test.py:100:1 | x |
|
||||
| test.py:100:1 | AnnAssign | test.py:100:4 | IntegerLiteral |
|
||||
| test.py:101:1 | AnnAssign | test.py:101:1 | x |
|
||||
| test.py:101:1 | AnnAssign | test.py:101:4 | y |
|
||||
| test.py:102:1 | AnnAssign | test.py:102:1 | x |
|
||||
| test.py:102:1 | AnnAssign | test.py:102:4 | Dict |
|
||||
| test.py:102:4 | Dict | test.py:102:5 | KeyValuePair |
|
||||
| test.py:102:5 | KeyValuePair | test.py:102:5 | Subscript |
|
||||
| test.py:102:5 | KeyValuePair | test.py:102:13 | BinaryExpr |
|
||||
| test.py:102:5 | Subscript | test.py:102:5 | Subscript |
|
||||
| test.py:102:5 | Subscript | test.py:102:5 | y |
|
||||
| test.py:102:5 | Subscript | test.py:102:7 | a |
|
||||
| test.py:102:5 | Subscript | test.py:102:10 | b |
|
||||
| test.py:102:13 | BinaryExpr | test.py:102:13 | z |
|
||||
| test.py:102:13 | BinaryExpr | test.py:102:15 | q |
|
||||
| test.py:103:1 | AnnAssign | test.py:103:1 | x |
|
||||
| test.py:103:1 | AnnAssign | test.py:103:4 | f() |
|
||||
| test.py:103:4 | f() | test.py:103:4 | f |
|
||||
| test.py:103:4 | f() | test.py:103:6 | IntegerLiteral |
|
||||
| test.py:103:4 | f() | test.py:103:9 | Keyword |
|
||||
| test.py:103:4 | f() | test.py:103:14 | Starred |
|
||||
| test.py:103:9 | Keyword | test.py:103:11 | IntegerLiteral |
|
||||
| test.py:103:14 | Starred | test.py:103:15 | t |
|
||||
| test.py:107:1 | ExprStmt | test.py:107:1 | Fstring |
|
||||
| test.py:107:1 | Fstring | test.py:107:1 | Str |
|
||||
| test.py:107:1 | Fstring | test.py:107:12 | value |
|
||||
| test.py:107:1 | Fstring | test.py:107:22 | Str |
|
||||
| test.py:108:1 | ExprStmt | test.py:108:1 | Fstring |
|
||||
| test.py:108:1 | Fstring | test.py:108:1 | Str |
|
||||
| test.py:108:1 | Fstring | test.py:108:12 | value |
|
||||
| test.py:108:1 | Fstring | test.py:108:19 | width |
|
||||
| test.py:108:1 | Fstring | test.py:108:27 | precision |
|
||||
| test.py:108:1 | Fstring | test.py:108:37 | Str |
|
||||
| test.py:111:1 | ExprStmt | test.py:111:1 | Fstring |
|
||||
| test.py:111:1 | Fstring | test.py:111:1 | Str |
|
||||
| test.py:111:1 | Fstring | test.py:111:8 | IfExp |
|
||||
| test.py:111:1 | Fstring | test.py:111:40 | Str |
|
||||
| test.py:111:1 | Fstring | test.py:111:58 | cls |
|
||||
| test.py:111:1 | Fstring | test.py:111:61 | Str |
|
||||
| test.py:111:8 | IfExp | test.py:111:8 | Str |
|
||||
| test.py:111:8 | IfExp | test.py:111:18 | Compare |
|
||||
| test.py:111:8 | IfExp | test.py:111:35 | Str |
|
||||
| test.py:111:18 | Compare | test.py:111:18 | alen |
|
||||
| test.py:111:18 | Compare | test.py:111:25 | elen |
|
||||
| test.py:115:1 | ExprStmt | test.py:115:1 | Repr |
|
||||
| test.py:115:1 | Repr | test.py:115:2 | backticks |
|
||||
| test.py:116:1 | ExprStmt | test.py:116:1 | Repr |
|
||||
| test.py:116:1 | Repr | test.py:116:2 | Tuple |
|
||||
| test.py:116:2 | Tuple | test.py:116:2 | why |
|
||||
| test.py:116:2 | Tuple | test.py:116:7 | are |
|
||||
| test.py:116:2 | Tuple | test.py:116:12 | we |
|
||||
| test.py:116:2 | Tuple | test.py:116:16 | still |
|
||||
| test.py:116:2 | Tuple | test.py:116:23 | supporting |
|
||||
| test.py:116:2 | Tuple | test.py:116:35 | Compare |
|
||||
| test.py:116:35 | Compare | test.py:116:35 | this |
|
||||
| test.py:116:35 | Compare | test.py:116:43 | IntegerLiteral |
|
||||
| test.py:119:1 | Function numeric_literals | test.py:121:5 | AssignStmt |
|
||||
| test.py:119:1 | FunctionDef | test.py:119:1 | FunctionExpr |
|
||||
| test.py:119:1 | FunctionDef | test.py:119:5 | numeric_literals |
|
||||
| test.py:119:1 | FunctionExpr | test.py:119:1 | Function numeric_literals |
|
||||
| test.py:121:5 | AssignStmt | test.py:121:5 | tmp |
|
||||
| test.py:121:5 | AssignStmt | test.py:122:9 | Tuple |
|
||||
| test.py:122:9 | Tuple | test.py:122:9 | IntegerLiteral |
|
||||
| test.py:122:9 | Tuple | test.py:123:9 | IntegerLiteral |
|
||||
| test.py:122:9 | Tuple | test.py:124:9 | IntegerLiteral |
|
||||
| test.py:122:9 | Tuple | test.py:125:9 | IntegerLiteral |
|
||||
| test.py:122:9 | Tuple | test.py:126:9 | IntegerLiteral |
|
||||
| test.py:122:9 | Tuple | test.py:127:9 | IntegerLiteral |
|
||||
| test.py:122:9 | Tuple | test.py:128:9 | IntegerLiteral |
|
||||
| test.py:122:9 | Tuple | test.py:129:9 | FloatLiteral |
|
||||
| test.py:122:9 | Tuple | test.py:130:9 | FloatLiteral |
|
||||
| test.py:122:9 | Tuple | test.py:131:9 | IntegerLiteral |
|
||||
| test.py:122:9 | Tuple | test.py:132:9 | IntegerLiteral |
|
||||
| test.py:122:9 | Tuple | test.py:133:9 | IntegerLiteral |
|
||||
| test.py:122:9 | Tuple | test.py:134:9 | IntegerLiteral |
|
||||
| test.py:122:9 | Tuple | test.py:135:9 | IntegerLiteral |
|
||||
| test.py:122:9 | Tuple | test.py:136:9 | IntegerLiteral |
|
||||
| test.py:122:9 | Tuple | test.py:137:9 | ImaginaryLiteral |
|
||||
| test.py:141:1 | ExprStmt | test.py:141:1 | print() |
|
||||
| test.py:141:1 | print() | test.py:141:1 | print |
|
||||
| test.py:141:1 | print() | test.py:141:7 | Fstring |
|
||||
| test.py:141:7 | Fstring | test.py:141:7 | Str |
|
||||
| test.py:141:7 | Fstring | test.py:141:10 | Str |
|
||||
| test.py:141:7 | Fstring | test.py:141:15 | Str |
|
||||
| test.py:142:1 | ExprStmt | test.py:142:1 | print() |
|
||||
| test.py:142:1 | print() | test.py:142:1 | print |
|
||||
| test.py:142:1 | print() | test.py:142:7 | Fstring |
|
||||
| test.py:142:7 | Fstring | test.py:142:7 | Str |
|
||||
| test.py:142:7 | Fstring | test.py:142:10 | Str |
|
||||
| test.py:142:7 | Fstring | test.py:142:15 | Str |
|
||||
7
python/ql/test/extractor-tests/ast/Child.ql
Normal file
7
python/ql/test/extractor-tests/ast/Child.ql
Normal file
@@ -0,0 +1,7 @@
|
||||
import python
|
||||
import semmle.python.TestUtils
|
||||
|
||||
from AstNode p, AstNode c
|
||||
where p.getAChildNode() = c
|
||||
select compact_location(p), p.toString(), compact_location(c), c.toString()
|
||||
|
||||
143
python/ql/test/extractor-tests/ast/test.py
Normal file
143
python/ql/test/extractor-tests/ast/test.py
Normal file
@@ -0,0 +1,143 @@
|
||||
|
||||
@deco1
|
||||
@deco2()
|
||||
@deco3.attr1.attr2
|
||||
class C(Base):
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@deco4.attr()
|
||||
def f():
|
||||
pass
|
||||
|
||||
def f(pos0, pos1, *args, **kwargs):
|
||||
pass
|
||||
|
||||
def simple_stmts():
|
||||
pass
|
||||
foo() ; del x; pass
|
||||
if thing:
|
||||
for a in b:
|
||||
pass
|
||||
#Expressions
|
||||
tmp = (
|
||||
yield 3,
|
||||
name,
|
||||
attr.attrname,
|
||||
a + b,
|
||||
3 & 4,
|
||||
3.0 * 4,
|
||||
a.b.c.d,
|
||||
a().b[c],
|
||||
lambda x: x+1,
|
||||
p or q and r ^ s,
|
||||
a < b > c in 5,
|
||||
{ 1 : y for z in x for y in z},
|
||||
{ (1, y) for z in x for y in z},
|
||||
[ y**2 for y in z ],
|
||||
[],
|
||||
{},
|
||||
(),
|
||||
(1,),
|
||||
)
|
||||
foo(1)
|
||||
foo(a=1)
|
||||
foo(1,2,*t)
|
||||
foo(1,a=1,*t)
|
||||
foo(1,a=1,*t,**d)
|
||||
f(**d)
|
||||
|
||||
def compound_stmts():
|
||||
if cond:
|
||||
return x
|
||||
else:
|
||||
raise y
|
||||
while True:
|
||||
if cond:
|
||||
break
|
||||
else:
|
||||
continue
|
||||
for x in y:
|
||||
pass
|
||||
with a as b, c as d:
|
||||
body
|
||||
try:
|
||||
t1
|
||||
except:
|
||||
e1
|
||||
try:
|
||||
t2
|
||||
except Exception:
|
||||
e2
|
||||
try:
|
||||
t3
|
||||
except Exception as ex:
|
||||
e3
|
||||
try:
|
||||
t4
|
||||
finally:
|
||||
f4
|
||||
try:
|
||||
t5
|
||||
except Exception as ex:
|
||||
e5
|
||||
finally:
|
||||
f5
|
||||
try:
|
||||
t6
|
||||
finally:
|
||||
try:
|
||||
t7
|
||||
finally:
|
||||
f7
|
||||
|
||||
#Unusual classdef
|
||||
class WhyUseParens():
|
||||
pass
|
||||
|
||||
#Annotations
|
||||
x: 1
|
||||
x: y
|
||||
x: {y[a][b]:z-q}
|
||||
x: f(1, d=3, *t)
|
||||
|
||||
|
||||
#f-strings with format specifier
|
||||
f'result: {value:0.2f}'
|
||||
f'result: {value:{width}.{precision}}'
|
||||
|
||||
|
||||
f"Too {'many' if alen > elen else 'few'} parameters for {cls};"
|
||||
#f" actual {alen}, expected {elen}"
|
||||
|
||||
#Backticks
|
||||
`backticks`
|
||||
`why, are, we, still, supporting, this in 2019`
|
||||
|
||||
|
||||
def numeric_literals():
|
||||
# Various corner cases for numeric literals
|
||||
tmp = (
|
||||
0b00010101011111111111L,
|
||||
1_1,
|
||||
0b1_1,
|
||||
0x1_1,
|
||||
0b_010,
|
||||
0x_010,
|
||||
0_0,
|
||||
009.,
|
||||
009e005,
|
||||
00123,
|
||||
0o77777777777L,
|
||||
0777777777777L,
|
||||
0o1_1,
|
||||
0o_010,
|
||||
1_2_3.4_5_6e7_8_9,
|
||||
0_0234j
|
||||
)
|
||||
|
||||
#Grammar ambiguity in extractor version 5.4
|
||||
print(f'{"foo"}')
|
||||
print(f"{"bar"}")
|
||||
|
||||
1
python/ql/test/extractor-tests/async/AsyncFor.expected
Normal file
1
python/ql/test/extractor-tests/async/AsyncFor.expected
Normal file
@@ -0,0 +1 @@
|
||||
| 22 | For |
|
||||
4
python/ql/test/extractor-tests/async/AsyncFor.ql
Normal file
4
python/ql/test/extractor-tests/async/AsyncFor.ql
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
import python
|
||||
from AsyncFor a
|
||||
select a.getLocation().getStartLine(), a.toString()
|
||||
1
python/ql/test/extractor-tests/async/AsyncWith.expected
Normal file
1
python/ql/test/extractor-tests/async/AsyncWith.expected
Normal file
@@ -0,0 +1 @@
|
||||
| 23 | With |
|
||||
5
python/ql/test/extractor-tests/async/AsyncWith.ql
Normal file
5
python/ql/test/extractor-tests/async/AsyncWith.ql
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
import python
|
||||
from AsyncWith aw
|
||||
select aw.getLocation().getStartLine(), aw.toString()
|
||||
|
||||
1
python/ql/test/extractor-tests/async/Await.expected
Normal file
1
python/ql/test/extractor-tests/async/Await.expected
Normal file
@@ -0,0 +1 @@
|
||||
| 25 | Await |
|
||||
4
python/ql/test/extractor-tests/async/Await.ql
Normal file
4
python/ql/test/extractor-tests/async/Await.ql
Normal file
@@ -0,0 +1,4 @@
|
||||
import python
|
||||
|
||||
from Await a
|
||||
select a.getLocation().getStartLine(), a.toString()
|
||||
9
python/ql/test/extractor-tests/async/Test.expected
Normal file
9
python/ql/test/extractor-tests/async/Test.expected
Normal file
@@ -0,0 +1,9 @@
|
||||
| test.py:2:1:2:13 | Function normal | no |
|
||||
| test.py:5:7:5:21 | Function is_async | yes |
|
||||
| test.py:8:1:8:20 | Function decorator | no |
|
||||
| test.py:12:1:12:11 | Function deco | no |
|
||||
| test.py:16:7:16:23 | Function deco_async | yes |
|
||||
| test.py:21:7:21:16 | Function foo | yes |
|
||||
| visit_trailer_fp.py:1:1:1:10 | Function foo | no |
|
||||
| visit_trailer_fp.py:4:1:4:12 | Function await | no |
|
||||
| visit_trailer_fp.py:7:1:7:15 | Function bar | no |
|
||||
14
python/ql/test/extractor-tests/async/Test.ql
Normal file
14
python/ql/test/extractor-tests/async/Test.ql
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
import python
|
||||
|
||||
string async(Function f) {
|
||||
if f.isAsync() then
|
||||
result = "yes"
|
||||
else
|
||||
result = "no"
|
||||
}
|
||||
|
||||
|
||||
from Function f
|
||||
select f, async(f)
|
||||
|
||||
27
python/ql/test/extractor-tests/async/test.py
Normal file
27
python/ql/test/extractor-tests/async/test.py
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
def normal():
|
||||
pass
|
||||
|
||||
async def is_async():
|
||||
pass
|
||||
|
||||
def decorator(func):
|
||||
return func
|
||||
|
||||
@decorator
|
||||
def deco():
|
||||
pass
|
||||
|
||||
@decorator
|
||||
async def deco_async():
|
||||
pass
|
||||
|
||||
|
||||
|
||||
async def foo():
|
||||
async for x in y:
|
||||
async with a as b:
|
||||
pass
|
||||
await z
|
||||
|
||||
|
||||
8
python/ql/test/extractor-tests/async/visit_trailer_fp.py
Normal file
8
python/ql/test/extractor-tests/async/visit_trailer_fp.py
Normal file
@@ -0,0 +1,8 @@
|
||||
def foo():
|
||||
await()
|
||||
|
||||
def await():
|
||||
pass
|
||||
|
||||
def bar(await):
|
||||
return await ** 5
|
||||
2
python/ql/test/extractor-tests/basicblocks/test.expected
Normal file
2
python/ql/test/extractor-tests/basicblocks/test.expected
Normal file
@@ -0,0 +1,2 @@
|
||||
| Function g | 1 |
|
||||
| Module test | 1 |
|
||||
84
python/ql/test/extractor-tests/basicblocks/test.py
Normal file
84
python/ql/test/extractor-tests/basicblocks/test.py
Normal file
@@ -0,0 +1,84 @@
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
|
||||
def g():
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
f()
|
||||
|
||||
|
||||
4
python/ql/test/extractor-tests/basicblocks/test.ql
Normal file
4
python/ql/test/extractor-tests/basicblocks/test.ql
Normal file
@@ -0,0 +1,4 @@
|
||||
import python
|
||||
|
||||
from Scope s
|
||||
select s.toString(), count(BasicBlock bb | bb.getScope() = s)
|
||||
@@ -0,0 +1,3 @@
|
||||
| test.py:1:1:1:23 | Function my_decorator |
|
||||
| test.py:5:1:5:18 | Function my_function |
|
||||
| test.py:8:1:8:28 | Function unrelated_function |
|
||||
@@ -0,0 +1,3 @@
|
||||
import python
|
||||
|
||||
select any(Function f)
|
||||
@@ -0,0 +1,14 @@
|
||||
def my_decorator(func):
|
||||
return func
|
||||
|
||||
@my_decorator # comment
|
||||
def my_function():
|
||||
print("hello")
|
||||
|
||||
def unrelated_function(arg):
|
||||
# this uses match, so we trigger tsg parsing
|
||||
match arg:
|
||||
case _:
|
||||
print("ok")
|
||||
|
||||
my_function()
|
||||
1
python/ql/test/extractor-tests/conflicts/options
Normal file
1
python/ql/test/extractor-tests/conflicts/options
Normal file
@@ -0,0 +1 @@
|
||||
semmle-extractor-options: -r package
|
||||
5
python/ql/test/extractor-tests/conflicts/test.expected
Normal file
5
python/ql/test/extractor-tests/conflicts/test.expected
Normal file
@@ -0,0 +1,5 @@
|
||||
| package | package |
|
||||
| package.__init__ | package/__init__.py |
|
||||
| package.mod | package/mod |
|
||||
| package.mod | package/mod.py |
|
||||
| package.mod.__init__ | package/mod/__init__.py |
|
||||
4
python/ql/test/extractor-tests/conflicts/test.ql
Normal file
4
python/ql/test/extractor-tests/conflicts/test.ql
Normal file
@@ -0,0 +1,4 @@
|
||||
import python
|
||||
|
||||
from Module m
|
||||
select m.getName(), m.getPath().toString()
|
||||
1217
python/ql/test/extractor-tests/deep_graph/long_if.py
Normal file
1217
python/ql/test/extractor-tests/deep_graph/long_if.py
Normal file
File diff suppressed because it is too large
Load Diff
1
python/ql/test/extractor-tests/deep_graph/test.expected
Normal file
1
python/ql/test/extractor-tests/deep_graph/test.expected
Normal file
@@ -0,0 +1 @@
|
||||
| long_if | long_if.py |
|
||||
4
python/ql/test/extractor-tests/deep_graph/test.ql
Normal file
4
python/ql/test/extractor-tests/deep_graph/test.ql
Normal file
@@ -0,0 +1,4 @@
|
||||
import python
|
||||
|
||||
from Module m
|
||||
select m.getName(), m.getPath().toString()
|
||||
@@ -0,0 +1,5 @@
|
||||
| folder://pack | pack | pack |
|
||||
| folder://pack/inner | pack/inner | pack.inner |
|
||||
| pack/__init__.py:0:0:0:0 | pack/__init__.py | pack.__init__ |
|
||||
| pack/inner/__init__.py:0:0:0:0 | pack/inner/__init__.py | pack.inner.__init__ |
|
||||
| pack/inner/mod.py:0:0:0:0 | pack/inner/mod.py | pack.inner.mod |
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
import python
|
||||
|
||||
from Container path, string name
|
||||
where exists(ModuleValue m | m.getPath() = path and m.getName() = name)
|
||||
select path, name
|
||||
1
python/ql/test/extractor-tests/double-import/options
Normal file
1
python/ql/test/extractor-tests/double-import/options
Normal file
@@ -0,0 +1 @@
|
||||
semmle-extractor-options: -v --path . --path ./pack pack.inner.mod inner.mod
|
||||
@@ -0,0 +1,5 @@
|
||||
| pack | pack |
|
||||
| pack.__init__ | pack/__init__.py |
|
||||
| pack.inner | pack/inner |
|
||||
| pack.inner.__init__ | pack/inner/__init__.py |
|
||||
| pack.inner.mod | pack/inner/mod.py |
|
||||
4
python/ql/test/extractor-tests/double-import/test.ql
Normal file
4
python/ql/test/extractor-tests/double-import/test.ql
Normal file
@@ -0,0 +1,4 @@
|
||||
import python
|
||||
|
||||
from Module m
|
||||
select m.getName(), m.getPath().toString()
|
||||
@@ -0,0 +1,4 @@
|
||||
| exception_groups.py:4:1:6:5 | ExceptGroupStmt |
|
||||
| exception_groups.py:7:1:9:5 | ExceptGroupStmt |
|
||||
| exception_groups.py:10:1:12:5 | ExceptGroupStmt |
|
||||
| exception_groups.py:13:1:15:5 | ExceptGroupStmt |
|
||||
4
python/ql/test/extractor-tests/exceptions/ExceptGroup.ql
Normal file
4
python/ql/test/extractor-tests/exceptions/ExceptGroup.ql
Normal file
@@ -0,0 +1,4 @@
|
||||
import python
|
||||
|
||||
from ExceptGroupStmt e
|
||||
select e
|
||||
@@ -0,0 +1,2 @@
|
||||
| exception_groups.py:7:14:7:14 | g |
|
||||
| exception_groups.py:13:19:13:19 | p |
|
||||
@@ -0,0 +1,4 @@
|
||||
import python
|
||||
|
||||
from ExceptGroupStmt e
|
||||
select e.getName()
|
||||
@@ -0,0 +1,6 @@
|
||||
| exception_groups.py:4:9:4:9 | c |
|
||||
| exception_groups.py:7:9:7:9 | f |
|
||||
| exception_groups.py:10:10:10:10 | j |
|
||||
| exception_groups.py:10:13:10:13 | k |
|
||||
| exception_groups.py:13:10:13:10 | n |
|
||||
| exception_groups.py:13:13:13:13 | o |
|
||||
@@ -0,0 +1,4 @@
|
||||
import python
|
||||
|
||||
from ExceptGroupStmt e
|
||||
select e.getType()
|
||||
@@ -0,0 +1,15 @@
|
||||
try:
|
||||
a
|
||||
b
|
||||
except* c:
|
||||
d
|
||||
e
|
||||
except* f as g:
|
||||
h
|
||||
i
|
||||
except* (j, k):
|
||||
l
|
||||
m
|
||||
except* (n, o) as p:
|
||||
q
|
||||
r
|
||||
@@ -0,0 +1,2 @@
|
||||
| Script mod.py | src/pack/mod.py |
|
||||
| Script module.py | src/module.py |
|
||||
4
python/ql/test/extractor-tests/exclude-subpath/Test.ql
Normal file
4
python/ql/test/extractor-tests/exclude-subpath/Test.ql
Normal file
@@ -0,0 +1,4 @@
|
||||
import python
|
||||
|
||||
from Module m
|
||||
select m.toString(), m.getFile().toString()
|
||||
1
python/ql/test/extractor-tests/exclude-subpath/options
Normal file
1
python/ql/test/extractor-tests/exclude-subpath/options
Normal file
@@ -0,0 +1 @@
|
||||
semmle-extractor-options: -R src -Y src/test --path no-such-path
|
||||
1
python/ql/test/extractor-tests/exo_path/options
Normal file
1
python/ql/test/extractor-tests/exo_path/options
Normal file
@@ -0,0 +1 @@
|
||||
semmle-extractor-options: --path path1 -p path2 -R . --filter exclude:**/src_archive/**
|
||||
6
python/ql/test/extractor-tests/exo_path/test.expected
Normal file
6
python/ql/test/extractor-tests/exo_path/test.expected
Normal file
@@ -0,0 +1,6 @@
|
||||
| package1 | path1/package1 |
|
||||
| package1.__init__ | path1/package1/__init__.py |
|
||||
| package1.module | path1/package1/module.py |
|
||||
| package2 | path2/package2 |
|
||||
| package2.__init__ | path2/package2/__init__.py |
|
||||
| package2.module | path2/package2/module.py |
|
||||
4
python/ql/test/extractor-tests/exo_path/test.ql
Normal file
4
python/ql/test/extractor-tests/exo_path/test.ql
Normal file
@@ -0,0 +1,4 @@
|
||||
import python
|
||||
|
||||
from Module m
|
||||
select m.getName(), m.getPath().toString()
|
||||
8
python/ql/test/extractor-tests/exports/Test.expected
Normal file
8
python/ql/test/extractor-tests/exports/Test.expected
Normal file
@@ -0,0 +1,8 @@
|
||||
| Module module1 | a |
|
||||
| Module module1 | b |
|
||||
| Module module1 | c |
|
||||
| Module module1 | d |
|
||||
| Module module2 | w |
|
||||
| Module module2 | x |
|
||||
| Module module2 | y |
|
||||
| Module module2 | z |
|
||||
4
python/ql/test/extractor-tests/exports/Test.ql
Normal file
4
python/ql/test/extractor-tests/exports/Test.ql
Normal file
@@ -0,0 +1,4 @@
|
||||
import python
|
||||
|
||||
from Module m
|
||||
select m.toString(), m.getAnExport().toString()
|
||||
1
python/ql/test/extractor-tests/exports/module1.py
Normal file
1
python/ql/test/extractor-tests/exports/module1.py
Normal file
@@ -0,0 +1 @@
|
||||
__all__ = [ 'a', 'b', 'c', 'd' ]
|
||||
3
python/ql/test/extractor-tests/exports/module2.py
Normal file
3
python/ql/test/extractor-tests/exports/module2.py
Normal file
@@ -0,0 +1,3 @@
|
||||
__all__ = ( 'w', 'x', 'y', 'z' )
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
| Module bar |
|
||||
| Module foo.__init__ |
|
||||
| Module foo.bar |
|
||||
| Module foo.include_test |
|
||||
| Package foo |
|
||||
4
python/ql/test/extractor-tests/filter-option/Test.ql
Normal file
4
python/ql/test/extractor-tests/filter-option/Test.ql
Normal file
@@ -0,0 +1,4 @@
|
||||
import python
|
||||
|
||||
from Module m
|
||||
select m.toString()
|
||||
0
python/ql/test/extractor-tests/filter-option/bar.py
Normal file
0
python/ql/test/extractor-tests/filter-option/bar.py
Normal file
1
python/ql/test/extractor-tests/filter-option/options
Normal file
1
python/ql/test/extractor-tests/filter-option/options
Normal file
@@ -0,0 +1 @@
|
||||
semmle-extractor-options: -v --filter include:**/*.py --filter exclude:**/*test.py -R . --filter exclude:**/foo/exclude_this.py --filter include:**/include*.py --filter exclude:**/src_archive/**
|
||||
19
python/ql/test/extractor-tests/flags/Flags.expected
Normal file
19
python/ql/test/extractor-tests/flags/Flags.expected
Normal file
@@ -0,0 +1,19 @@
|
||||
| options.all | False |
|
||||
| options.colorize | True |
|
||||
| options.context_cost | 11 |
|
||||
| options.extract_stdlib | True |
|
||||
| options.guess | False |
|
||||
| options.help | False |
|
||||
| options.ignore_missing_modules | False |
|
||||
| options.introspect_c | False |
|
||||
| options.max_import_depth | inf |
|
||||
| options.no_symlinks | False |
|
||||
| options.no_syntax_errors | False |
|
||||
| options.none | False |
|
||||
| options.prune | True |
|
||||
| options.quiet | 0 |
|
||||
| options.respect_init | False |
|
||||
| options.split | False |
|
||||
| options.top | False |
|
||||
| options.trace_only | False |
|
||||
| options.unroll | False |
|
||||
9
python/ql/test/extractor-tests/flags/Flags.ql
Normal file
9
python/ql/test/extractor-tests/flags/Flags.ql
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
import python
|
||||
|
||||
from string k, string v
|
||||
where k.prefix(8) = "options." and
|
||||
not k.prefix(14) = "options.verbos" and
|
||||
py_flags_versioned(k, v, _)
|
||||
select k, v
|
||||
|
||||
1
python/ql/test/extractor-tests/flags/options
Normal file
1
python/ql/test/extractor-tests/flags/options
Normal file
@@ -0,0 +1 @@
|
||||
semmle-extractor-options: -R . --path no-such-path --filter exclude:**/src_archive/** --respect-init=False --max-context-cost=11 --dont-split-graph
|
||||
@@ -0,0 +1,2 @@
|
||||
| Script setup.py | folder1/setup.py |
|
||||
| Script setup.py | folder2/setup.py |
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
import python
|
||||
|
||||
from Module m
|
||||
select m.toString(), m.getFile().toString()
|
||||
@@ -0,0 +1,35 @@
|
||||
#Contents don't matter but must be the same for both files.
|
||||
|
||||
class ExtractorTest(unittest.TestCase):
|
||||
|
||||
def __init__(self, name):
|
||||
unittest.TestCase.__init__(self, name)
|
||||
self.here = os.path.dirname(__file__)
|
||||
self.module_path = os.path.abspath(os.path.join(self.here, "data"))
|
||||
self.trap_path = os.path.abspath(os.path.join(self.here, "traps"))
|
||||
|
||||
def setUp(self):
|
||||
try:
|
||||
os.makedirs(self.trap_path)
|
||||
except:
|
||||
if os.path.exists(self.trap_path):
|
||||
return
|
||||
raise
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.trap_path, ignore_errors=True)
|
||||
|
||||
def check_exists_only_and_clear(self, *module_names):
|
||||
for name in module_names:
|
||||
path = os.path.join(self.trap_path, name.replace('.', os.sep) + ".trap.gz")
|
||||
self.assertTrue(os.path.exists(path), "No trap file for " + name + " at " + path)
|
||||
os.remove(path)
|
||||
for _, _, filenames in os.walk(self.trap_path):
|
||||
filenames = [ name for name in filenames if not name.startswith("$") and name != "__builtin__.trap.gz"]
|
||||
self.assertFalse(filenames, "Some trap files remain: " + ", ".join(filenames))
|
||||
|
||||
def run_extractor(self, *args):
|
||||
argv = sys.argv
|
||||
sys.argv = [ "python_extractor" ] + ["-p", self.module_path, "-o", self.trap_path, "--omit-hash"] + list(args)
|
||||
semmle.populator.main()
|
||||
sys.argv = sys
|
||||
@@ -0,0 +1,35 @@
|
||||
#Contents don't matter but must be the same for both files.
|
||||
|
||||
class ExtractorTest(unittest.TestCase):
|
||||
|
||||
def __init__(self, name):
|
||||
unittest.TestCase.__init__(self, name)
|
||||
self.here = os.path.dirname(__file__)
|
||||
self.module_path = os.path.abspath(os.path.join(self.here, "data"))
|
||||
self.trap_path = os.path.abspath(os.path.join(self.here, "traps"))
|
||||
|
||||
def setUp(self):
|
||||
try:
|
||||
os.makedirs(self.trap_path)
|
||||
except:
|
||||
if os.path.exists(self.trap_path):
|
||||
return
|
||||
raise
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.trap_path, ignore_errors=True)
|
||||
|
||||
def check_exists_only_and_clear(self, *module_names):
|
||||
for name in module_names:
|
||||
path = os.path.join(self.trap_path, name.replace('.', os.sep) + ".trap.gz")
|
||||
self.assertTrue(os.path.exists(path), "No trap file for " + name + " at " + path)
|
||||
os.remove(path)
|
||||
for _, _, filenames in os.walk(self.trap_path):
|
||||
filenames = [ name for name in filenames if not name.startswith("$") and name != "__builtin__.trap.gz"]
|
||||
self.assertFalse(filenames, "Some trap files remain: " + ", ".join(filenames))
|
||||
|
||||
def run_extractor(self, *args):
|
||||
argv = sys.argv
|
||||
sys.argv = [ "python_extractor" ] + ["-p", self.module_path, "-o", self.trap_path, "--omit-hash"] + list(args)
|
||||
semmle.populator.main()
|
||||
sys.argv = sys
|
||||
@@ -0,0 +1 @@
|
||||
semmle-extractor-options: -R . --path no-such-path --filter exclude:**/src_archive/**
|
||||
1
python/ql/test/extractor-tests/ignore/options
Normal file
1
python/ql/test/extractor-tests/ignore/options
Normal file
@@ -0,0 +1 @@
|
||||
semmle-extractor-options: --ignore-missing-modules -r package -r dont_exist --verbose
|
||||
0
python/ql/test/extractor-tests/ignore/package/x.py
Normal file
0
python/ql/test/extractor-tests/ignore/package/x.py
Normal file
0
python/ql/test/extractor-tests/ignore/package/y.py
Normal file
0
python/ql/test/extractor-tests/ignore/package/y.py
Normal file
4
python/ql/test/extractor-tests/ignore/test.expected
Normal file
4
python/ql/test/extractor-tests/ignore/test.expected
Normal file
@@ -0,0 +1,4 @@
|
||||
| package |
|
||||
| package.__init__ |
|
||||
| package.x |
|
||||
| package.y |
|
||||
4
python/ql/test/extractor-tests/ignore/test.ql
Normal file
4
python/ql/test/extractor-tests/ignore/test.ql
Normal file
@@ -0,0 +1,4 @@
|
||||
import python
|
||||
|
||||
from Module m
|
||||
select m.getName()
|
||||
1
python/ql/test/extractor-tests/imports/module.py
Normal file
1
python/ql/test/extractor-tests/imports/module.py
Normal file
@@ -0,0 +1 @@
|
||||
x = 1
|
||||
4
python/ql/test/extractor-tests/imports/test.expected
Normal file
4
python/ql/test/extractor-tests/imports/test.expected
Normal file
@@ -0,0 +1,4 @@
|
||||
| 2 | Import | Alias | ImportMember | y |
|
||||
| 6 | Import | Alias | ImportExpr | fcntl |
|
||||
| 11 | Import | Alias | ImportExpr | __builtin__ |
|
||||
| 13 | Import | Alias | ImportExpr | __builtin__ |
|
||||
13
python/ql/test/extractor-tests/imports/test.py
Normal file
13
python/ql/test/extractor-tests/imports/test.py
Normal file
@@ -0,0 +1,13 @@
|
||||
#This use to cause an extractor failure.
|
||||
from module import (x
|
||||
as y)
|
||||
|
||||
try:
|
||||
import fcntl
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
try:
|
||||
import __builtin__
|
||||
except ImportError:
|
||||
import builtins as __builtin__
|
||||
8
python/ql/test/extractor-tests/imports/test.ql
Normal file
8
python/ql/test/extractor-tests/imports/test.ql
Normal file
@@ -0,0 +1,8 @@
|
||||
import python
|
||||
|
||||
from Import imp, Alias al
|
||||
where
|
||||
al = imp.getAName() and
|
||||
imp.getLocation().getFile().getShortName() = "test.py"
|
||||
select imp.getLocation().getStartLine(), imp.toString(), al.toString(), al.getValue().toString(),
|
||||
al.getAsname().toString()
|
||||
1
python/ql/test/extractor-tests/just_folder/options
Normal file
1
python/ql/test/extractor-tests/just_folder/options
Normal file
@@ -0,0 +1 @@
|
||||
semmle-extractor-options: test
|
||||
2
python/ql/test/extractor-tests/just_folder/test.expected
Normal file
2
python/ql/test/extractor-tests/just_folder/test.expected
Normal file
@@ -0,0 +1,2 @@
|
||||
| test | test |
|
||||
| test.__init__ | test/__init__.py |
|
||||
4
python/ql/test/extractor-tests/just_folder/test.ql
Normal file
4
python/ql/test/extractor-tests/just_folder/test.ql
Normal file
@@ -0,0 +1,4 @@
|
||||
import python
|
||||
|
||||
from Module m
|
||||
select m.getName(), m.getPath().toString()
|
||||
3
python/ql/test/extractor-tests/latin/Encoding.ql
Normal file
3
python/ql/test/extractor-tests/latin/Encoding.ql
Normal file
@@ -0,0 +1,3 @@
|
||||
import python
|
||||
from EncodingError e
|
||||
select e.toString()
|
||||
2
python/ql/test/extractor-tests/latin/Test.expected
Normal file
2
python/ql/test/extractor-tests/latin/Test.expected
Normal file
@@ -0,0 +1,2 @@
|
||||
| Module test |
|
||||
| Module test_suffix |
|
||||
3
python/ql/test/extractor-tests/latin/Test.ql
Normal file
3
python/ql/test/extractor-tests/latin/Test.ql
Normal file
@@ -0,0 +1,3 @@
|
||||
import python
|
||||
from Module m
|
||||
select m.toString()
|
||||
9
python/ql/test/extractor-tests/latin/test.py
Normal file
9
python/ql/test/extractor-tests/latin/test.py
Normal file
@@ -0,0 +1,9 @@
|
||||
# -*- coding: latin-1 -*-
|
||||
|
||||
class C(object):
|
||||
|
||||
def m(self):
|
||||
#According to https://docs.python.org/2/library/ast.html#ast.AST.col_offset
|
||||
#all column offsets are utf-8.
|
||||
#That is incorrect as the compiler passes latin-1 encoded files through untouched.
|
||||
f(unicode=u'<EFBFBD><EFBFBD><EFBFBD>'.encode('utf-8'))
|
||||
6
python/ql/test/extractor-tests/latin/test_suffix.py
Normal file
6
python/ql/test/extractor-tests/latin/test_suffix.py
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- coding: iso-latin-1-randomsuffix -*-
|
||||
|
||||
"Encodings of the form legal-encoding-randomsuffix should be treated as legal-encoding"
|
||||
|
||||
#Not ascii or utf8, if we fail back on default encodings this will fail to decode.
|
||||
""
|
||||
@@ -0,0 +1,4 @@
|
||||
| continuation |
|
||||
| feeds |
|
||||
| string_cr_conversion |
|
||||
| test |
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user