Skip to content

Commit adec76d

Browse files
committed
Python: Follow conventions of getASomething
When multiple results are available, we usually name the function `getAnArgument` or `getASomething`. The support for django copied the way bottle did things, so this commits cleans up both
1 parent 362e7ae commit adec76d

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class BottleRoute extends ControlFlowNode {
3636

3737
Function getFunction() { bottle_route(this, _, result) }
3838

39-
Parameter getNamedArgument() {
39+
Parameter getANamedArgument() {
4040
exists(string name, Function func |
4141
func = this.getFunction() and
4242
func.getArgByName(name) = result and

python/ql/src/semmle/python/web/bottle/Request.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class UntrustedFile extends TaintKind {
7171
/** Parameter to a bottle request handler function */
7272
class BottleRequestParameter extends HttpRequestTaintSource {
7373
BottleRequestParameter() {
74-
exists(BottleRoute route | route.getNamedArgument() = this.(ControlFlowNode).getNode())
74+
exists(BottleRoute route | route.getANamedArgument() = this.(ControlFlowNode).getNode())
7575
}
7676

7777
override predicate isSourceOf(TaintKind kind) { kind instanceof UntrustedStringKind }

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class DjangoRoute extends CallNode {
1919

2020
FunctionValue getViewFunction() { django_route(this, _, result) }
2121

22-
string getNamedArgument() {
22+
string getANamedArgument() {
2323
exists(DjangoRouteRegex regex |
2424
django_route(this, regex.getAFlowNode(), _) and
2525
regex.getGroupName(_, _) = result
@@ -32,8 +32,8 @@ class DjangoRoute extends CallNode {
3232
*/
3333
int getNumPositionalArguments() {
3434
exists(DjangoRouteRegex regex |
35+
not exists(this.getANamedArgument()) and
3536
django_route(this, regex.getAFlowNode(), _) and
36-
not exists(string s | s = regex.getGroupName(_, _)) and
3737
result = count(regex.getGroupNumber(_, _))
3838
)
3939
}

python/ql/src/semmle/python/web/django/Request.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class DjangoRequestParameter extends HttpRequestTaintSource {
8181
DjangoRequestParameter() {
8282
exists(DjangoRoute route, Function f |
8383
f = route.getViewFunction().getScope() |
84-
this.(ControlFlowNode).getNode() = f.getArgByName(route.getNamedArgument())
84+
this.(ControlFlowNode).getNode() = f.getArgByName(route.getANamedArgument())
8585
or
8686
exists(int i | i >= 0 |
8787
i < route.getNumPositionalArguments() and

0 commit comments

Comments
 (0)