@@ -317,9 +317,7 @@ private class LocalAssignsHashSyntheticGlobal extends SummaryComponent::Syntheti
317
317
private class RenderLocalsSummary extends SummarizedCallable {
318
318
private LocalAssignsHashSyntheticGlobal glob ;
319
319
320
- RenderLocalsSummary ( ) {
321
- this = "rails_render_locals()" + glob .getId ( )
322
- }
320
+ RenderLocalsSummary ( ) { this = "rails_render_locals()" + glob .getId ( ) }
323
321
324
322
override Rails:: RenderCall getACall ( ) { result .getTemplateFile ( ) = glob .getErbFile ( ) }
325
323
@@ -334,9 +332,7 @@ private class RenderLocalsSummary extends SummarizedCallable {
334
332
private class AccessLocalsSummary extends SummarizedCallable {
335
333
private LocalAssignsHashSyntheticGlobal glob ;
336
334
337
- AccessLocalsSummary ( ) {
338
- this = "rails_local_assigns()" + glob .getId ( )
339
- }
335
+ AccessLocalsSummary ( ) { this = "rails_local_assigns()" + glob .getId ( ) }
340
336
341
337
override MethodCall getACall ( ) {
342
338
glob .getId ( ) = getErbFileIdentifier ( result .getLocation ( ) .getFile ( ) ) and
@@ -354,25 +350,17 @@ private string getAMethodNameFromErbFile(ErbFile f) {
354
350
result = any ( MethodCall c | c .getLocation ( ) .getFile ( ) = f ) .getMethodName ( )
355
351
}
356
352
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
-
366
353
private class AccessLocalsKeySummary extends SummarizedCallable {
367
354
private LocalAssignsHashSyntheticGlobal glob ;
368
355
private string methodName ;
369
356
370
357
AccessLocalsKeySummary ( ) {
371
358
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 ( )
376
364
}
377
365
378
366
override MethodCall getACall ( ) {
0 commit comments