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

Skip to content

Commit 9170d85

Browse files
committed
Python: Fix falcon sources to only be source if a route is attached.
1 parent 9e268d7 commit 9170d85

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

python/ql/src/semmle/python/web/falcon/General.qll

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ private predicate api_route(CallNode route_call, ControlFlowNode route, ClassObj
1616
route_call.getArg(1).refersTo(_, resource, _)
1717
}
1818

19+
private predicate route(FalconRoute route, Function target, string funcname) {
20+
route.getResourceClass().lookupAttribute("on_" + funcname).(FunctionObject).getFunction() = target
21+
}
22+
1923
class FalconRoute extends ControlFlowNode {
2024

2125
FalconRoute() {
@@ -33,28 +37,24 @@ class FalconRoute extends ControlFlowNode {
3337
api_route(this, _, result)
3438
}
3539

36-
FalconHandlerFunction getHandlerFunction() {
37-
result = this.getResourceClass().lookupAttribute(_).(FunctionObject).getFunction()
38-
}
39-
4040
FalconHandlerFunction getHandlerFunction(string method) {
41-
result = this.getResourceClass().lookupAttribute("on_" + method).(FunctionObject).getFunction()
41+
route(this, result, method)
4242
}
4343

4444
}
4545

4646
class FalconHandlerFunction extends Function {
4747

48-
string method;
49-
5048
FalconHandlerFunction() {
51-
exists(ClassObject resource |
52-
resource.lookupAttribute("on_" + method).(FunctionObject).getFunction() = this
53-
)
49+
route(_, this, _)
50+
}
51+
52+
private string methodName() {
53+
route(_, this, result)
5454
}
5555

5656
string getMethod() {
57-
result = method.toUpperCase()
57+
result = this.methodName().toUpperCase()
5858
}
5959

6060
Parameter getRequest() {

python/ql/src/semmle/python/web/falcon/Response.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class FalconResponseBodySink extends TaintSink {
4040
}
4141

4242
override predicate sinks(TaintKind kind) {
43-
kind instanceof ExternalStringKind
43+
kind instanceof StringKind
4444
}
4545

4646
}

0 commit comments

Comments
 (0)