@@ -297,34 +297,29 @@ abstract private class CustomSpecialServiceDefinition extends CustomServiceDefin
297
297
/**
298
298
* Holds if `mce` defines a service of type `moduleMethodName` with name `serviceName` using the `factoryFunction` as the factory function.
299
299
*/
300
+ bindingset [ moduleMethodName]
300
301
private predicate isCustomServiceDefinitionOnModule (
301
302
DataFlow:: CallNode mce , string moduleMethodName , string serviceName ,
302
- DataFlow:: SourceNode factoryFunction
303
+ DataFlow:: SourceNode factoryArgument
303
304
) {
304
305
mce = moduleRef ( _) .getAMethodCall ( moduleMethodName ) and
305
- (
306
- moduleMethodName = "controller" or
307
- moduleMethodName = "filter" or
308
- moduleMethodName = "directive" or
309
- moduleMethodName = "component" or
310
- moduleMethodName = "animation"
311
- ) and
312
306
mce .getArgument ( 0 ) .asExpr ( ) .mayHaveStringValue ( serviceName ) and
313
- factoryFunction . flowsTo ( mce .getArgument ( 1 ) )
307
+ factoryArgument = mce .getArgument ( 1 )
314
308
}
315
309
310
+ pragma [ inline]
316
311
private predicate isCustomServiceDefinitionOnProvider (
317
312
DataFlow:: CallNode mce , string providerName , string providerMethodName , string serviceName ,
318
- DataFlow:: SourceNode factoryFunction
313
+ DataFlow:: Node factoryArgument
319
314
) {
320
315
mce = builtinServiceRef ( providerName ) .getAMethodCall ( providerMethodName ) and
321
316
(
322
317
mce .getNumArgument ( ) = 1 and
323
- factoryFunction . flowsTo ( mce .getOptionArgument ( 0 , serviceName ) )
318
+ factoryArgument = mce .getOptionArgument ( 0 , serviceName )
324
319
or
325
320
mce .getNumArgument ( ) = 2 and
326
321
mce .getArgument ( 0 ) .asExpr ( ) .mayHaveStringValue ( serviceName ) and
327
- factoryFunction . flowsTo ( mce .getArgument ( 1 ) )
322
+ factoryArgument = mce .getArgument ( 1 )
328
323
)
329
324
}
330
325
@@ -333,7 +328,7 @@ private predicate isCustomServiceDefinitionOnProvider(
333
328
*/
334
329
class ControllerDefinition extends CustomSpecialServiceDefinition {
335
330
string name ;
336
- DataFlow:: SourceNode factoryFunction ;
331
+ DataFlow:: Node factoryFunction ;
337
332
338
333
ControllerDefinition ( ) {
339
334
isCustomServiceDefinitionOnModule ( this , "controller" , name , factoryFunction ) or
@@ -343,17 +338,17 @@ class ControllerDefinition extends CustomSpecialServiceDefinition {
343
338
344
339
override string getName ( ) { result = name }
345
340
346
- override DataFlow:: SourceNode getAService ( ) { result = factoryFunction }
341
+ override DataFlow:: SourceNode getAService ( ) { result = factoryFunction . getALocalSource ( ) }
347
342
348
- override DataFlow:: SourceNode getAFactoryFunction ( ) { result = factoryFunction }
343
+ override DataFlow:: SourceNode getAFactoryFunction ( ) { result = factoryFunction . getALocalSource ( ) }
349
344
}
350
345
351
346
/**
352
347
* A filter defined with `module.filter` or `$filterProvider.register`.
353
348
*/
354
349
class FilterDefinition extends CustomSpecialServiceDefinition {
355
350
string name ;
356
- DataFlow:: SourceNode factoryFunction ;
351
+ DataFlow:: Node factoryFunction ;
357
352
358
353
FilterDefinition ( ) {
359
354
isCustomServiceDefinitionOnModule ( this , "filter" , name , factoryFunction ) or
@@ -364,20 +359,20 @@ class FilterDefinition extends CustomSpecialServiceDefinition {
364
359
365
360
override DataFlow:: SourceNode getAService ( ) {
366
361
exists ( InjectableFunction f |
367
- f = factoryFunction and
362
+ f = factoryFunction . getALocalSource ( ) and
368
363
result .flowsToExpr ( f .asFunction ( ) .getAReturnedExpr ( ) )
369
364
)
370
365
}
371
366
372
- override DataFlow:: SourceNode getAFactoryFunction ( ) { result = factoryFunction }
367
+ override DataFlow:: SourceNode getAFactoryFunction ( ) { result = factoryFunction . getALocalSource ( ) }
373
368
}
374
369
375
370
/**
376
371
* A directive defined with `module.directive` or `$compileProvider.directive`.
377
372
*/
378
373
class DirectiveDefinition extends CustomSpecialServiceDefinition {
379
374
string name ;
380
- DataFlow:: SourceNode factoryFunction ;
375
+ DataFlow:: Node factoryFunction ;
381
376
382
377
DirectiveDefinition ( ) {
383
378
isCustomServiceDefinitionOnModule ( this , "directive" , name , factoryFunction ) or
@@ -393,7 +388,7 @@ class DirectiveDefinition extends CustomSpecialServiceDefinition {
393
388
)
394
389
}
395
390
396
- override DataFlow:: SourceNode getAFactoryFunction ( ) { result = factoryFunction }
391
+ override DataFlow:: SourceNode getAFactoryFunction ( ) { result = factoryFunction . getALocalSource ( ) }
397
392
}
398
393
399
394
private class CustomDirectiveControllerDependencyInjection extends DependencyInjection {
@@ -416,7 +411,7 @@ private class CustomDirectiveControllerDependencyInjection extends DependencyInj
416
411
*/
417
412
class ComponentDefinition extends CustomSpecialServiceDefinition {
418
413
string name ;
419
- DataFlow:: SourceNode config ;
414
+ DataFlow:: Node config ;
420
415
421
416
ComponentDefinition ( ) {
422
417
isCustomServiceDefinitionOnModule ( this , "component" , name , config ) or
@@ -435,15 +430,15 @@ class ComponentDefinition extends CustomSpecialServiceDefinition {
435
430
override DataFlow:: SourceNode getAFactoryFunction ( ) { none ( ) }
436
431
437
432
/** Gets the configuration object for the defined component. */
438
- DataFlow:: SourceNode getConfig ( ) { result = config }
433
+ DataFlow:: SourceNode getConfig ( ) { result = config . getALocalSource ( ) }
439
434
}
440
435
441
436
/**
442
437
* An animation defined with `module.animation` or `$animationProvider.register`.
443
438
*/
444
439
class AnimationDefinition extends CustomSpecialServiceDefinition {
445
440
string name ;
446
- DataFlow:: SourceNode factoryFunction ;
441
+ DataFlow:: Node factoryFunction ;
447
442
448
443
AnimationDefinition ( ) {
449
444
isCustomServiceDefinitionOnModule ( this , "animation" , name , factoryFunction ) or
@@ -454,12 +449,12 @@ class AnimationDefinition extends CustomSpecialServiceDefinition {
454
449
455
450
override DataFlow:: SourceNode getAService ( ) {
456
451
exists ( InjectableFunction f |
457
- f = factoryFunction and
452
+ f = factoryFunction . getALocalSource ( ) and
458
453
result .flowsToExpr ( f .asFunction ( ) .getAReturnedExpr ( ) )
459
454
)
460
455
}
461
456
462
- override DataFlow:: SourceNode getAFactoryFunction ( ) { result = factoryFunction }
457
+ override DataFlow:: SourceNode getAFactoryFunction ( ) { result = factoryFunction . getALocalSource ( ) }
463
458
}
464
459
465
460
/**
@@ -500,7 +495,7 @@ private class LinkFunctionWithScopeInjection extends ServiceRequest {
500
495
class InjectableFunctionServiceRequest extends ServiceRequest {
501
496
InjectableFunction injectedFunction ;
502
497
503
- InjectableFunctionServiceRequest ( ) { DataFlow :: valueNode ( this ) = injectedFunction }
498
+ InjectableFunctionServiceRequest ( ) { injectedFunction . getAstNode ( ) = this }
504
499
505
500
/**
506
501
* Gets the function of this request.
@@ -589,7 +584,7 @@ class ServiceRecipeDefinition extends RecipeDefinition {
589
584
590
585
exists ( InjectableFunction f |
591
586
f = getAFactoryFunction ( ) and
592
- result = DataFlow :: valueNode ( f .asFunction ( ) )
587
+ result . getAstNode ( ) = f .asFunction ( )
593
588
)
594
589
}
595
590
}
0 commit comments