Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4248a84

Browse files
committed
Python: Move tornado tests from internal repo
1 parent fc8c1e1 commit 4248a84

12 files changed

Lines changed: 223 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
| class ErrorHandler | resources/lib/python/lib/tornado/web.py:2260 |
2+
| class FallbackHandler | resources/lib/python/lib/tornado/web.py:2806 |
3+
| class Handler1 | test.py:4 |
4+
| class Handler2 | test.py:8 |
5+
| class Handler3 | test.py:14 |
6+
| class RedirectHandler | resources/lib/python/lib/tornado/web.py:2275 |
7+
| class StaticFileHandler | resources/lib/python/lib/tornado/web.py:2319 |
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
import python
3+
4+
import semmle.python.TestUtils
5+
6+
import semmle.python.web.tornado.Tornado
7+
from ClassObject cls
8+
where cls = aTornadoRequestHandlerClass()
9+
select cls.toString(), remove_library_prefix(cls.getPyClass().getLocation())
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
| __init__ | Function __init__ | resources/lib/python/lib/tornado/web.py:168 |
2+
| _break_cycles | Function _break_cycles | resources/lib/python/lib/tornado/web.py:1025 |
3+
| _clear_headers_for_304 | Function _clear_headers_for_304 | resources/lib/python/lib/tornado/web.py:1636 |
4+
| _convert_header_value | Function _convert_header_value | resources/lib/python/lib/tornado/web.py:363 |
5+
| _decode_xsrf_token | Function _decode_xsrf_token | resources/lib/python/lib/tornado/web.py:1294 |
6+
| _get_argument | Function _get_argument | resources/lib/python/lib/tornado/web.py:479 |
7+
| _get_arguments | Function _get_arguments | resources/lib/python/lib/tornado/web.py:487 |
8+
| _get_raw_xsrf_token | Function _get_raw_xsrf_token | resources/lib/python/lib/tornado/web.py:1270 |
9+
| _handle_request_exception | Function _handle_request_exception | resources/lib/python/lib/tornado/web.py:1581 |
10+
| _log | Function _log | resources/lib/python/lib/tornado/web.py:1568 |
11+
| _request_summary | Function _request_summary | resources/lib/python/lib/tornado/web.py:1577 |
12+
| _stack_context_handle_exception | Function _stack_context_handle_exception | resources/lib/python/lib/tornado/web.py:1493 |
13+
| _ui_method | Function _ui_method | resources/lib/python/lib/tornado/web.py:1633 |
14+
| _ui_module | Function _ui_module | resources/lib/python/lib/tornado/web.py:1623 |
15+
| add_header | Function add_header | resources/lib/python/lib/tornado/web.py:343 |
16+
| check_etag_header | Function check_etag_header | resources/lib/python/lib/tornado/web.py:1452 |
17+
| check_xsrf_cookie | Function check_xsrf_cookie | resources/lib/python/lib/tornado/web.py:1330 |
18+
| clear | Function clear | resources/lib/python/lib/tornado/web.py:288 |
19+
| clear_all_cookies | Function clear_all_cookies | resources/lib/python/lib/tornado/web.py:597 |
20+
| clear_cookie | Function clear_cookie | resources/lib/python/lib/tornado/web.py:582 |
21+
| clear_header | Function clear_header | resources/lib/python/lib/tornado/web.py:352 |
22+
| compute_etag | Function compute_etag | resources/lib/python/lib/tornado/web.py:1428 |
23+
| create_signed_value | Function create_signed_value | resources/lib/python/lib/tornado/web.py:642 |
24+
| create_template_loader | Function create_template_loader | resources/lib/python/lib/tornado/web.py:916 |
25+
| data_received | Function data_received | resources/lib/python/lib/tornado/web.py:1561 |
26+
| decode_argument | Function decode_argument | resources/lib/python/lib/tornado/web.py:500 |
27+
| delete | Function delete | resources/lib/python/lib/tornado/web.py:230 |
28+
| finish | Function finish | resources/lib/python/lib/tornado/web.py:985 |
29+
| flush | Function flush | resources/lib/python/lib/tornado/web.py:937 |
30+
| get | Function get | resources/lib/python/lib/tornado/web.py:224 |
31+
| get_argument | Function get_argument | resources/lib/python/lib/tornado/web.py:395 |
32+
| get_arguments | Function get_arguments | resources/lib/python/lib/tornado/web.py:408 |
33+
| get_body_argument | Function get_body_argument | resources/lib/python/lib/tornado/web.py:423 |
34+
| get_body_arguments | Function get_body_arguments | resources/lib/python/lib/tornado/web.py:440 |
35+
| get_browser_locale | Function get_browser_locale | resources/lib/python/lib/tornado/web.py:1127 |
36+
| get_cookie | Function get_cookie | resources/lib/python/lib/tornado/web.py:525 |
37+
| get_current_user | Function get_current_user | resources/lib/python/lib/tornado/web.py:1191 |
38+
| get_login_url | Function get_login_url | resources/lib/python/lib/tornado/web.py:1198 |
39+
| get_query_argument | Function get_query_argument | resources/lib/python/lib/tornado/web.py:451 |
40+
| get_query_arguments | Function get_query_arguments | resources/lib/python/lib/tornado/web.py:468 |
41+
| get_secure_cookie | Function get_secure_cookie | resources/lib/python/lib/tornado/web.py:665 |
42+
| get_secure_cookie_key_version | Function get_secure_cookie_key_version | resources/lib/python/lib/tornado/web.py:688 |
43+
| get_status | Function get_status | resources/lib/python/lib/tornado/web.py:329 |
44+
| get_template_namespace | Function get_template_namespace | resources/lib/python/lib/tornado/web.py:893 |
45+
| get_template_path | Function get_template_path | resources/lib/python/lib/tornado/web.py:1206 |
46+
| get_user_locale | Function get_user_locale | resources/lib/python/lib/tornado/web.py:1117 |
47+
| head | Function head | resources/lib/python/lib/tornado/web.py:221 |
48+
| initialize | Function initialize | resources/lib/python/lib/tornado/web.py:195 |
49+
| log_exception | Function log_exception | resources/lib/python/lib/tornado/web.py:1603 |
50+
| on_connection_close | Function on_connection_close | resources/lib/python/lib/tornado/web.py:269 |
51+
| on_finish | Function on_finish | resources/lib/python/lib/tornado/web.py:259 |
52+
| options | Function options | resources/lib/python/lib/tornado/web.py:239 |
53+
| patch | Function patch | resources/lib/python/lib/tornado/web.py:233 |
54+
| post | Function post | resources/lib/python/lib/tornado/web.py:227 |
55+
| prepare | Function prepare | resources/lib/python/lib/tornado/web.py:242 |
56+
| put | Function put | resources/lib/python/lib/tornado/web.py:236 |
57+
| redirect | Function redirect | resources/lib/python/lib/tornado/web.py:698 |
58+
| render | Function render | resources/lib/python/lib/tornado/web.py:746 |
59+
| render_embed_css | Function render_embed_css | resources/lib/python/lib/tornado/web.py:859 |
60+
| render_embed_js | Function render_embed_js | resources/lib/python/lib/tornado/web.py:830 |
61+
| render_linked_css | Function render_linked_css | resources/lib/python/lib/tornado/web.py:839 |
62+
| render_linked_js | Function render_linked_js | resources/lib/python/lib/tornado/web.py:810 |
63+
| render_string | Function render_string | resources/lib/python/lib/tornado/web.py:868 |
64+
| require_setting | Function require_setting | resources/lib/python/lib/tornado/web.py:1418 |
65+
| reverse_url | Function reverse_url | resources/lib/python/lib/tornado/web.py:1424 |
66+
| send_error | Function send_error | resources/lib/python/lib/tornado/web.py:1030 |
67+
| set_cookie | Function set_cookie | resources/lib/python/lib/tornado/web.py:538 |
68+
| set_default_headers | Function set_default_headers | resources/lib/python/lib/tornado/web.py:300 |
69+
| set_etag_header | Function set_etag_header | resources/lib/python/lib/tornado/web.py:1441 |
70+
| set_header | Function set_header | resources/lib/python/lib/tornado/web.py:333 |
71+
| set_secure_cookie | Function set_secure_cookie | resources/lib/python/lib/tornado/web.py:613 |
72+
| set_status | Function set_status | resources/lib/python/lib/tornado/web.py:310 |
73+
| static_url | Function static_url | resources/lib/python/lib/tornado/web.py:1383 |
74+
| write | Function write | resources/lib/python/lib/tornado/web.py:716 |
75+
| write_error | Function write_error | resources/lib/python/lib/tornado/web.py:1069 |
76+
| xsrf_form_html | Function xsrf_form_html | resources/lib/python/lib/tornado/web.py:1367 |
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
import python
3+
4+
import semmle.python.TestUtils
5+
6+
import semmle.python.web.tornado.Tornado
7+
8+
from FunctionObject func, string name
9+
where func = getTornadoRequestHandlerMethod(name) and
10+
/* Compatibility hack to make tests pass on both 1.20 and 1.21 */
11+
not name = "_execute"
12+
select name, func.toString(), remove_library_prefix(func.getFunction().getLocation())
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
| resources/lib/python/lib/tornado/web.py:2316 | to_url | externally controlled string |
2+
| resources/lib/python/lib/tornado/web.py:2471 | chunk | externally controlled string |
3+
| resources/lib/python/lib/tornado/web.py:2597 | BinaryExpr | externally controlled string |
4+
| test.py:6 | Attribute() | externally controlled string |
5+
| test.py:12 | name | externally controlled string |
6+
| test.py:20 | url | externally controlled string |
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
import python
3+
4+
import semmle.python.web.HttpRequest
5+
import semmle.python.web.HttpResponse
6+
import semmle.python.security.strings.Untrusted
7+
import semmle.python.TestUtils
8+
9+
from TaintSink sink, TaintKind kind
10+
where sink.sinks(kind)
11+
select remove_library_prefix(sink.getLocation()), sink.(ControlFlowNode).getNode().toString(), kind
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
| resources/lib/python/lib/tornado/web.py:406 | Attribute | tornado.request.HttpRequest |
2+
| resources/lib/python/lib/tornado/web.py:449 | Attribute | tornado.request.HttpRequest |
3+
| resources/lib/python/lib/tornado/web.py:2313 | Attribute | tornado.request.HttpRequest |
4+
| resources/lib/python/lib/tornado/web.py:2315 | Attribute | tornado.request.HttpRequest |
5+
| resources/lib/python/lib/tornado/web.py:2421 | Attribute | tornado.request.HttpRequest |
6+
| resources/lib/python/lib/tornado/web.py:2476 | Attribute | tornado.request.HttpRequest |
7+
| resources/lib/python/lib/tornado/web.py:2522 | Attribute | tornado.request.HttpRequest |
8+
| resources/lib/python/lib/tornado/web.py:2527 | Attribute | tornado.request.HttpRequest |
9+
| resources/lib/python/lib/tornado/web.py:2596 | Attribute | tornado.request.HttpRequest |
10+
| resources/lib/python/lib/tornado/web.py:2597 | Attribute | tornado.request.HttpRequest |
11+
| resources/lib/python/lib/tornado/web.py:2728 | Attribute | tornado.request.HttpRequest |
12+
| resources/lib/python/lib/tornado/web.py:2826 | Attribute | tornado.request.HttpRequest |
13+
| test.py:6 | Attribute() | externally controlled string |
14+
| test.py:10 | Attribute() | [externally controlled string] |
15+
| test.py:17 | Attribute | tornado.request.HttpRequest |
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
import python
3+
4+
import semmle.python.TestUtils
5+
6+
import semmle.python.web.HttpRequest
7+
import semmle.python.web.HttpResponse
8+
import semmle.python.security.strings.Untrusted
9+
10+
11+
from TaintSource src, TaintKind kind
12+
where src.isSourceOf(kind)
13+
select remove_library_prefix(src.getLocation()), src.(ControlFlowNode).getNode().toString(), kind
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
| resources/lib/python/lib/tornado/web.py:406 | Attribute | tornado.request.HttpRequest |
2+
| resources/lib/python/lib/tornado/web.py:406 | Attribute | {[externally controlled string]} |
3+
| resources/lib/python/lib/tornado/web.py:449 | Attribute | tornado.request.HttpRequest |
4+
| resources/lib/python/lib/tornado/web.py:449 | Attribute | {[externally controlled string]} |
5+
| resources/lib/python/lib/tornado/web.py:2313 | Attribute | tornado.request.HttpRequest |
6+
| resources/lib/python/lib/tornado/web.py:2313 | Attribute | {[externally controlled string]} |
7+
| resources/lib/python/lib/tornado/web.py:2315 | Attribute | tornado.request.HttpRequest |
8+
| resources/lib/python/lib/tornado/web.py:2315 | Attribute | {[externally controlled string]} |
9+
| resources/lib/python/lib/tornado/web.py:2421 | Attribute | tornado.request.HttpRequest |
10+
| resources/lib/python/lib/tornado/web.py:2421 | Attribute | {externally controlled string} |
11+
| resources/lib/python/lib/tornado/web.py:2421 | Attribute() | externally controlled string |
12+
| resources/lib/python/lib/tornado/web.py:2422 | range_header | externally controlled string |
13+
| resources/lib/python/lib/tornado/web.py:2425 | range_header | externally controlled string |
14+
| resources/lib/python/lib/tornado/web.py:2476 | Attribute | tornado.request.HttpRequest |
15+
| resources/lib/python/lib/tornado/web.py:2522 | Attribute | tornado.request.HttpRequest |
16+
| resources/lib/python/lib/tornado/web.py:2522 | Attribute | {externally controlled string} |
17+
| resources/lib/python/lib/tornado/web.py:2522 | Attribute() | externally controlled string |
18+
| resources/lib/python/lib/tornado/web.py:2527 | Attribute | tornado.request.HttpRequest |
19+
| resources/lib/python/lib/tornado/web.py:2527 | Attribute | {externally controlled string} |
20+
| resources/lib/python/lib/tornado/web.py:2527 | Attribute() | externally controlled string |
21+
| resources/lib/python/lib/tornado/web.py:2528 | ims_value | externally controlled string |
22+
| resources/lib/python/lib/tornado/web.py:2529 | ims_value | externally controlled string |
23+
| resources/lib/python/lib/tornado/web.py:2596 | Attribute | tornado.request.HttpRequest |
24+
| resources/lib/python/lib/tornado/web.py:2597 | Attribute | tornado.request.HttpRequest |
25+
| resources/lib/python/lib/tornado/web.py:2728 | Attribute | tornado.request.HttpRequest |
26+
| resources/lib/python/lib/tornado/web.py:2728 | Attribute | {[externally controlled string]} |
27+
| resources/lib/python/lib/tornado/web.py:2826 | Attribute | tornado.request.HttpRequest |
28+
| test.py:6 | Attribute() | externally controlled string |
29+
| test.py:10 | Attribute() | [externally controlled string] |
30+
| test.py:11 | Subscript | externally controlled string |
31+
| test.py:11 | args | [externally controlled string] |
32+
| test.py:12 | name | externally controlled string |
33+
| test.py:17 | Attribute | tornado.request.HttpRequest |
34+
| test.py:18 | Attribute | {externally controlled string} |
35+
| test.py:18 | req | tornado.request.HttpRequest |
36+
| test.py:19 | Subscript | externally controlled string |
37+
| test.py:19 | h | {externally controlled string} |
38+
| test.py:20 | url | externally controlled string |
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
import python
3+
4+
import semmle.python.TestUtils
5+
6+
import semmle.python.web.HttpRequest
7+
import semmle.python.web.HttpResponse
8+
import semmle.python.security.strings.Untrusted
9+
10+
from TaintedNode node
11+
// Add this restriction to keep Python2 and 3 results the same.
12+
where not exists(node.getContext().getCaller())
13+
select remove_library_prefix(node.getLocation()), node.getAstNode().toString(), node.getTaintKind()
14+

0 commit comments

Comments
 (0)