Skip to content

Commit ac411f1

Browse files
committed
Second round feedback
1 parent 0483b80 commit ac411f1

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

python/ql/lib/semmle/python/frameworks/Bottle.qll

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ module Bottle {
2727
*/
2828
module App {
2929
/** Gets a reference to a Bottle application (an instance of `bottle.Bottle`) */
30-
API::Node instance() { result = bottle().getMember("Bottle").getReturn() }
31-
32-
/** Gets a reference to a Bottle application (an instance of `bottle.app`) */
33-
API::Node app() { result = bottle().getMember("app").getReturn() }
30+
API::Node app() { result = bottle().getMember(["Bottle", "app"]).getReturn() }
3431
}
3532

3633
/** Provides models for functions that are possible "views" */
@@ -42,13 +39,13 @@ module Bottle {
4239
ViewCallable() { this = any(BottleRouteSetup rs).getARequestHandler() }
4340
}
4441

42+
/** Get methods that reprsent a route in Bottle */
4543
string routeMethods() { result = ["route", "get", "post", "put", "delete", "patch"] }
4644

4745
private class BottleRouteSetup extends Http::Server::RouteSetup::Range, DataFlow::CallCfgNode {
4846
BottleRouteSetup() {
4947
this =
5048
[
51-
App::instance().getMember(routeMethods()).getACall(),
5249
App::app().getMember(routeMethods()).getACall(),
5350
bottle().getMember(routeMethods()).getACall()
5451
]
@@ -68,8 +65,10 @@ module Bottle {
6865

6966
/** Provides models for the `bottle.response` module */
7067
module Response {
71-
/** Gets a reference to the `bottle.response` module. */
72-
API::Node response() { result = bottle().getMember("response") }
68+
/** Gets a reference to the `bottle.response` module or instantiation of Bottle Response class. */
69+
API::Node response() {
70+
result = [bottle().getMember("response"), bottle().getMember("Response").getReturn()]
71+
}
7372

7473
/** A response returned by a view callable. */
7574
class BottleReturnResponse extends Http::Server::HttpResponse::Range {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Source: https://bottlepy.org/docs/dev/tutorial.html#the-application-object
2+
from bottle import Bottle, run
3+
4+
app = Bottle()
5+
6+
@app.route('/hello') # $ routeSetup="/hello"
7+
def hello(): # $ requestHandler
8+
return "Hello World!" # $ HttpResponse responseBody="Hello World!" mimetype=text/html
9+
10+
if __name__ == '__main__':
11+
app.run(host='localhost', port=8080)

0 commit comments

Comments
 (0)