Skip to content

Commit 41ed9f3

Browse files
committed
Data flow: Fix inconsistencies
1 parent 00e5441 commit 41ed9f3

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

ql/src/codeql_ruby/dataflow/internal/DataFlowPrivate.qll

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,14 @@ private module Cached {
122122
TNormalParameterNode(Parameter p) { not p instanceof BlockParameter } or
123123
TSelfParameterNode(MethodBase m) or
124124
TBlockParameterNode(MethodBase m) or
125-
TExprPostUpdateNode(CfgNodes::ExprCfgNode n) { n.getNode() instanceof Argument }
125+
TExprPostUpdateNode(CfgNodes::ExprCfgNode n) {
126+
exists(AstNode node | node = n.getNode() |
127+
node instanceof Argument and
128+
not node instanceof BlockArgument
129+
or
130+
n = any(CfgNodes::ExprNodes::CallCfgNode call).getReceiver()
131+
)
132+
}
126133

127134
class TParameterNode = TNormalParameterNode or TBlockParameterNode or TSelfParameterNode;
128135

@@ -142,7 +149,7 @@ private module Cached {
142149
nodeTo.(ParameterNode).getParameter().(KeywordParameter).getDefaultValue() =
143150
nodeFrom.asExpr().getExpr()
144151
or
145-
nodeFrom.(SelfParameterNode).getMethod() = nodeTo.asExpr().getExpr().getEnclosingMethod() and
152+
nodeFrom.(SelfParameterNode).getMethod() = nodeTo.asExpr().getExpr().getEnclosingCallable() and
146153
nodeTo.asExpr().getExpr() instanceof Self
147154
or
148155
nodeFrom.asExpr() = nodeTo.asExpr().(CfgNodes::ExprNodes::AssignExprCfgNode).getRhs()
@@ -446,6 +453,13 @@ predicate jumpStep(Node pred, Node succ) {
446453
or
447454
SsaImpl::captureFlowOut(pred.(SsaDefinitionNode).getDefinition(),
448455
succ.(SsaDefinitionNode).getDefinition())
456+
or
457+
exists(Self s, Method m |
458+
s = succ.asExpr().getExpr() and
459+
pred.(SelfParameterNode).getMethod() = m and
460+
m = s.getEnclosingMethod() and
461+
m != s.getEnclosingCallable()
462+
)
449463
}
450464

451465
predicate storeStep(Node node1, Content c, Node node2) { none() }
@@ -537,7 +551,7 @@ class Unit extends TUnit {
537551
*
538552
* This predicate is only used for consistency checks.
539553
*/
540-
predicate isImmutableOrUnobservable(Node n) { none() }
554+
predicate isImmutableOrUnobservable(Node n) { n instanceof BlockArgumentNode }
541555

542556
/**
543557
* Holds if the node `n` is unreachable when the call context is `call`.

0 commit comments

Comments
 (0)