@@ -55,28 +55,35 @@ module Filters {
5555 private class FilterCall extends MethodCallCfgNode {
5656 private FilterKind kind ;
5757
58+ pragma [ nomagic]
5859 FilterCall ( ) {
5960 this .getExpr ( ) .getEnclosingModule ( ) = any ( ActionControllerClass c ) .getADeclaration ( ) and
6061 this .getMethodName ( ) = [ "" , "prepend_" , "append_" , "skip_" ] + kind + "_action"
6162 }
6263
6364 FilterKind getKind ( ) { result = kind }
6465
66+ pragma [ nomagic]
67+ private ActionControllerActionMethod getAnActionCand ( string name ) {
68+ result = getADescendentAction ( this ) and
69+ name = result .getName ( ) and
70+ // A filter cannot apply to another filter
71+ not result = any ( Filter f ) .getFilterCallable ( ) and
72+ // Only include routable actions. This can exclude valid actions if we can't parse the `routes.rb` file fully.
73+ exists ( result .getARoute ( ) )
74+ }
75+
6576 /**
6677 * Gets an action which this filter is applied to.
6778 */
79+ pragma [ nomagic]
6880 ActionControllerActionMethod getAnAction ( ) {
69- // A filter cannot apply to another filter
70- result != any ( Filter f ) .getFilterCallable ( ) and
71- // Only include routable actions. This can exclude valid actions if we can't parse the `routes.rb` file fully.
72- exists ( result .getARoute ( ) ) and
73- (
74- result .getName ( ) = this .getOnlyArgument ( )
81+ exists ( string name | result = this .getAnActionCand ( name ) |
82+ name = this .getOnlyArgument ( )
7583 or
7684 not exists ( this .getOnlyArgument ( ) ) and
77- forall ( string except | except = this .getExceptArgument ( ) | result .getName ( ) != except )
78- ) and
79- result = getADescendentAction ( this )
85+ forall ( string except | except = this .getExceptArgument ( ) | name != except )
86+ )
8087 }
8188
8289 private string getOnlyArgument ( ) {
0 commit comments