@@ -317,9 +317,7 @@ private class LocalAssignsHashSyntheticGlobal extends SummaryComponent::Syntheti
317317private class RenderLocalsSummary extends SummarizedCallable {
318318 private LocalAssignsHashSyntheticGlobal glob ;
319319
320- RenderLocalsSummary ( ) {
321- this = "rails_render_locals()" + glob .getId ( )
322- }
320+ RenderLocalsSummary ( ) { this = "rails_render_locals()" + glob .getId ( ) }
323321
324322 override Rails:: RenderCall getACall ( ) { result .getTemplateFile ( ) = glob .getErbFile ( ) }
325323
@@ -334,9 +332,7 @@ private class RenderLocalsSummary extends SummarizedCallable {
334332private class AccessLocalsSummary extends SummarizedCallable {
335333 private LocalAssignsHashSyntheticGlobal glob ;
336334
337- AccessLocalsSummary ( ) {
338- this = "rails_local_assigns()" + glob .getId ( )
339- }
335+ AccessLocalsSummary ( ) { this = "rails_local_assigns()" + glob .getId ( ) }
340336
341337 override MethodCall getACall ( ) {
342338 glob .getId ( ) = getErbFileIdentifier ( result .getLocation ( ) .getFile ( ) ) and
@@ -354,25 +350,17 @@ private string getAMethodNameFromErbFile(ErbFile f) {
354350 result = any ( MethodCall c | c .getLocation ( ) .getFile ( ) = f ) .getMethodName ( )
355351}
356352
357- private predicate renderHasLocalsKey ( Rails:: RenderCall c , string key ) {
358- exists ( DataFlow:: HashLiteralNode hashLitNode , DataFlow:: CallNode renderCall |
359- renderCall .asExpr ( ) .getExpr ( ) = c and
360- hashLitNode .flowsTo ( renderCall .getKeywordArgument ( "locals" ) )
361- |
362- key = hashLitNode .getAKeyValuePair ( ) .getKey ( ) .getConstantValue ( ) .getStringlikeValue ( )
363- )
364- }
365-
366353private class AccessLocalsKeySummary extends SummarizedCallable {
367354 private LocalAssignsHashSyntheticGlobal glob ;
368355 private string methodName ;
369356
370357 AccessLocalsKeySummary ( ) {
371358 this = "rails_locals_key()" + glob .getId ( ) + "#" + methodName and
372- methodName = getAMethodNameFromErbFile ( glob .getErbFile ( ) )
373- // TODO: this would cut down massively on impossible flow steps, but fails due to non-monotonic recusrion problems
374- // and
375- // renderHasLocalsKey(glob.getARenderCall(), methodName)
359+ methodName = getAMethodNameFromErbFile ( glob .getErbFile ( ) ) and
360+ // Limit method calls to those that could plausibly be a key in a `locals` hash argument
361+ // TODO: this could be more precise but for problems using the dataflow library in this context
362+ methodName =
363+ any ( HashLiteral l ) .getAKeyValuePair ( ) .getKey ( ) .getConstantValue ( ) .getStringlikeValue ( )
376364 }
377365
378366 override MethodCall getACall ( ) {
0 commit comments