Skip to content

Commit c78ba47

Browse files
authored
Python: Clean up a few verbose casts
1 parent 847faf5 commit c78ba47

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

python/ql/src/semmle/python/Concepts.qll

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ module HTTP {
345345
/** Gets the URL pattern for this route, if it can be statically determined. */
346346
string getUrlPattern() {
347347
exists(StrConst str |
348-
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(this.getUrlPatternArg()) and
348+
this.getUrlPatternArg().getALocalSource() = DataFlow::exprNode(str) and
349349
result = str.getText()
350350
)
351351
}
@@ -478,9 +478,7 @@ module HTTP {
478478
/** Gets the mimetype of this HTTP response, if it can be statically determined. */
479479
string getMimetype() {
480480
exists(StrConst str |
481-
DataFlow::exprNode(str)
482-
.(DataFlow::LocalSourceNode)
483-
.flowsTo(this.getMimetypeOrContentTypeArg()) and
481+
this.getMimetypeOrContentTypeArg().getALocalSource() = DataFlow::exprNode(str) and
484482
result = str.getText().splitAt(";", 0)
485483
)
486484
or

python/ql/src/semmle/python/frameworks/Django.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,7 @@ private module PrivateDjango {
17081708

17091709
DjangoRouteRegex() {
17101710
this instanceof StrConst and
1711-
DataFlow::exprNode(this).(DataFlow::LocalSourceNode).flowsTo(rePathCall.getUrlPatternArg())
1711+
rePathCall.getUrlPatternArg().getALocalSource() = DataFlow::exprNode(this)
17121712
}
17131713

17141714
DjangoRegexRouteSetup getRouteSetup() { result = rePathCall }

python/ql/src/semmle/python/frameworks/Stdlib.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ private DataFlow::CallCfgNode hashlibNewCall(string algorithmName) {
10971097
result = API::moduleImport("hashlib").getMember("new").getACall() and
10981098
nameArg in [result.getArg(0), result.getArgByName("name")] and
10991099
exists(StrConst str |
1100-
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(nameArg) and
1100+
nameArg.getALocalSource() = DataFlow::exprNode(str) and
11011101
algorithmName = str.getText()
11021102
)
11031103
)

python/ql/src/semmle/python/frameworks/Tornado.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ private module Tornado {
349349

350350
TornadoRouteRegex() {
351351
this instanceof StrConst and
352-
DataFlow::exprNode(this).(DataFlow::LocalSourceNode).flowsTo(setup.getUrlPatternArg())
352+
setup.getUrlPatternArg().getALocalSource() = DataFlow::exprNode(this)
353353
}
354354

355355
TornadoRouteSetup getRouteSetup() { result = setup }

0 commit comments

Comments
 (0)