Python: Clean up a few verbose casts

This commit is contained in:
Taus
2021-06-17 17:37:01 +00:00
committed by GitHub
parent 847faf536d
commit c78ba476cf
4 changed files with 5 additions and 7 deletions

View File

@@ -345,7 +345,7 @@ module HTTP {
/** Gets the URL pattern for this route, if it can be statically determined. */
string getUrlPattern() {
exists(StrConst str |
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(this.getUrlPatternArg()) and
this.getUrlPatternArg().getALocalSource() = DataFlow::exprNode(str) and
result = str.getText()
)
}
@@ -478,9 +478,7 @@ module HTTP {
/** Gets the mimetype of this HTTP response, if it can be statically determined. */
string getMimetype() {
exists(StrConst str |
DataFlow::exprNode(str)
.(DataFlow::LocalSourceNode)
.flowsTo(this.getMimetypeOrContentTypeArg()) and
this.getMimetypeOrContentTypeArg().getALocalSource() = DataFlow::exprNode(str) and
result = str.getText().splitAt(";", 0)
)
or

View File

@@ -1708,7 +1708,7 @@ private module PrivateDjango {
DjangoRouteRegex() {
this instanceof StrConst and
DataFlow::exprNode(this).(DataFlow::LocalSourceNode).flowsTo(rePathCall.getUrlPatternArg())
rePathCall.getUrlPatternArg().getALocalSource() = DataFlow::exprNode(this)
}
DjangoRegexRouteSetup getRouteSetup() { result = rePathCall }

View File

@@ -1097,7 +1097,7 @@ private DataFlow::CallCfgNode hashlibNewCall(string algorithmName) {
result = API::moduleImport("hashlib").getMember("new").getACall() and
nameArg in [result.getArg(0), result.getArgByName("name")] and
exists(StrConst str |
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(nameArg) and
nameArg.getALocalSource() = DataFlow::exprNode(str) and
algorithmName = str.getText()
)
)

View File

@@ -349,7 +349,7 @@ private module Tornado {
TornadoRouteRegex() {
this instanceof StrConst and
DataFlow::exprNode(this).(DataFlow::LocalSourceNode).flowsTo(setup.getUrlPatternArg())
setup.getUrlPatternArg().getALocalSource() = DataFlow::exprNode(this)
}
TornadoRouteSetup getRouteSetup() { result = setup }