Skip to content

Commit af9ed21

Browse files
committed
Ruby: Routing.qll - rename method as methodCall
1 parent 01c1acd commit af9ed21

File tree

1 file changed

+33
-30
lines changed
  • ruby/ql/lib/codeql/ruby/frameworks/actiondispatch/internal

1 file changed

+33
-30
lines changed

ruby/ql/lib/codeql/ruby/frameworks/actiondispatch/internal/Routing.qll

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -340,20 +340,20 @@ module Routing {
340340
*/
341341
string getAPrimaryQlClass() { result = "RouteImpl" }
342342

343-
MethodCall method;
343+
MethodCall methodCall;
344344

345345
/** Gets a string representation of this route. */
346-
string toString() { result = method.toString() }
346+
string toString() { result = methodCall.toString() }
347347

348348
/**
349349
* Gets the location of the method call that defines this route.
350350
*/
351-
Location getLocation() { result = method.getLocation() }
351+
Location getLocation() { result = methodCall.getLocation() }
352352

353353
/**
354354
* Gets the method call that defines this route.
355355
*/
356-
MethodCall getDefiningMethodCall() { result = method }
356+
MethodCall getDefiningMethodCall() { result = methodCall }
357357

358358
/**
359359
* Get the last component of the path. For example, in
@@ -473,20 +473,20 @@ module Routing {
473473
private class ExplicitRoute extends RouteImpl, TExplicitRoute {
474474
RouteBlock parentBlock;
475475

476-
ExplicitRoute() { this = TExplicitRoute(parentBlock, method) }
476+
ExplicitRoute() { this = TExplicitRoute(parentBlock, methodCall) }
477477

478478
override string getAPrimaryQlClass() { result = "ExplicitRoute" }
479479

480480
override RouteBlock getParentBlock() { result = parentBlock }
481481

482482
override string getLastPathComponent() {
483-
method.getArgument(0).getConstantValue().isStringlikeValue(result)
483+
methodCall.getArgument(0).getConstantValue().isStringlikeValue(result)
484484
}
485485

486486
override string getLastControllerComponent() {
487-
method.getKeywordArgument("controller").getConstantValue().isStringlikeValue(result)
487+
methodCall.getKeywordArgument("controller").getConstantValue().isStringlikeValue(result)
488488
or
489-
not exists(method.getKeywordArgument("controller")) and
489+
not exists(methodCall.getKeywordArgument("controller")) and
490490
(
491491
result = extractController(this.getActionString())
492492
or
@@ -508,17 +508,17 @@ module Routing {
508508
}
509509

510510
private string getActionString() {
511-
method.getKeywordArgument("to").getConstantValue().isStringlikeValue(result)
511+
methodCall.getKeywordArgument("to").getConstantValue().isStringlikeValue(result)
512512
or
513-
method.getKeywordArgument("to").(MethodCall).getMethodName() = "redirect" and
513+
methodCall.getKeywordArgument("to").(MethodCall).getMethodName() = "redirect" and
514514
result = "<redirect>#<redirect>"
515515
}
516516

517517
override string getAction() {
518518
// get "/photos", action: "index"
519-
method.getKeywordArgument("action").getConstantValue().isStringlikeValue(result)
519+
methodCall.getKeywordArgument("action").getConstantValue().isStringlikeValue(result)
520520
or
521-
not exists(method.getKeywordArgument("action")) and
521+
not exists(methodCall.getKeywordArgument("action")) and
522522
(
523523
// get "/photos", to: "photos#index"
524524
// get "/photos", to: redirect("some_url")
@@ -531,11 +531,11 @@ module Routing {
531531
or
532532
// get :some_action
533533
not exists(this.getActionString()) and
534-
method.getArgument(0).getConstantValue().isStringlikeValue(result)
534+
methodCall.getArgument(0).getConstantValue().isStringlikeValue(result)
535535
)
536536
}
537537

538-
override string getHttpMethod() { result = method.getMethodName().toString() }
538+
override string getHttpMethod() { result = methodCall.getMethodName().toString() }
539539
}
540540

541541
/**
@@ -577,8 +577,8 @@ module Routing {
577577

578578
ResourcesRoute() {
579579
exists(string resource |
580-
this = TResourcesRoute(parent, method, action) and
581-
method.getArgument(0).getConstantValue().isStringlikeValue(resource) and
580+
this = TResourcesRoute(parent, methodCall, action) and
581+
methodCall.getArgument(0).getConstantValue().isStringlikeValue(resource) and
582582
isDefaultResourceRoute(resource, httpMethod, pathComponent, action)
583583
)
584584
}
@@ -590,7 +590,7 @@ module Routing {
590590
override string getLastPathComponent() { result = pathComponent }
591591

592592
override string getLastControllerComponent() {
593-
method.getArgument(0).getConstantValue().isStringlikeValue(result)
593+
methodCall.getArgument(0).getConstantValue().isStringlikeValue(result)
594594
}
595595

596596
override string getAction() { result = action }
@@ -615,8 +615,8 @@ module Routing {
615615

616616
SingularResourceRoute() {
617617
exists(string resource |
618-
this = TResourceRoute(parent, method, action) and
619-
method.getArgument(0).getConstantValue().isStringlikeValue(resource) and
618+
this = TResourceRoute(parent, methodCall, action) and
619+
methodCall.getArgument(0).getConstantValue().isStringlikeValue(resource) and
620620
isDefaultSingularResourceRoute(resource, httpMethod, pathComponent, action)
621621
)
622622
}
@@ -628,7 +628,7 @@ module Routing {
628628
override string getLastPathComponent() { result = pathComponent }
629629

630630
override string getLastControllerComponent() {
631-
method.getArgument(0).getConstantValue().isStringlikeValue(result)
631+
methodCall.getArgument(0).getConstantValue().isStringlikeValue(result)
632632
}
633633

634634
override string getAction() { result = action }
@@ -652,24 +652,27 @@ module Routing {
652652
private class MatchRoute extends RouteImpl, TMatchRoute {
653653
private RouteBlock parent;
654654

655-
MatchRoute() { this = TMatchRoute(parent, method) }
655+
MatchRoute() { this = TMatchRoute(parent, methodCall) }
656656

657657
override string getAPrimaryQlClass() { result = "MatchRoute" }
658658

659659
override RouteBlock getParentBlock() { result = parent }
660660

661661
override string getLastPathComponent() {
662-
[method.getArgument(0), method.getArgument(0).(Pair).getKey()]
662+
[methodCall.getArgument(0), methodCall.getArgument(0).(Pair).getKey()]
663663
.getConstantValue()
664664
.isStringlikeValue(result)
665665
}
666666

667667
override string getLastControllerComponent() {
668668
result =
669-
extractController(method.getKeywordArgument("to").getConstantValue().getStringlikeValue()) or
670-
method.getKeywordArgument("controller").getConstantValue().isStringlikeValue(result) or
669+
extractController(methodCall
670+
.getKeywordArgument("to")
671+
.getConstantValue()
672+
.getStringlikeValue()) or
673+
methodCall.getKeywordArgument("controller").getConstantValue().isStringlikeValue(result) or
671674
result =
672-
extractController(method
675+
extractController(methodCall
673676
.getArgument(0)
674677
.(Pair)
675678
.getValue()
@@ -679,15 +682,15 @@ module Routing {
679682

680683
override string getHttpMethod() {
681684
exists(string via |
682-
method.getKeywordArgument("via").getConstantValue().isStringlikeValue(via)
685+
methodCall.getKeywordArgument("via").getConstantValue().isStringlikeValue(via)
683686
|
684687
via = "all" and result = anyHttpMethod()
685688
or
686689
via != "all" and result = via
687690
)
688691
or
689692
result =
690-
method
693+
methodCall
691694
.getKeywordArgument("via")
692695
.(ArrayLiteral)
693696
.getElement(_)
@@ -697,10 +700,10 @@ module Routing {
697700

698701
override string getAction() {
699702
result =
700-
extractAction(method.getKeywordArgument("to").getConstantValue().getStringlikeValue()) or
701-
method.getKeywordArgument("action").getConstantValue().isStringlikeValue(result) or
703+
extractAction(methodCall.getKeywordArgument("to").getConstantValue().getStringlikeValue()) or
704+
methodCall.getKeywordArgument("action").getConstantValue().isStringlikeValue(result) or
702705
result =
703-
extractAction(method
706+
extractAction(methodCall
704707
.getArgument(0)
705708
.(Pair)
706709
.getValue()

0 commit comments

Comments
 (0)