@@ -2559,23 +2559,25 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
2559
2559
2560
2560
pragma [ nomagic]
2561
2561
private predicate revFlowThroughArg (
2562
- DataFlowCall call , ArgNodeEx arg , FlowState state , ReturnCtx returnCtx , ApOption returnAp ,
2563
- Ap ap
2562
+ DataFlowCall call , ArgNodeEx arg , ParamNodeEx p , FlowState state , ReturnCtx returnCtx ,
2563
+ ApOption returnAp , Ap ap
2564
2564
) {
2565
- exists ( ParamNodeEx p , Ap innerReturnAp |
2565
+ exists ( Ap innerReturnAp |
2566
2566
revFlowThrough ( call , returnCtx , p , state , _, returnAp , ap , innerReturnAp ) and
2567
2567
flowThroughIntoCall ( call , arg , p , _, ap , innerReturnAp )
2568
2568
)
2569
2569
}
2570
2570
2571
2571
pragma [ nomagic]
2572
- predicate callMayFlowThroughRev ( DataFlowCall call ) {
2572
+ additional predicate callMayFlowThroughRev ( DataFlowCall call , ParamNodeEx p ) {
2573
2573
exists ( ArgNodeEx arg , FlowState state , ReturnCtx returnCtx , ApOption returnAp , Ap ap |
2574
2574
revFlow ( arg , state , returnCtx , returnAp , ap ) and
2575
- revFlowThroughArg ( call , arg , state , returnCtx , returnAp , ap )
2575
+ revFlowThroughArg ( call , arg , p , state , returnCtx , returnAp , ap )
2576
2576
)
2577
2577
}
2578
2578
2579
+ predicate callMayFlowThroughRev ( DataFlowCall call ) { callMayFlowThroughRev ( call , _) }
2580
+
2579
2581
predicate callEdgeArgParam (
2580
2582
DataFlowCall call , DataFlowCallable c , ArgNodeEx arg , ParamNodeEx p ,
2581
2583
boolean allowsFieldFlow , Ap ap
@@ -3416,24 +3418,51 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
3416
3418
private module StoreReadMatchingInput implements StoreReadMatchingInputSig {
3417
3419
class NodeEx = NodeExAlias ;
3418
3420
3419
- predicate nodeRange ( NodeEx node , boolean fromArg ) {
3420
- exists ( PrevStage:: Ap ap |
3421
- PrevStage:: revFlowAp ( node , ap ) and
3421
+ pragma [ nomagic]
3422
+ private DataFlowCallOption getAFlowThroughCallCtx (
3423
+ NodeEx node , PrevStage:: Ap ap , boolean fromArg
3424
+ ) {
3425
+ exists ( PrevStage:: Cc cc , ParamNodeOption summaryCtx , PrevStage:: ApOption argAp |
3426
+ PrevStage:: fwdFlow ( node , _, cc , summaryCtx , _, argAp , _, ap , _)
3427
+ |
3428
+ PrevStage:: instanceofCcCall ( cc ) and
3429
+ fromArg = true and
3422
3430
(
3423
- ap = true
3424
- or
3425
- PrevStage:: storeStepCand ( node , ap , _, _, _, _)
3431
+ summaryCtx instanceof TParamNodeNone and
3432
+ result = TDataFlowCallNone ( )
3426
3433
or
3427
- PrevStage:: readStepCand ( _, _, node )
3434
+ exists ( ParamNodeEx p , PrevStage:: Ap argApSome |
3435
+ summaryCtx = TParamNodeSome ( p .asNode ( ) ) and
3436
+ argAp = PrevStage:: apSome ( argApSome )
3437
+ |
3438
+ if
3439
+ PrevStage:: parameterMayFlowThrough ( p , argApSome ) and
3440
+ PrevStage:: callMayFlowThroughRev ( _, p )
3441
+ then
3442
+ exists ( DataFlowCall call |
3443
+ PrevStage:: callMayFlowThroughRev ( call , p ) and
3444
+ result = TDataFlowCallSome ( call )
3445
+ )
3446
+ else result = TDataFlowCallNone ( )
3447
+ )
3428
3448
)
3449
+ or
3450
+ PrevStage:: instanceofCcNoCall ( cc ) and
3451
+ fromArg = false and
3452
+ result = TDataFlowCallNone ( )
3453
+ )
3454
+ }
3455
+
3456
+ predicate nodeRange ( NodeEx node , boolean fromArg , DataFlowCallOption summaryCtx ) {
3457
+ exists ( PrevStage:: Ap ap |
3458
+ PrevStage:: revFlowAp ( node , ap ) and
3459
+ summaryCtx = getAFlowThroughCallCtx ( node , ap , fromArg )
3429
3460
|
3430
- exists ( PrevStage:: Cc cc | PrevStage:: fwdFlow ( node , _, cc , _, _, _, _, ap , _) |
3431
- PrevStage:: instanceofCcCall ( cc ) and
3432
- fromArg = true
3433
- or
3434
- PrevStage:: instanceofCcNoCall ( cc ) and
3435
- fromArg = false
3436
- )
3461
+ ap = true
3462
+ or
3463
+ PrevStage:: storeStepCand ( node , ap , _, _, _, _)
3464
+ or
3465
+ PrevStage:: readStepCand ( _, _, node )
3437
3466
)
3438
3467
}
3439
3468
@@ -3459,12 +3488,19 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
3459
3488
)
3460
3489
}
3461
3490
3462
- predicate callEdgeArgParam ( NodeEx arg , NodeEx param ) {
3463
- PrevStage:: callEdgeArgParam ( _, _, arg , param , true , true )
3491
+ predicate callEdgeArgParam ( NodeEx arg , NodeEx param , DataFlowCallOption summaryCtx ) {
3492
+ exists ( DataFlowCall call |
3493
+ PrevStage:: callEdgeArgParam ( call , _, arg , param , true , true ) and
3494
+ summaryCtx = getAFlowThroughCallCtx ( param , true , true )
3495
+ |
3496
+ summaryCtx = TDataFlowCallNone ( )
3497
+ or
3498
+ summaryCtx = TDataFlowCallSome ( call )
3499
+ )
3464
3500
}
3465
3501
3466
- predicate callEdgeReturn ( NodeEx ret , NodeEx out , boolean mayFlowThrough ) {
3467
- PrevStage:: callEdgeReturn ( _ , _, ret , _, out , true , true ) and
3502
+ predicate callEdgeReturn ( DataFlowCall call , NodeEx ret , NodeEx out , boolean mayFlowThrough ) {
3503
+ PrevStage:: callEdgeReturn ( call , _, ret , _, out , true , true ) and
3468
3504
if flowThroughOutOfCall ( ret , out ) then mayFlowThrough = true else mayFlowThrough = false
3469
3505
}
3470
3506
0 commit comments