Skip to content

Commit 77b09f3

Browse files
committed
Dataflow: Add type to partial flow summary context
1 parent 11c0525 commit 77b09f3

File tree

1 file changed

+40
-19
lines changed

1 file changed

+40
-19
lines changed

java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImpl.qll

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3987,7 +3987,11 @@ module Impl<FullStateConfigSig Config> {
39873987

39883988
private newtype TSummaryCtx3 =
39893989
TSummaryCtx3None() or
3990-
TSummaryCtx3Some(PartialAccessPath ap)
3990+
TSummaryCtx3Some(DataFlowType t)
3991+
3992+
private newtype TSummaryCtx4 =
3993+
TSummaryCtx4None() or
3994+
TSummaryCtx4Some(PartialAccessPath ap)
39913995

39923996
private newtype TRevSummaryCtx1 =
39933997
TRevSummaryCtx1None() or
@@ -4004,18 +4008,19 @@ module Impl<FullStateConfigSig Config> {
40044008
private newtype TPartialPathNode =
40054009
TPartialPathNodeFwd(
40064010
NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2,
4007-
TSummaryCtx3 sc3, DataFlowType t, PartialAccessPath ap
4011+
TSummaryCtx3 sc3, TSummaryCtx4 sc4, DataFlowType t, PartialAccessPath ap
40084012
) {
40094013
sourceNode(node, state) and
40104014
cc instanceof CallContextAny and
40114015
sc1 = TSummaryCtx1None() and
40124016
sc2 = TSummaryCtx2None() and
40134017
sc3 = TSummaryCtx3None() and
4018+
sc4 = TSummaryCtx4None() and
40144019
t = node.getDataFlowType() and
40154020
ap = TPartialNil(node.getDataFlowType()) and
40164021
exists(explorationLimit())
40174022
or
4018-
partialPathNodeMk0(node, state, cc, sc1, sc2, sc3, t, ap) and
4023+
partialPathNodeMk0(node, state, cc, sc1, sc2, sc3, sc4, t, ap) and
40194024
distSrc(node.getEnclosingCallable()) <= explorationLimit()
40204025
} or
40214026
TPartialPathNodeRev(
@@ -4043,9 +4048,9 @@ module Impl<FullStateConfigSig Config> {
40434048
pragma[nomagic]
40444049
private predicate partialPathNodeMk0(
40454050
NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2,
4046-
TSummaryCtx3 sc3, DataFlowType t, PartialAccessPath ap
4051+
TSummaryCtx3 sc3, TSummaryCtx4 sc4, DataFlowType t, PartialAccessPath ap
40474052
) {
4048-
partialPathStep(_, node, state, cc, sc1, sc2, sc3, t, ap) and
4053+
partialPathStep(_, node, state, cc, sc1, sc2, sc3, sc4, t, ap) and
40494054
not fullBarrier(node) and
40504055
not stateBarrier(node, state) and
40514056
not clearsContentEx(node, ap.getHead().getContent()) and
@@ -4155,10 +4160,11 @@ module Impl<FullStateConfigSig Config> {
41554160
TSummaryCtx1 sc1;
41564161
TSummaryCtx2 sc2;
41574162
TSummaryCtx3 sc3;
4163+
TSummaryCtx4 sc4;
41584164
DataFlowType t;
41594165
PartialAccessPath ap;
41604166

4161-
PartialPathNodeFwd() { this = TPartialPathNodeFwd(node, state, cc, sc1, sc2, sc3, t, ap) }
4167+
PartialPathNodeFwd() { this = TPartialPathNodeFwd(node, state, cc, sc1, sc2, sc3, sc4, t, ap) }
41624168

41634169
NodeEx getNodeEx() { result = node }
41644170

@@ -4172,13 +4178,15 @@ module Impl<FullStateConfigSig Config> {
41724178

41734179
TSummaryCtx3 getSummaryCtx3() { result = sc3 }
41744180

4181+
TSummaryCtx4 getSummaryCtx4() { result = sc4 }
4182+
41754183
DataFlowType getType() { result = t }
41764184

41774185
PartialAccessPath getAp() { result = ap }
41784186

41794187
override PartialPathNodeFwd getASuccessor() {
41804188
partialPathStep(this, result.getNodeEx(), result.getState(), result.getCallContext(),
4181-
result.getSummaryCtx1(), result.getSummaryCtx2(), result.getSummaryCtx3(), result.getType(), result.getAp())
4189+
result.getSummaryCtx1(), result.getSummaryCtx2(), result.getSummaryCtx3(), result.getSummaryCtx4(), result.getType(), result.getAp())
41824190
}
41834191

41844192
predicate isSource() {
@@ -4187,6 +4195,7 @@ module Impl<FullStateConfigSig Config> {
41874195
sc1 = TSummaryCtx1None() and
41884196
sc2 = TSummaryCtx2None() and
41894197
sc3 = TSummaryCtx3None() and
4198+
sc4 = TSummaryCtx4None() and
41904199
ap instanceof TPartialNil
41914200
}
41924201
}
@@ -4229,7 +4238,7 @@ module Impl<FullStateConfigSig Config> {
42294238

42304239
private predicate partialPathStep(
42314240
PartialPathNodeFwd mid, NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1,
4232-
TSummaryCtx2 sc2, TSummaryCtx3 sc3, DataFlowType t, PartialAccessPath ap
4241+
TSummaryCtx2 sc2, TSummaryCtx3 sc3, TSummaryCtx4 sc4, DataFlowType t, PartialAccessPath ap
42334242
) {
42344243
not isUnreachableInCallCached(node.asNode(), cc.(CallContextSpecificCall).getCall()) and
42354244
(
@@ -4239,6 +4248,7 @@ module Impl<FullStateConfigSig Config> {
42394248
sc1 = mid.getSummaryCtx1() and
42404249
sc2 = mid.getSummaryCtx2() and
42414250
sc3 = mid.getSummaryCtx3() and
4251+
sc4 = mid.getSummaryCtx4() and
42424252
t = mid.getType() and
42434253
ap = mid.getAp()
42444254
or
@@ -4248,6 +4258,7 @@ module Impl<FullStateConfigSig Config> {
42484258
sc1 = mid.getSummaryCtx1() and
42494259
sc2 = mid.getSummaryCtx2() and
42504260
sc3 = mid.getSummaryCtx3() and
4261+
sc4 = mid.getSummaryCtx4() and
42514262
mid.getAp() instanceof PartialAccessPathNil and
42524263
t = node.getDataFlowType() and
42534264
ap = TPartialNil(node.getDataFlowType())
@@ -4257,6 +4268,7 @@ module Impl<FullStateConfigSig Config> {
42574268
sc1 = mid.getSummaryCtx1() and
42584269
sc2 = mid.getSummaryCtx2() and
42594270
sc3 = mid.getSummaryCtx3() and
4271+
sc4 = mid.getSummaryCtx4() and
42604272
mid.getAp() instanceof PartialAccessPathNil and
42614273
t = node.getDataFlowType() and
42624274
ap = TPartialNil(node.getDataFlowType())
@@ -4268,7 +4280,8 @@ module Impl<FullStateConfigSig Config> {
42684280
sc1 = TSummaryCtx1None() and
42694281
sc2 = TSummaryCtx2None() and
42704282
sc3 = TSummaryCtx3None() and
4271-
t = mid.getType() and
4283+
sc4 = TSummaryCtx4None() and
4284+
t = mid.getType() and
42724285
ap = mid.getAp()
42734286
or
42744287
additionalJumpStep(mid.getNodeEx(), node) and
@@ -4277,6 +4290,7 @@ module Impl<FullStateConfigSig Config> {
42774290
sc1 = TSummaryCtx1None() and
42784291
sc2 = TSummaryCtx2None() and
42794292
sc3 = TSummaryCtx3None() and
4293+
sc4 = TSummaryCtx4None() and
42804294
mid.getAp() instanceof PartialAccessPathNil and
42814295
t = node.getDataFlowType() and
42824296
ap = TPartialNil(node.getDataFlowType())
@@ -4286,6 +4300,7 @@ module Impl<FullStateConfigSig Config> {
42864300
sc1 = TSummaryCtx1None() and
42874301
sc2 = TSummaryCtx2None() and
42884302
sc3 = TSummaryCtx3None() and
4303+
sc4 = TSummaryCtx4None() and
42894304
mid.getAp() instanceof PartialAccessPathNil and
42904305
t = node.getDataFlowType() and
42914306
ap = TPartialNil(node.getDataFlowType())
@@ -4295,28 +4310,32 @@ module Impl<FullStateConfigSig Config> {
42954310
cc = mid.getCallContext() and
42964311
sc1 = mid.getSummaryCtx1() and
42974312
sc2 = mid.getSummaryCtx2() and
4298-
sc3 = mid.getSummaryCtx3()
4313+
sc3 = mid.getSummaryCtx3() and
4314+
sc4 = mid.getSummaryCtx4()
42994315
or
43004316
exists(DataFlowType t0, PartialAccessPath ap0, Content c |
43014317
partialPathReadStep(mid, t0, ap0, c, node, cc) and
43024318
state = mid.getState() and
43034319
sc1 = mid.getSummaryCtx1() and
43044320
sc2 = mid.getSummaryCtx2() and
43054321
sc3 = mid.getSummaryCtx3() and
4322+
sc4 = mid.getSummaryCtx4() and
43064323
apConsFwd(t, ap, c, t0, ap0)
43074324
)
43084325
or
4309-
partialPathIntoCallable(mid, node, state, _, cc, sc1, sc2, sc3, _, t, ap)
4326+
partialPathIntoCallable(mid, node, state, _, cc, sc1, sc2, sc3, sc4, _, t, ap)
43104327
or
43114328
partialPathOutOfCallable(mid, node, state, cc, t, ap) and
43124329
sc1 = TSummaryCtx1None() and
43134330
sc2 = TSummaryCtx2None() and
4314-
sc3 = TSummaryCtx3None()
4331+
sc3 = TSummaryCtx3None() and
4332+
sc4 = TSummaryCtx4None()
43154333
or
43164334
partialPathThroughCallable(mid, node, state, cc, t, ap) and
43174335
sc1 = mid.getSummaryCtx1() and
43184336
sc2 = mid.getSummaryCtx2() and
4319-
sc3 = mid.getSummaryCtx3()
4337+
sc3 = mid.getSummaryCtx3() and
4338+
sc4 = mid.getSummaryCtx4()
43204339
}
43214340

43224341
bindingset[result, i]
@@ -4422,14 +4441,15 @@ module Impl<FullStateConfigSig Config> {
44224441
private predicate partialPathIntoCallable(
44234442
PartialPathNodeFwd mid, ParamNodeEx p, FlowState state, CallContext outercc,
44244443
CallContextCall innercc, TSummaryCtx1 sc1, TSummaryCtx2 sc2, TSummaryCtx3 sc3,
4425-
DataFlowCall call, DataFlowType t, PartialAccessPath ap
4444+
TSummaryCtx4 sc4, DataFlowCall call, DataFlowType t, PartialAccessPath ap
44264445
) {
44274446
exists(ParameterPosition pos, DataFlowCallable callable |
44284447
partialPathIntoCallable0(mid, callable, pos, state, outercc, call, t, ap) and
44294448
p.isParameterOf(callable, pos) and
44304449
sc1 = TSummaryCtx1Param(p) and
44314450
sc2 = TSummaryCtx2Some(state) and
4432-
sc3 = TSummaryCtx3Some(ap)
4451+
sc3 = TSummaryCtx3Some(t) and
4452+
sc4 = TSummaryCtx4Some(ap)
44334453
|
44344454
if recordDataFlowCallSite(call, callable)
44354455
then innercc = TSpecificCall(call)
@@ -4440,7 +4460,7 @@ module Impl<FullStateConfigSig Config> {
44404460
pragma[nomagic]
44414461
private predicate paramFlowsThroughInPartialPath(
44424462
ReturnKindExt kind, FlowState state, CallContextCall cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2,
4443-
TSummaryCtx3 sc3, DataFlowType t, PartialAccessPath ap
4463+
TSummaryCtx3 sc3, TSummaryCtx4 sc4, DataFlowType t, PartialAccessPath ap
44444464
) {
44454465
exists(PartialPathNodeFwd mid, RetNodeEx ret |
44464466
mid.getNodeEx() = ret and
@@ -4450,6 +4470,7 @@ module Impl<FullStateConfigSig Config> {
44504470
sc1 = mid.getSummaryCtx1() and
44514471
sc2 = mid.getSummaryCtx2() and
44524472
sc3 = mid.getSummaryCtx3() and
4473+
sc4 = mid.getSummaryCtx4() and
44534474
t = mid.getType() and
44544475
ap = mid.getAp()
44554476
)
@@ -4460,9 +4481,9 @@ module Impl<FullStateConfigSig Config> {
44604481
DataFlowCall call, PartialPathNodeFwd mid, ReturnKindExt kind, FlowState state,
44614482
CallContext cc, DataFlowType t, PartialAccessPath ap
44624483
) {
4463-
exists(CallContext innercc, TSummaryCtx1 sc1, TSummaryCtx2 sc2, TSummaryCtx3 sc3 |
4464-
partialPathIntoCallable(mid, _, _, cc, innercc, sc1, sc2, sc3, call, _, _) and
4465-
paramFlowsThroughInPartialPath(kind, state, innercc, sc1, sc2, sc3, t, ap)
4484+
exists(CallContext innercc, TSummaryCtx1 sc1, TSummaryCtx2 sc2, TSummaryCtx3 sc3, TSummaryCtx4 sc4 |
4485+
partialPathIntoCallable(mid, _, _, cc, innercc, sc1, sc2, sc3, sc4, call, _, _) and
4486+
paramFlowsThroughInPartialPath(kind, state, innercc, sc1, sc2, sc3, sc4, t, ap)
44664487
)
44674488
}
44684489

0 commit comments

Comments
 (0)