Skip to content

Commit 021e538

Browse files
authored
Merge pull request #23049 from aschackmull/dataflow/accesspathlimit
Dataflow: Allow a config access path limit above the language default.
2 parents e173c08 + d4875b8 commit 021e538

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

‎shared/dataflow/codeql/dataflow/internal/DataFlowImpl.qll‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -566,15 +566,15 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
566566

567567
pragma[nomagic]
568568
private int getAnApLengthLowerBound(Ap ap) {
569-
accessPathLimit() != 0 and // `accessPathLimit() = 0` is already checked in `useFieldFlow`
569+
Config::accessPathLimit() != 0 and // `accessPathLimit() = 0` is already checked in `useFieldFlow`
570570
result = ap.length()
571571
or
572572
not exists(ap.length()) and
573573
exists(Ap tail |
574574
fwdFlowConsCand(_, ap, _, _, tail) and
575575
ap != tail and // no need to report a longer length
576576
result = 1 + getAnApLengthLowerBound(tail) and
577-
result <= accessPathLimit()
577+
result <= Config::accessPathLimit()
578578
)
579579
}
580580

@@ -612,7 +612,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
612612
fwdFlowStore(_, _, ap0, _, c, t, stored, node, cc, summaryCtx) and
613613
ap = apCons(c, ap0) and
614614
apa = getApprox(ap) and
615-
getAnApLengthLowerBound(ap0) < accessPathLimit()
615+
getAnApLengthLowerBound(ap0) < Config::accessPathLimit()
616616
)
617617
or
618618
// read
@@ -1340,15 +1340,15 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
13401340

13411341
pragma[nomagic]
13421342
private int getAnApLengthLowerBoundRev(Ap ap) {
1343-
accessPathLimit() != 0 and // `accessPathLimit() = 0` is already checked in `useFieldFlow`
1343+
Config::accessPathLimit() != 0 and // `accessPathLimit() = 0` is already checked in `useFieldFlow`
13441344
result = ap.length()
13451345
or
13461346
not exists(ap.length()) and
13471347
exists(Ap tail |
13481348
revFlowConsCand(ap, _, tail) and
13491349
ap != tail and // no need to report a longer length
13501350
result = 1 + getAnApLengthLowerBoundRev(tail) and
1351-
result <= accessPathLimit()
1351+
result <= Config::accessPathLimit()
13521352
)
13531353
}
13541354

@@ -1389,7 +1389,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
13891389
exists(Nd mid, Ap ap0 |
13901390
revFlow(mid, returnCtx, returnAp, ap0) and
13911391
readStepFwd(node, ap, _, mid, ap0) and
1392-
getAnApLengthLowerBoundRev(ap0) < accessPathLimit()
1392+
getAnApLengthLowerBoundRev(ap0) < Config::accessPathLimit()
13931393
)
13941394
or
13951395
// flow into a callable

‎shared/dataflow/codeql/dataflow/internal/DataFlowImplCommon.qll‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,15 +1794,22 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
17941794
TReturnCtxNoFlowThrough() or
17951795
TReturnCtxMaybeFlowThrough(ReturnPosition pos)
17961796

1797+
/**
1798+
* Gets the upper bound for the access path length limit that is supported
1799+
* in data flow Configurations. This is set to be at least twice the
1800+
* language default access path limit.
1801+
*/
1802+
private int accessPathLimitConfigCap() { result = 10.maximum(2 * accessPathLimit()) }
1803+
17971804
cached
17981805
newtype TAccessPathFront =
17991806
TFrontNil() or
1800-
TFrontHead(Content c, int length) { length in [1 .. accessPathLimit()] }
1807+
TFrontHead(Content c, int length) { length in [1 .. accessPathLimitConfigCap()] }
18011808

18021809
cached
18031810
newtype TApproxAccessPathFront =
18041811
TApproxFrontNil() or
1805-
TApproxFrontHead(ContentApprox c, int length) { length in [1 .. accessPathLimit()] }
1812+
TApproxFrontHead(ContentApprox c, int length) { length in [1 .. accessPathLimitConfigCap()] }
18061813

18071814
cached
18081815
newtype TAccessPathFrontOption =

0 commit comments

Comments
 (0)