@@ -184,20 +184,25 @@ private module Shared {
184184 )
185185 }
186186
187+ pragma [ noinline]
188+ predicate isHelperMethodNameMatch ( ActionControllerHelperMethod helperMethod , MethodCall call ) {
189+ helperMethod .getName ( ) = call .getMethodName ( )
190+ }
191+
187192 predicate isFlowFromHelperMethod ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
188193 // flow out of controller helper method into template
189- exists (
190- ErbFile template , ActionControllerHelperMethod helperMethod ,
191- CfgNodes :: ExprNodes :: MethodCallCfgNode helperMethodCall
192- |
193- template = node2 . getLocation ( ) . getFile ( ) and
194- // TODO: this is slow, x-product of helper method names and method calls
195- helperMethod . getName ( ) = helperMethodCall . getExpr ( ) . getMethodName ( ) and
196- helperMethod . getControllerClass ( ) = getAssociatedControllerClass ( template ) and
197- // `node1` is an expr node that may be returned by the helper method
198- exprNodeReturnedFrom ( node1 , helperMethod ) and
199- // `node2` is a call to the helper method
200- node2 . asExpr ( ) = helperMethodCall
194+ exists ( ErbFile template |
195+ template = node2 . getLocation ( ) . getFile ( ) |
196+ exists ( ActionControllerHelperMethod helperMethod |
197+ helperMethod . getControllerClass ( ) = getAssociatedControllerClass ( template ) and
198+ // `node1` is an expr node that may be returned by the helper method
199+ exprNodeReturnedFrom ( node1 , helperMethod ) |
200+ exists ( CfgNodes :: ExprNodes :: MethodCallCfgNode helperMethodCall |
201+ // `node2` is a call to the helper method
202+ node2 . asExpr ( ) = helperMethodCall and
203+ isHelperMethodNameMatch ( helperMethod , helperMethodCall . getExpr ( ) )
204+ )
205+ )
201206 )
202207 }
203208
0 commit comments