@@ -64,7 +64,7 @@ module ActionDispatch {
64
64
* the route defined by the call to `get` has the full path `/admin/dashboard`.
65
65
* We track these contributions via `getPathComponent` and `getControllerComponent`.
66
66
*/
67
- abstract class RouteBlock extends TRouteBlock {
67
+ abstract private class RouteBlock extends TRouteBlock {
68
68
/**
69
69
* Gets the name of a primary CodeQL class to which this route block belongs.
70
70
*/
@@ -228,7 +228,7 @@ module ActionDispatch {
228
228
* ```
229
229
* https://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper/Resources.html#method-i-resources
230
230
*/
231
- class ResourcesRouteBlock extends NestedRouteBlock , TResourcesRouteBlock {
231
+ private class ResourcesRouteBlock extends NestedRouteBlock , TResourcesRouteBlock {
232
232
private MethodCall call ;
233
233
private Block block ;
234
234
@@ -267,7 +267,7 @@ module ActionDispatch {
267
267
* We ignore the condition and analyze both branches to obtain as
268
268
* much routing information as possible.
269
269
*/
270
- class ConditionalRouteBlock extends NestedRouteBlock , TConditionalRouteBlock {
270
+ private class ConditionalRouteBlock extends NestedRouteBlock , TConditionalRouteBlock {
271
271
private ConditionalExpr e ;
272
272
273
273
ConditionalRouteBlock ( ) { this = TConditionalRouteBlock ( parent , e ) }
@@ -294,7 +294,7 @@ module ActionDispatch {
294
294
* ```
295
295
* https://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper/Scoping.html#method-i-namespace
296
296
*/
297
- class NamespaceRouteBlock extends NestedRouteBlock , TNamespaceRouteBlock {
297
+ private class NamespaceRouteBlock extends NestedRouteBlock , TNamespaceRouteBlock {
298
298
private MethodCall call ;
299
299
private Block block ;
300
300
@@ -494,7 +494,7 @@ module ActionDispatch {
494
494
* put "/photos/:id", to: "photos#update"
495
495
* ```
496
496
*/
497
- class ExplicitRoute extends Route , TExplicitRoute {
497
+ private class ExplicitRoute extends Route , TExplicitRoute {
498
498
RouteBlock parentBlock ;
499
499
500
500
ExplicitRoute ( ) { this = TExplicitRoute ( parentBlock , method ) }
@@ -593,7 +593,7 @@ module ActionDispatch {
593
593
* get "/photos/:photo_id/foo", to: "photos#foo"
594
594
* ```
595
595
*/
596
- class ResourcesRoute extends Route , TResourcesRoute {
596
+ private class ResourcesRoute extends Route , TResourcesRoute {
597
597
RouteBlock parent ;
598
598
string resource ;
599
599
string action ;
@@ -628,7 +628,7 @@ module ActionDispatch {
628
628
* resource :account
629
629
* ```
630
630
*/
631
- class SingularResourceRoute extends Route , TResourceRoute {
631
+ private class SingularResourceRoute extends Route , TResourceRoute {
632
632
RouteBlock parent ;
633
633
string resource ;
634
634
string action ;
@@ -666,7 +666,7 @@ module ActionDispatch {
666
666
* match 'photos/:id', controller: 'photos', action: 'show', via: :get
667
667
* ```
668
668
*/
669
- class MatchRoute extends Route , TMatchRoute {
669
+ private class MatchRoute extends Route , TMatchRoute {
670
670
private RouteBlock parent ;
671
671
672
672
MatchRoute ( ) { this = TMatchRoute ( parent , method ) }
@@ -704,7 +704,7 @@ module ActionDispatch {
704
704
* - `except:` removes the given actions from the set.
705
705
*/
706
706
bindingset [ action]
707
- predicate applyActionFilters ( MethodCall m , string action ) {
707
+ private predicate applyActionFilters ( MethodCall m , string action ) {
708
708
// Respect the `only` keyword argument, which restricts the set of actions.
709
709
(
710
710
not exists ( m .getKeywordArgument ( "only" ) )
@@ -727,7 +727,9 @@ module ActionDispatch {
727
727
* Holds if the (resource, method, path, action) combination would be generated by a call to `resources :<resource>`.
728
728
*/
729
729
bindingset [ resource]
730
- predicate isDefaultResourceRoute ( string resource , string method , string path , string action ) {
730
+ private predicate isDefaultResourceRoute (
731
+ string resource , string method , string path , string action
732
+ ) {
731
733
action = "create" and
732
734
( method = "post" and path = "/" + resource )
733
735
or
@@ -754,7 +756,7 @@ module ActionDispatch {
754
756
* Holds if the (resource, method, path, action) combination would be generated by a call to `resource :<resource>`.
755
757
*/
756
758
bindingset [ resource]
757
- predicate isDefaultSingularResourceRoute (
759
+ private predicate isDefaultSingularResourceRoute (
758
760
string resource , string method , string path , string action
759
761
) {
760
762
action = "create" and
@@ -780,17 +782,18 @@ module ActionDispatch {
780
782
* Extract the controller from a Rails routing string
781
783
* ```
782
784
* extractController("posts#show") = "posts"
785
+ * ```
783
786
*/
784
787
bindingset [ input]
785
- string extractController ( string input ) { result = input .regexpCapture ( "([^#]+)#.+" , 1 ) }
788
+ private string extractController ( string input ) { result = input .regexpCapture ( "([^#]+)#.+" , 1 ) }
786
789
787
790
/**
788
791
* Extract the action from a Rails routing string
789
792
* ```
790
793
* extractController("posts#show") = "show"
791
794
*/
792
795
bindingset [ input]
793
- string extractAction ( string input ) { result = input .regexpCapture ( "[^#]+#(.+)" , 1 ) }
796
+ private string extractAction ( string input ) { result = input .regexpCapture ( "[^#]+#(.+)" , 1 ) }
794
797
795
798
/**
796
799
* A basic pluralizer for English strings.
@@ -799,7 +802,7 @@ module ActionDispatch {
799
802
* TODO: remove?
800
803
*/
801
804
bindingset [ input]
802
- string pluralize ( string input ) {
805
+ private string pluralize ( string input ) {
803
806
exists ( string prefix | prefix = input .regexpCapture ( "(.*)y" , 1 ) | result = prefix + "ies" )
804
807
or
805
808
not input .regexpMatch ( ".*y" ) and
@@ -813,7 +816,7 @@ module ActionDispatch {
813
816
* not_plural => not_plural
814
817
*/
815
818
bindingset [ input]
816
- string singularize ( string input ) {
819
+ private string singularize ( string input ) {
817
820
exists ( string prefix | prefix = input .regexpCapture ( "(.*)ies" , 1 ) | result = prefix + "y" )
818
821
or
819
822
not input .regexpMatch ( ".*ies" ) and
@@ -890,13 +893,15 @@ module ActionDispatch {
890
893
* Convert the first character of the string to lowercase.
891
894
*/
892
895
bindingset [ input]
893
- string decapitalize ( string input ) { result = input .charAt ( 0 ) .toLowerCase ( ) + input .suffix ( 1 ) }
896
+ private string decapitalize ( string input ) {
897
+ result = input .charAt ( 0 ) .toLowerCase ( ) + input .suffix ( 1 )
898
+ }
894
899
895
900
/**
896
901
* Strip leading and trailing forward slashes from the string.
897
902
*/
898
903
bindingset [ input]
899
- string stripSlashes ( string input ) {
904
+ private string stripSlashes ( string input ) {
900
905
result = input .regexpReplaceAll ( "^/+(.+)$" , "$1" ) .regexpReplaceAll ( "^(.*[^/])/+$" , "$1" )
901
906
}
902
907
}
0 commit comments