Skip to content

Commit 5fae3a8

Browse files
committed
Python: Explain complexity of HTTPConnection.request
1 parent b213db0 commit 5fae3a8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

python/ql/src/semmle/python/web/client/StdLib.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@ class HttpConnectionHttpRequest extends Client::HttpRequest, CallNode {
2727
cls = httpConnectionClass() and
2828
func = cls.lookup("request") and
2929
this = func.getACall() and
30+
// since you can do `r = conn.request; r('GET', path)`, we need to find the origin
3031
this.getFunction().pointsTo(_, _, call_origin) and
32+
// Since HTTPSConnection is a subtype of HTTPConnection, up until this point, `cls` could be either class,
33+
// because `HTTPSConnection.request == HTTPConnection.request`. To avoid generating 2 results, we filter
34+
// on the actual class used as the constructor
3135
call_origin.getObject().pointsTo(_, constructor_call_value, constructor_call) and
3236
cls = constructor_call_value.getClass() and
3337
constructor_call = cls.getACall()
3438
)
35-
3639
}
3740

3841
override ControlFlowNode getAUrlPart() {

0 commit comments

Comments
 (0)