Skip to content

Commit a33a8fd

Browse files
committed
Python: Support flask.blueprints.Blueprint
Thanks to @haby0 who originally proposed this as part of #6977
1 parent e889568 commit a33a8fd

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ module Flask {
7373
*/
7474
module Blueprint {
7575
/** Gets a reference to the `flask.Blueprint` class. */
76-
API::Node classRef() { result = API::moduleImport("flask").getMember("Blueprint") }
76+
API::Node classRef() {
77+
result = API::moduleImport("flask").getMember("Blueprint")
78+
or
79+
result = API::moduleImport("flask").getMember("blueprints").getMember("Blueprint")
80+
}
7781

7882
/** Gets a reference to an instance of `flask.Blueprint`. */
7983
API::Node instance() { result = classRef().getReturn() }

python/ql/test/library-tests/frameworks/flask/routing_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ def bp1_example(foo): # $ requestHandler routedParameter=foo
105105

106106
app.register_blueprint(bp1) # by default, URLs of blueprints are not prefixed
107107

108-
109-
bp2 = flask.Blueprint("bp2", __name__)
108+
import flask.blueprints
109+
bp2 = flask.blueprints.Blueprint("bp2", __name__)
110110

111111
@bp2.route("/example") # $ routeSetup="/example"
112112
def bp2_example(): # $ requestHandler

0 commit comments

Comments
 (0)