mirror of
https://github.com/github/codeql.git
synced 2025-12-20 02:44:30 +01:00
Python: Rewrite old Tornado tests
Now you can run them, and the examples have been adjusted so they actually work!
This commit is contained in:
@@ -0,0 +1,54 @@
|
|||||||
|
import tornado.web
|
||||||
|
|
||||||
|
|
||||||
|
class BasicHandler(tornado.web.RequestHandler):
|
||||||
|
def get(self):
|
||||||
|
self.write("BasicHandler " + self.get_argument("xss"))
|
||||||
|
|
||||||
|
def post(self):
|
||||||
|
self.write("BasicHandler (POST)")
|
||||||
|
|
||||||
|
|
||||||
|
class DeepInheritance(BasicHandler):
|
||||||
|
def get(self):
|
||||||
|
self.write("DeepInheritance" + self.get_argument("also_xss"))
|
||||||
|
|
||||||
|
|
||||||
|
class FormHandler(tornado.web.RequestHandler):
|
||||||
|
def post(self):
|
||||||
|
name = self.get_body_argument("name")
|
||||||
|
self.write(name)
|
||||||
|
|
||||||
|
|
||||||
|
class RedirectHandler(tornado.web.RequestHandler):
|
||||||
|
def get(self):
|
||||||
|
req = self.request
|
||||||
|
h = req.headers
|
||||||
|
url = h["url"]
|
||||||
|
self.redirect(url)
|
||||||
|
|
||||||
|
|
||||||
|
def make_app():
|
||||||
|
return tornado.web.Application([
|
||||||
|
(r"/basic", BasicHandler),
|
||||||
|
(r"/deep", DeepInheritance),
|
||||||
|
(r"/form", FormHandler),
|
||||||
|
(r"/redirect", RedirectHandler),
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
import tornado.ioloop
|
||||||
|
|
||||||
|
app = make_app()
|
||||||
|
app.listen(8888)
|
||||||
|
tornado.ioloop.IOLoop.current().start()
|
||||||
|
|
||||||
|
# http://localhost:8888/basic?xss=foo
|
||||||
|
# http://localhost:8888/deep?also_xss=foo
|
||||||
|
|
||||||
|
# curl -X POST http://localhost:8888/basic
|
||||||
|
# curl -X POST http://localhost:8888/deep
|
||||||
|
|
||||||
|
# curl -X POST -F "name=foo" http://localhost:8888/form
|
||||||
|
# curl -v -H 'url: http://example.com' http://localhost:8888/redirect
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
import tornado.web
|
|
||||||
|
|
||||||
class Handler1(tornado.web.RequestHandler):
|
|
||||||
def get(self):
|
|
||||||
self.write(self.get_argument("xss"))
|
|
||||||
|
|
||||||
class Handler2(tornado.web.RequestHandler):
|
|
||||||
def get(self):
|
|
||||||
args = self.get_body_arguments()
|
|
||||||
name = args[0]
|
|
||||||
self.write(name)
|
|
||||||
|
|
||||||
class Handler3(tornado.web.RequestHandler):
|
|
||||||
|
|
||||||
def get(self):
|
|
||||||
req = self.request
|
|
||||||
h = req.headers
|
|
||||||
url = h["url"]
|
|
||||||
self.redirect(url)
|
|
||||||
|
|
||||||
|
|
||||||
class DeepInheritance(Handler3):
|
|
||||||
|
|
||||||
def get(self):
|
|
||||||
self.write(self.get_argument("also_xss"))
|
|
||||||
Reference in New Issue
Block a user