Skip to content

Commit b82727d

Browse files
committed
Python: Consider routed parameter if URL pattern unknown
1 parent 16bad00 commit b82727d

File tree

2 files changed

+7
-1
lines changed
  • python/ql

2 files changed

+7
-1
lines changed

python/ql/src/experimental/semmle/python/frameworks/Flask.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ private module Flask {
117117
/** A route setup made by flask (sharing handling of URL patterns). */
118118
abstract private class FlaskRouteSetup extends HTTP::Server::RouteSetup::Range {
119119
override Parameter getARoutedParameter() {
120+
// If we don't know the URL pattern, we simply mark all parameters as a routed
121+
// parameter. This should give us more RemoteFlowSources but could also lead to
122+
// more FPs. If this turns out to be the wrong tradeoff, we can always change our mind.
123+
not exists(this.getUrlPattern()) and
124+
result = this.getARouteHandler().getArgByName(_)
125+
or
120126
exists(string name |
121127
result = this.getARouteHandler().getArgByName(name) and
122128
exists(string match |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def later_set(): # $f-:routeHandler
2424

2525

2626
@app.route(UNKNOWN_ROUTE) # $routeSetup
27-
def unkown_route(foo, bar): # $routeHandler
27+
def unkown_route(foo, bar): # $routeHandler $routedParameter=foo $routedParameter=bar
2828
return make_response("unkown_route")
2929

3030

0 commit comments

Comments
 (0)