Skip to content

Commit 55e6255

Browse files
committed
Dataflow: Extend the first join to also include argApa.
Improves from 2024-03-04 13:29:20] Evaluated non-recursive predicate DataFlowImpl::Impl<TaintedPath::TaintedPath::C>::Stage5::flowThroughIntoCall/6#b44155c7@6dd478n9 in 126ms (size: 398332). Evaluated relational algebra for predicate DataFlowImpl::Impl<TaintedPath::TaintedPath::C>::Stage5::flowThroughIntoCall/6#b44155c7@6dd478n9 with tuple counts: 1 ~0% {2} r1 = SCAN `DataFlowImpl::Impl<TaintedPath::TaintedPath::C>::TAccessPathApproxNone#dom#04382804` OUTPUT _, _ 1 ~0% {0} | REWRITE WITH Tmp.0 := true, Tmp.1 := false, TEST Tmp.0 != Tmp.1 KEEPING 0 83798 ~0% {4} | JOIN WITH `project#DataFlowImpl::Impl<TaintedPath::TaintedPath::C>::Stage5::returnFlowsThrough/8#ffafcf14` CARTESIAN PRODUCT OUTPUT Rhs.0, Rhs.3, Rhs.1, Rhs.2 4044102 ~3% {7} | JOIN WITH `project#DataFlowImpl::Impl<TaintedPath::TaintedPath::C>::Stage5::flowIntoCallApaTaken/6#d989a8d1#cpe#12346_2013#join_rhs` ON FIRST 1 OUTPUT Rhs.2, Lhs.2, Lhs.3, Rhs.3, Lhs.1, Lhs.0, Rhs.1 398332 ~3% {6} | JOIN WITH `project#DataFlowImpl::Impl<TaintedPath::TaintedPath::C>::Stage5::fwdFlow/9#00ae2fc8#2` ON FIRST 4 OUTPUT Lhs.6, Lhs.0, Lhs.5, _, Lhs.2, Lhs.4 398332 ~1% {6} | REWRITE WITH Out.3 := true return r1 to [2024-03-04 15:20:26] Evaluated non-recursive predicate DataFlowImpl::Impl<TaintedPath::TaintedPath::C>::Stage5::flowThroughIntoCall/6#b44155c7@97bd358u in 35ms (size: 398332). Evaluated relational algebra for predicate DataFlowImpl::Impl<TaintedPath::TaintedPath::C>::Stage5::flowThroughIntoCall/6#b44155c7@97bd358u with tuple counts: 83798 ~0% {7} r1 = SCAN `project#DataFlowImpl::Impl<TaintedPath::TaintedPath::C>::Stage5::returnFlowsThrough/9#53894c55` OUTPUT In.0, In.1, In.2, In.3, In.4, _, _ {5} | REWRITE WITH Tmp.5 := true, Tmp.6 := false, TEST Tmp.5 != Tmp.6 KEEPING 5 83798 ~3% {5} | SCAN OUTPUT In.0, In.3, In.4, In.1, In.2 416847 ~2% {7} | JOIN WITH `project#DataFlowImpl::Impl<TaintedPath::TaintedPath::C>::Stage5::flowIntoCallApaTaken/6#d989a8d1#cpe#12346_2301#join_rhs` ON FIRST 2 OUTPUT Rhs.3, Lhs.3, Lhs.4, Lhs.1, Lhs.2, Lhs.0, Rhs.2 398332 ~3% {6} | JOIN WITH `project#DataFlowImpl::Impl<TaintedPath::TaintedPath::C>::Stage5::fwdFlow/9#00ae2fc8#2` ON FIRST 4 OUTPUT Lhs.6, Lhs.0, Lhs.5, _, Lhs.2, Lhs.4 398332 ~1% {6} | REWRITE WITH Out.3 := true return r1
1 parent 66d2a84 commit 55e6255

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,11 +1904,11 @@ module MakeImpl<InputSig Lang> {
19041904
pragma[nomagic]
19051905
private predicate returnFlowsThrough(
19061906
RetNodeEx ret, ReturnPosition pos, FlowState state, CcCall ccc, ParamNodeEx p, Typ argT,
1907-
Ap argAp, Ap ap
1907+
Ap argAp, ApApprox argApa, Ap ap
19081908
) {
1909-
exists(DataFlowCall call, ApApprox apa, boolean allowsFieldFlow, ApApprox innerArgApa |
1910-
returnFlowsThrough0(call, state, ccc, ap, apa, ret, p, argT, argAp, innerArgApa) and
1911-
flowThroughOutOfCall(call, ccc, ret, _, allowsFieldFlow, innerArgApa, apa) and
1909+
exists(DataFlowCall call, ApApprox apa, boolean allowsFieldFlow |
1910+
returnFlowsThrough0(call, state, ccc, ap, apa, ret, p, argT, argAp, argApa) and
1911+
flowThroughOutOfCall(call, ccc, ret, _, allowsFieldFlow, argApa, apa) and
19121912
pos = ret.getReturnPosition() and
19131913
if allowsFieldFlow = false then ap instanceof ApNil else any()
19141914
)
@@ -1920,10 +1920,10 @@ module MakeImpl<InputSig Lang> {
19201920
) {
19211921
exists(ApApprox argApa, Typ argT |
19221922
returnFlowsThrough(_, _, _, _, pragma[only_bind_into](p), pragma[only_bind_into](argT),
1923-
pragma[only_bind_into](argAp), ap) and
1923+
pragma[only_bind_into](argAp), pragma[only_bind_into](argApa), ap) and
19241924
flowIntoCallApaTaken(call, _, pragma[only_bind_into](arg), p, allowsFieldFlow, argApa) and
19251925
fwdFlow(arg, _, _, _, _, _, pragma[only_bind_into](argT), pragma[only_bind_into](argAp),
1926-
argApa) and
1926+
pragma[only_bind_into](argApa)) and
19271927
if allowsFieldFlow = false then argAp instanceof ApNil else any()
19281928
)
19291929
}
@@ -2027,7 +2027,7 @@ module MakeImpl<InputSig Lang> {
20272027
// flow out of a callable
20282028
exists(ReturnPosition pos |
20292029
revFlowOut(_, node, pos, state, _, _, _, ap) and
2030-
if returnFlowsThrough(node, pos, state, _, _, _, _, ap)
2030+
if returnFlowsThrough(node, pos, state, _, _, _, _, _, ap)
20312031
then (
20322032
returnCtx = TReturnCtxMaybeFlowThrough(pos) and
20332033
returnAp = apSome(ap)
@@ -2189,7 +2189,7 @@ module MakeImpl<InputSig Lang> {
21892189
) {
21902190
exists(RetNodeEx ret, FlowState state, CcCall ccc |
21912191
revFlowOut(call, ret, pos, state, returnCtx, _, returnAp, ap) and
2192-
returnFlowsThrough(ret, pos, state, ccc, _, _, _, ap) and
2192+
returnFlowsThrough(ret, pos, state, ccc, _, _, _, _, ap) and
21932193
matchesCall(ccc, call)
21942194
)
21952195
}
@@ -2258,15 +2258,15 @@ module MakeImpl<InputSig Lang> {
22582258
pragma[nomagic]
22592259
predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap) {
22602260
exists(ReturnPosition pos |
2261-
returnFlowsThrough(_, pos, _, _, p, _, ap, _) and
2261+
returnFlowsThrough(_, pos, _, _, p, _, ap, _, _) and
22622262
parameterFlowsThroughRev(p, ap, pos, _)
22632263
)
22642264
}
22652265

22662266
pragma[nomagic]
22672267
predicate returnMayFlowThrough(RetNodeEx ret, Ap argAp, Ap ap, ReturnKindExt kind) {
22682268
exists(ParamNodeEx p, ReturnPosition pos |
2269-
returnFlowsThrough(ret, pos, _, _, p, _, argAp, ap) and
2269+
returnFlowsThrough(ret, pos, _, _, p, _, argAp, _, ap) and
22702270
parameterFlowsThroughRev(p, argAp, pos, ap) and
22712271
kind = pos.getKind()
22722272
)

0 commit comments

Comments
 (0)