diff --git a/shared/dataflow/codeql/dataflow/internal/DataFlowImpl.qll b/shared/dataflow/codeql/dataflow/internal/DataFlowImpl.qll index 75a4dbcd4bee0..a9d1d0c0481b5 100644 --- a/shared/dataflow/codeql/dataflow/internal/DataFlowImpl.qll +++ b/shared/dataflow/codeql/dataflow/internal/DataFlowImpl.qll @@ -1143,16 +1143,8 @@ module MakeImpl Lang> { ) { exists(RetNodeEx ret | flowOutOfCallNodeCand1(call, ret, _, out) and - c = ret.getEnclosingCallable() - | + c = ret.getEnclosingCallable() and scope = getSecondLevelScopeEx(ret) - or - // ret = TParamReturnNode(_, scope) - ret = TParamReturnNode(_) and - scope.isNone() // todo - or - parameterNode(ret.asNodeReverse(_), _, _) and - scope.isNone() // todo ) } @@ -3481,7 +3473,7 @@ module MakeImpl Lang> { /** Gets the parameter node through which data is returned, if any. */ final ParameterNode asParameterReturnNode() { - result = super.getNodeEx().asParamReturnNode() + result = super.getNodeEx().asNodeReverse(_) } /** Gets the `FlowState` of this node. */ diff --git a/shared/dataflow/codeql/dataflow/internal/DataFlowImplCommon.qll b/shared/dataflow/codeql/dataflow/internal/DataFlowImplCommon.qll index 1e831161a7b88..5dea0776ef13c 100644 --- a/shared/dataflow/codeql/dataflow/internal/DataFlowImplCommon.qll +++ b/shared/dataflow/codeql/dataflow/internal/DataFlowImplCommon.qll @@ -872,8 +872,6 @@ module MakeImplCommon Lang> { or exists(Node n | this.isImplicitReadNode(n) | result = n.toString() + " [Ext]") or - result = this.asParamReturnNode().toString() + " [Return]" - or // exists(boolean b | result = this.asNodeReverse(b).toString() + " [Reverse, " + b + "]") result = this.asNodeReverse(_).toString() + " [Reverse]" } @@ -887,12 +885,9 @@ module MakeImplCommon Lang> { predicate isImplicitReadNode(Node n) { this = TNodeImplicitRead(n) } - ParameterNode asParamReturnNode() { this = TParamReturnNode(result) } - Node projectToNode() { this = TNodeNormal(result) or this = TNodeImplicitRead(result) or - this = TParamReturnNode(result) or this = TNodeReverse(result, _) } @@ -911,8 +906,6 @@ module MakeImplCommon Lang> { nodeDataFlowType(this.asNode(), result) or nodeDataFlowType(this.asNodeReverse(_), result) - or - nodeDataFlowType(this.asParamReturnNode(), result) } pragma[inline] @@ -981,12 +974,9 @@ module MakeImplCommon Lang> { this.asNode().(ArgNode).argumentOf(call_.asDataFlowCall(true), pos_.asArgumentPosition()) or exists(boolean b | - // this.asNodeReverse() = getAnOutNodeExt(call_, pos_.asReturnKind()) and - this.asNodeReverse(b) = - getAnOutNode(call_.asDataFlowCall(b), pos_.asReturnKind().(ValueReturnKind).getKind()) //and //and + pragma[only_bind_into](this.asNodeReverse(b)) = + getAnOutNode(call_.asDataFlowCall(b), pos_.asReturnKind().(ValueReturnKind).getKind()) ) - // not this.asNodeReverse() instanceof PostUpdateNode // needed for swift - // call_.toString().matches("%GetBox1%") } predicate argumentOf(DataFlowCallEx call, ArgumentPositionEx pos) { @@ -1084,8 +1074,8 @@ module MakeImplCommon Lang> { } cached - SndLevelScopeOption getSecondLevelScopeEx(NodeEx n) { - result = getSecondLevelScope0(n.asNode()) + SndLevelScopeOption getSecondLevelScopeEx(RetNodeEx n) { + result = getSecondLevelScope0([n.asNode(), n.asNodeReverse(_)]) } cached @@ -1139,7 +1129,7 @@ module MakeImplCommon Lang> { cached predicate hiddenNode(NodeEx n) { - nodeIsHidden([n.asNode(), n.asNodeReverse(_), n.asParamReturnNode()]) + nodeIsHidden([n.asNode(), n.asNodeReverse(_)]) or n instanceof TNodeImplicitRead } @@ -1205,10 +1195,7 @@ module MakeImplCommon Lang> { } cached - predicate castingNodeEx(NodeEx n) { - [n.asNode(), n.asNodeReverse(_)] instanceof CastingNode or - exists(n.asParamReturnNode()) - } + predicate castingNodeEx(NodeEx n) { [n.asNode(), n.asNodeReverse(_)] instanceof CastingNode } cached predicate parameterNode(Node p, DataFlowCallable c, ParameterPosition pos) { @@ -1790,7 +1777,10 @@ module MakeImplCommon Lang> { predicate readEx(NodeEx node1, ContentSet c, NodeEx node2) { readSet(pragma[only_bind_into](node1.asNode()), c, pragma[only_bind_into](node2.asNode())) or - exists(boolean b | storeSet(node2.asNodeReverse(b), c, node1.asNodeReverse(b), _, _)) + exists(boolean b | + storeSet(pragma[only_bind_into](node2.asNodeReverse(b)), c, + pragma[only_bind_into](node1.asNodeReverse(b)), _, _) + ) } cached @@ -2028,11 +2018,7 @@ module MakeImplCommon Lang> { cached newtype TNodeEx = TNodeNormal(Node n) or - TNodeImplicitRead(Node n) or // will be restricted to nodes with actual implicit reads in `DataFlowImpl.qll` - // TParamReturnNode(ParameterNode p, SndLevelScopeOption scope) { - // paramReturnNode(_, p, scope, _) - // } or - TParamReturnNode(ParameterNode p) or + TNodeImplicitRead(Node n) or TNodeReverse(Node n, Boolean b) /** @@ -2046,17 +2032,6 @@ module MakeImplCommon Lang> { simpleLocalFlowStepExt(pragma[only_bind_into](n1), pragma[only_bind_into](n2), model) ) or - // or - // exists(Node n1, Node n2, SndLevelScopeOption scope | - // node1.asNode() = n1 and - // node2 = TParamReturnNode(n2, scope) and - // paramReturnNode(pragma[only_bind_into](n1), pragma[only_bind_into](n2), - // pragma[only_bind_into](scope), _) and - // model = "" - // ) - // node2 = TParamReturnNode(node1.asNodeReverse()) and - // model = "" - // or exists(Node n1, Node n2 | node1.asNodeReverse(_) = n1 and node2.asNodeReverse(false) = n2 and @@ -2071,11 +2046,6 @@ module MakeImplCommon Lang> { ReturnPosition getReturnPositionEx(NodeEx ret) { result = getValueReturnPosition(ret.asNode()) or - exists(ParamNode p | - ret = TParamReturnNode(p) and - result = getParamReturnPosition(p) - ) - or exists(DataFlowCallable c, ParameterPosition ppos | parameterNode(ret.asNodeReverse(_), c, ppos) and result = TReverseReturnPosition(c, ppos) //and