@@ -190,8 +190,8 @@ abstract private class ConfigurationRecursionPrevention extends Configuration {
190
190
191
191
private newtype TNodeEx =
192
192
TNodeNormal ( Node n ) or
193
- TNodeImplicitRead ( Node n , boolean b ) {
194
- any ( Configuration c ) .allowImplicitRead ( n , _) and b = [ false , true ]
193
+ TNodeImplicitRead ( Node n , boolean hasRead ) {
194
+ any ( Configuration c ) .allowImplicitRead ( n , _) and hasRead = [ false , true ]
195
195
}
196
196
197
197
private class NodeEx extends TNodeEx {
@@ -203,12 +203,27 @@ private class NodeEx extends TNodeEx {
203
203
204
204
Node asNode ( ) { this = TNodeNormal ( result ) }
205
205
206
- predicate isImplicitReadNode ( Node n , boolean b ) { this = TNodeImplicitRead ( n , b ) }
206
+ predicate isImplicitReadNode ( Node n , boolean hasRead ) { this = TNodeImplicitRead ( n , hasRead ) }
207
207
208
208
Node projectToNode ( ) { this = TNodeNormal ( result ) or this = TNodeImplicitRead ( result , _) }
209
209
210
210
pragma [ nomagic]
211
- DataFlowCallable getEnclosingCallable ( ) { nodeEnclosingCallable ( this .projectToNode ( ) , result ) }
211
+ private DataFlowCallable getEnclosingCallable0 ( ) {
212
+ nodeEnclosingCallable ( this .projectToNode ( ) , result )
213
+ }
214
+
215
+ pragma [ inline]
216
+ DataFlowCallable getEnclosingCallable ( ) {
217
+ pragma [ only_bind_out ] ( this ) .getEnclosingCallable0 ( ) = pragma [ only_bind_into ] ( result )
218
+ }
219
+
220
+ pragma [ nomagic]
221
+ private DataFlowType getDataFlowType0 ( ) { nodeDataFlowType ( this .asNode ( ) , result ) }
222
+
223
+ pragma [ inline]
224
+ DataFlowType getDataFlowType ( ) {
225
+ pragma [ only_bind_out ] ( this ) .getDataFlowType0 ( ) = pragma [ only_bind_into ] ( result )
226
+ }
212
227
213
228
predicate hasLocationInfo (
214
229
string filepath , int startline , int startcolumn , int endline , int endcolumn
@@ -239,19 +254,6 @@ private class RetNodeEx extends NodeEx {
239
254
ReturnKindExt getKind ( ) { result = this .asNode ( ) .( ReturnNodeExt ) .getKind ( ) }
240
255
}
241
256
242
- pragma [ inline]
243
- private DataFlowCallable getEnclosingCallable ( NodeEx n ) {
244
- pragma [ only_bind_out ] ( n ) .getEnclosingCallable ( ) = pragma [ only_bind_into ] ( result )
245
- }
246
-
247
- pragma [ nomagic]
248
- private DataFlowType getDataFlowType0 ( NodeEx n ) { nodeDataFlowType ( n .asNode ( ) , result ) }
249
-
250
- pragma [ inline]
251
- private DataFlowType getDataFlowType ( NodeEx n ) {
252
- getDataFlowType0 ( pragma [ only_bind_out ] ( n ) ) = pragma [ only_bind_into ] ( result )
253
- }
254
-
255
257
private predicate inBarrier ( NodeEx node , Configuration config ) {
256
258
exists ( Node n |
257
259
node .asNode ( ) = n and
@@ -727,7 +729,7 @@ private module Stage1 {
727
729
) {
728
730
exists ( RetNodeEx ret |
729
731
throughFlowNodeCand ( ret , config ) and
730
- callable = getEnclosingCallable ( ret ) and
732
+ callable = ret . getEnclosingCallable ( ) and
731
733
kind = ret .getKind ( )
732
734
)
733
735
}
@@ -740,7 +742,7 @@ private module Stage1 {
740
742
exists ( ReturnKindExt kind |
741
743
throughFlowNodeCand ( p , config ) and
742
744
returnFlowCallableNodeCand ( c , kind , config ) and
743
- getEnclosingCallable ( p ) = c and
745
+ p . getEnclosingCallable ( ) = c and
744
746
exists ( ap ) and
745
747
// we don't expect a parameter to return stored in itself
746
748
not kind .( ParamUpdateReturnKind ) .getPosition ( ) = p .getPosition ( )
@@ -984,7 +986,7 @@ private module Stage2 {
984
986
) {
985
987
flowOutOfCall ( call , ret , out , allowsFieldFlow , pragma [ only_bind_into ] ( config ) ) and
986
988
PrevStage:: callMayFlowThroughRev ( call , pragma [ only_bind_into ] ( config ) ) and
987
- PrevStage:: parameterMayFlowThrough ( _, getEnclosingCallable ( ret ) , _,
989
+ PrevStage:: parameterMayFlowThrough ( _, ret . getEnclosingCallable ( ) , _,
988
990
pragma [ only_bind_into ] ( config ) )
989
991
}
990
992
@@ -1103,7 +1105,7 @@ private module Stage2 {
1103
1105
exists ( ArgNodeEx arg , boolean allowsFieldFlow |
1104
1106
fwdFlow ( arg , outercc , argAp , ap , config ) and
1105
1107
flowIntoCall ( call , arg , p , allowsFieldFlow , config ) and
1106
- innercc = getCallContextCall ( call , getEnclosingCallable ( p ) , outercc )
1108
+ innercc = getCallContextCall ( call , p . getEnclosingCallable ( ) , outercc )
1107
1109
|
1108
1110
ap instanceof ApNil or allowsFieldFlow = true
1109
1111
)
@@ -1119,7 +1121,7 @@ private module Stage2 {
1119
1121
|
1120
1122
fwdFlow ( ret , innercc , argAp , ap , config ) and
1121
1123
flowOutOfCall ( call , ret , out , allowsFieldFlow , config ) and
1122
- inner = getEnclosingCallable ( ret ) and
1124
+ inner = ret . getEnclosingCallable ( ) and
1123
1125
checkCallContextReturn ( innercc , inner , call ) and
1124
1126
ccOut = getCallContextReturn ( inner , call )
1125
1127
|
@@ -1384,13 +1386,13 @@ private module Stage2 {
1384
1386
ParamNodeEx p , Ap ap , Ap ap0 , DataFlowCallable c , Configuration config
1385
1387
) {
1386
1388
revFlow ( p , true , apSome ( ap0 ) , ap , config ) and
1387
- c = getEnclosingCallable ( p )
1389
+ c = p . getEnclosingCallable ( )
1388
1390
}
1389
1391
1390
1392
predicate parameterMayFlowThrough ( ParamNodeEx p , DataFlowCallable c , Ap ap , Configuration config ) {
1391
1393
exists ( RetNodeEx ret , Ap ap0 , ReturnKindExt kind , int pos |
1392
1394
parameterFlow ( p , ap , ap0 , c , config ) and
1393
- c = getEnclosingCallable ( ret ) and
1395
+ c = ret . getEnclosingCallable ( ) and
1394
1396
revFlow ( ret , true , apSome ( _) , ap0 , config ) and
1395
1397
fwdFlow ( ret , any ( CcCall ccc ) , apSome ( ap ) , ap0 , config ) and
1396
1398
kind = ret .getKind ( ) and
@@ -1520,14 +1522,14 @@ private module LocalFlowBigStep {
1520
1522
(
1521
1523
localFlowStepNodeCand1 ( node1 , node2 , config ) and
1522
1524
preservesValue = true and
1523
- t = getDataFlowType ( node1 ) // irrelevant dummy value
1525
+ t = node1 . getDataFlowType ( ) // irrelevant dummy value
1524
1526
or
1525
1527
additionalLocalFlowStepNodeCand2 ( node1 , node2 , config ) and
1526
1528
preservesValue = false and
1527
- t = getDataFlowType ( node2 )
1529
+ t = node2 . getDataFlowType ( )
1528
1530
) and
1529
1531
node1 != node2 and
1530
- cc .relevantFor ( getEnclosingCallable ( node1 ) ) and
1532
+ cc .relevantFor ( node1 . getEnclosingCallable ( ) ) and
1531
1533
not isUnreachableInCallCached ( node1 .asNode ( ) , cc .( LocalCallContextSpecificCall ) .getCall ( ) ) and
1532
1534
Stage2:: revFlow ( node2 , pragma [ only_bind_into ] ( config ) )
1533
1535
or
@@ -1543,7 +1545,7 @@ private module LocalFlowBigStep {
1543
1545
additionalLocalFlowStepNodeCand2 ( mid , node2 , config ) and
1544
1546
not mid instanceof FlowCheckNode and
1545
1547
preservesValue = false and
1546
- t = getDataFlowType ( node2 ) and
1548
+ t = node2 . getDataFlowType ( ) and
1547
1549
Stage2:: revFlow ( node2 , pragma [ only_bind_into ] ( config ) )
1548
1550
)
1549
1551
)
@@ -1577,7 +1579,7 @@ private module Stage3 {
1577
1579
private ApApprox getApprox ( Ap ap ) { result = ap .toBoolNonEmpty ( ) }
1578
1580
1579
1581
private ApNil getApNil ( NodeEx node ) {
1580
- PrevStage:: revFlow ( node , _) and result = TFrontNil ( getDataFlowType ( node ) )
1582
+ PrevStage:: revFlow ( node , _) and result = TFrontNil ( node . getDataFlowType ( ) )
1581
1583
}
1582
1584
1583
1585
bindingset [ tc, tail]
@@ -1642,7 +1644,7 @@ private module Stage3 {
1642
1644
bindingset [ node, ap]
1643
1645
private predicate filter ( NodeEx node , Ap ap ) {
1644
1646
not clear ( node , ap ) and
1645
- if castingNodeEx ( node ) then compatibleTypes ( getDataFlowType ( node ) , ap .getType ( ) ) else any ( )
1647
+ if castingNodeEx ( node ) then compatibleTypes ( node . getDataFlowType ( ) , ap .getType ( ) ) else any ( )
1646
1648
}
1647
1649
1648
1650
bindingset [ ap, contentType]
@@ -1670,7 +1672,7 @@ private module Stage3 {
1670
1672
) {
1671
1673
flowOutOfCall ( call , ret , out , allowsFieldFlow , pragma [ only_bind_into ] ( config ) ) and
1672
1674
PrevStage:: callMayFlowThroughRev ( call , pragma [ only_bind_into ] ( config ) ) and
1673
- PrevStage:: parameterMayFlowThrough ( _, getEnclosingCallable ( ret ) , _,
1675
+ PrevStage:: parameterMayFlowThrough ( _, ret . getEnclosingCallable ( ) , _,
1674
1676
pragma [ only_bind_into ] ( config ) )
1675
1677
}
1676
1678
@@ -1796,7 +1798,7 @@ private module Stage3 {
1796
1798
exists ( ArgNodeEx arg , boolean allowsFieldFlow |
1797
1799
fwdFlow ( arg , outercc , argAp , ap , config ) and
1798
1800
flowIntoCall ( call , arg , p , allowsFieldFlow , config ) and
1799
- innercc = getCallContextCall ( call , getEnclosingCallable ( p ) , outercc )
1801
+ innercc = getCallContextCall ( call , p . getEnclosingCallable ( ) , outercc )
1800
1802
|
1801
1803
ap instanceof ApNil or allowsFieldFlow = true
1802
1804
)
@@ -1812,7 +1814,7 @@ private module Stage3 {
1812
1814
|
1813
1815
fwdFlow ( ret , innercc , argAp , ap , config ) and
1814
1816
flowOutOfCall ( call , ret , out , allowsFieldFlow , config ) and
1815
- inner = getEnclosingCallable ( ret ) and
1817
+ inner = ret . getEnclosingCallable ( ) and
1816
1818
checkCallContextReturn ( innercc , inner , call ) and
1817
1819
ccOut = getCallContextReturn ( inner , call )
1818
1820
|
@@ -2077,13 +2079,13 @@ private module Stage3 {
2077
2079
ParamNodeEx p , Ap ap , Ap ap0 , DataFlowCallable c , Configuration config
2078
2080
) {
2079
2081
revFlow ( p , true , apSome ( ap0 ) , ap , config ) and
2080
- c = getEnclosingCallable ( p )
2082
+ c = p . getEnclosingCallable ( )
2081
2083
}
2082
2084
2083
2085
predicate parameterMayFlowThrough ( ParamNodeEx p , DataFlowCallable c , Ap ap , Configuration config ) {
2084
2086
exists ( RetNodeEx ret , Ap ap0 , ReturnKindExt kind , int pos |
2085
2087
parameterFlow ( p , ap , ap0 , c , config ) and
2086
- c = getEnclosingCallable ( ret ) and
2088
+ c = ret . getEnclosingCallable ( ) and
2087
2089
revFlow ( ret , true , apSome ( _) , ap0 , config ) and
2088
2090
fwdFlow ( ret , any ( CcCall ccc ) , apSome ( ap ) , ap0 , config ) and
2089
2091
kind = ret .getKind ( ) and
@@ -2333,7 +2335,7 @@ private module Stage4 {
2333
2335
private ApApprox getApprox ( Ap ap ) { result = ap .getFront ( ) }
2334
2336
2335
2337
private ApNil getApNil ( NodeEx node ) {
2336
- PrevStage:: revFlow ( node , _) and result = TNil ( getDataFlowType ( node ) )
2338
+ PrevStage:: revFlow ( node , _) and result = TNil ( node . getDataFlowType ( ) )
2337
2339
}
2338
2340
2339
2341
bindingset [ tc, tail]
@@ -2379,7 +2381,7 @@ private module Stage4 {
2379
2381
localFlowEntry ( node , config ) and
2380
2382
result =
2381
2383
getLocalCallContext ( pragma [ only_bind_into ] ( pragma [ only_bind_out ] ( cc ) ) ,
2382
- getEnclosingCallable ( node ) )
2384
+ node . getEnclosingCallable ( ) )
2383
2385
}
2384
2386
2385
2387
private predicate localStep (
@@ -2432,7 +2434,7 @@ private module Stage4 {
2432
2434
) {
2433
2435
flowOutOfCall ( call , ret , out , allowsFieldFlow , pragma [ only_bind_into ] ( config ) ) and
2434
2436
PrevStage:: callMayFlowThroughRev ( call , pragma [ only_bind_into ] ( config ) ) and
2435
- PrevStage:: parameterMayFlowThrough ( _, getEnclosingCallable ( ret ) , _,
2437
+ PrevStage:: parameterMayFlowThrough ( _, ret . getEnclosingCallable ( ) , _,
2436
2438
pragma [ only_bind_into ] ( config ) )
2437
2439
}
2438
2440
@@ -2558,7 +2560,7 @@ private module Stage4 {
2558
2560
exists ( ArgNodeEx arg , boolean allowsFieldFlow |
2559
2561
fwdFlow ( arg , outercc , argAp , ap , config ) and
2560
2562
flowIntoCall ( call , arg , p , allowsFieldFlow , config ) and
2561
- innercc = getCallContextCall ( call , getEnclosingCallable ( p ) , outercc )
2563
+ innercc = getCallContextCall ( call , p . getEnclosingCallable ( ) , outercc )
2562
2564
|
2563
2565
ap instanceof ApNil or allowsFieldFlow = true
2564
2566
)
@@ -2574,7 +2576,7 @@ private module Stage4 {
2574
2576
|
2575
2577
fwdFlow ( ret , innercc , argAp , ap , config ) and
2576
2578
flowOutOfCall ( call , ret , out , allowsFieldFlow , config ) and
2577
- inner = getEnclosingCallable ( ret ) and
2579
+ inner = ret . getEnclosingCallable ( ) and
2578
2580
checkCallContextReturn ( innercc , inner , call ) and
2579
2581
ccOut = getCallContextReturn ( inner , call )
2580
2582
|
@@ -2839,13 +2841,13 @@ private module Stage4 {
2839
2841
ParamNodeEx p , Ap ap , Ap ap0 , DataFlowCallable c , Configuration config
2840
2842
) {
2841
2843
revFlow ( p , true , apSome ( ap0 ) , ap , config ) and
2842
- c = getEnclosingCallable ( p )
2844
+ c = p . getEnclosingCallable ( )
2843
2845
}
2844
2846
2845
2847
predicate parameterMayFlowThrough ( ParamNodeEx p , DataFlowCallable c , Ap ap , Configuration config ) {
2846
2848
exists ( RetNodeEx ret , Ap ap0 , ReturnKindExt kind , int pos |
2847
2849
parameterFlow ( p , ap , ap0 , c , config ) and
2848
- c = getEnclosingCallable ( ret ) and
2850
+ c = ret . getEnclosingCallable ( ) and
2849
2851
revFlow ( ret , true , apSome ( _) , ap0 , config ) and
2850
2852
fwdFlow ( ret , any ( CcCall ccc ) , apSome ( ap ) , ap0 , config ) and
2851
2853
kind = ret .getKind ( ) and
@@ -2890,7 +2892,7 @@ private predicate nodeMayUseSummary(NodeEx n, AccessPathApprox apa, Configuratio
2890
2892
Stage4:: parameterMayFlowThrough ( _, c , apa , _) and
2891
2893
Stage4:: revFlow ( n , true , _, apa0 , config ) and
2892
2894
Stage4:: fwdFlow ( n , any ( CallContextCall ccc ) , TAccessPathApproxSome ( apa ) , apa0 , config ) and
2893
- getEnclosingCallable ( n ) = c
2895
+ n . getEnclosingCallable ( ) = c
2894
2896
)
2895
2897
}
2896
2898
@@ -3050,7 +3052,7 @@ private newtype TPathNode =
3050
3052
sourceNode ( node , config ) and
3051
3053
cc instanceof CallContextAny and
3052
3054
sc instanceof SummaryCtxNone and
3053
- ap = TAccessPathNil ( getDataFlowType ( node ) )
3055
+ ap = TAccessPathNil ( node . getDataFlowType ( ) )
3054
3056
or
3055
3057
// ... or a step from an existing PathNode to another node.
3056
3058
exists ( PathNodeMid mid |
@@ -3430,7 +3432,7 @@ private predicate pathStep(
3430
3432
sc = mid .getSummaryCtx ( ) and
3431
3433
localCC =
3432
3434
getLocalCallContext ( pragma [ only_bind_into ] ( pragma [ only_bind_out ] ( cc ) ) ,
3433
- getEnclosingCallable ( midnode ) ) and
3435
+ midnode . getEnclosingCallable ( ) ) and
3434
3436
ap0 = mid .getAp ( )
3435
3437
|
3436
3438
localFlowBigStep ( midnode , node , true , _, conf , localCC ) and
@@ -3449,7 +3451,7 @@ private predicate pathStep(
3449
3451
cc instanceof CallContextAny and
3450
3452
sc instanceof SummaryCtxNone and
3451
3453
mid .getAp ( ) instanceof AccessPathNil and
3452
- ap = TAccessPathNil ( getDataFlowType ( node ) )
3454
+ ap = TAccessPathNil ( node . getDataFlowType ( ) )
3453
3455
or
3454
3456
exists ( TypedContent tc | pathStoreStep ( mid , node , ap .pop ( tc ) , tc , cc ) ) and
3455
3457
sc = mid .getSummaryCtx ( )
@@ -3716,8 +3718,8 @@ private module FlowExploration {
3716
3718
// flow out of a callable
3717
3719
viableReturnPosOutEx ( _, node1 .( RetNodeEx ) .getReturnPosition ( ) , node2 )
3718
3720
|
3719
- c1 = getEnclosingCallable ( node1 ) and
3720
- c2 = getEnclosingCallable ( node2 ) and
3721
+ c1 = node1 . getEnclosingCallable ( ) and
3722
+ c2 = node2 . getEnclosingCallable ( ) and
3721
3723
c1 != c2
3722
3724
)
3723
3725
}
@@ -3892,12 +3894,12 @@ private module FlowExploration {
3892
3894
cc instanceof CallContextAny and
3893
3895
sc1 = TSummaryCtx1None ( ) and
3894
3896
sc2 = TSummaryCtx2None ( ) and
3895
- ap = TPartialNil ( getDataFlowType ( node ) ) and
3897
+ ap = TPartialNil ( node . getDataFlowType ( ) ) and
3896
3898
not fullBarrier ( node , config ) and
3897
3899
exists ( config .explorationLimit ( ) )
3898
3900
or
3899
3901
partialPathNodeMk0 ( node , cc , sc1 , sc2 , ap , config ) and
3900
- distSrc ( getEnclosingCallable ( node ) , config ) <= config .explorationLimit ( )
3902
+ distSrc ( node . getEnclosingCallable ( ) , config ) <= config .explorationLimit ( )
3901
3903
} or
3902
3904
TPartialPathNodeRev (
3903
3905
NodeEx node , TRevSummaryCtx1 sc1 , TRevSummaryCtx2 sc2 , RevPartialAccessPath ap ,
@@ -3914,7 +3916,7 @@ private module FlowExploration {
3914
3916
revPartialPathStep ( mid , node , sc1 , sc2 , ap , config ) and
3915
3917
not clearsContentCached ( node .asNode ( ) , ap .getHead ( ) ) and
3916
3918
not fullBarrier ( node , config ) and
3917
- distSink ( getEnclosingCallable ( node ) , config ) <= config .explorationLimit ( )
3919
+ distSink ( node . getEnclosingCallable ( ) , config ) <= config .explorationLimit ( )
3918
3920
)
3919
3921
}
3920
3922
@@ -3928,7 +3930,7 @@ private module FlowExploration {
3928
3930
not fullBarrier ( node , config ) and
3929
3931
not clearsContentCached ( node .asNode ( ) , ap .getHead ( ) .getContent ( ) ) and
3930
3932
if node .asNode ( ) instanceof CastingNode
3931
- then compatibleTypes ( getDataFlowType ( node ) , ap .getType ( ) )
3933
+ then compatibleTypes ( node . getDataFlowType ( ) , ap .getType ( ) )
3932
3934
else any ( )
3933
3935
)
3934
3936
}
@@ -3980,15 +3982,15 @@ private module FlowExploration {
3980
3982
* of interprocedural steps.
3981
3983
*/
3982
3984
int getSourceDistance ( ) {
3983
- result = distSrc ( getEnclosingCallable ( this .getNodeEx ( ) ) , this .getConfiguration ( ) )
3985
+ result = distSrc ( this .getNodeEx ( ) . getEnclosingCallable ( ) , this .getConfiguration ( ) )
3984
3986
}
3985
3987
3986
3988
/**
3987
3989
* Gets the approximate distance to the nearest sink measured in number
3988
3990
* of interprocedural steps.
3989
3991
*/
3990
3992
int getSinkDistance ( ) {
3991
- result = distSink ( getEnclosingCallable ( this .getNodeEx ( ) ) , this .getConfiguration ( ) )
3993
+ result = distSink ( this .getNodeEx ( ) . getEnclosingCallable ( ) , this .getConfiguration ( ) )
3992
3994
}
3993
3995
3994
3996
private string ppAp ( ) {
@@ -4105,7 +4107,7 @@ private module FlowExploration {
4105
4107
sc1 = mid .getSummaryCtx1 ( ) and
4106
4108
sc2 = mid .getSummaryCtx2 ( ) and
4107
4109
mid .getAp ( ) instanceof PartialAccessPathNil and
4108
- ap = TPartialNil ( getDataFlowType ( node ) ) and
4110
+ ap = TPartialNil ( node . getDataFlowType ( ) ) and
4109
4111
config = mid .getConfiguration ( )
4110
4112
)
4111
4113
or
@@ -4121,7 +4123,7 @@ private module FlowExploration {
4121
4123
sc1 = TSummaryCtx1None ( ) and
4122
4124
sc2 = TSummaryCtx2None ( ) and
4123
4125
mid .getAp ( ) instanceof PartialAccessPathNil and
4124
- ap = TPartialNil ( getDataFlowType ( node ) ) and
4126
+ ap = TPartialNil ( node . getDataFlowType ( ) ) and
4125
4127
config = mid .getConfiguration ( )
4126
4128
or
4127
4129
partialPathStoreStep ( mid , _, _, node , ap ) and
0 commit comments