Skip to content

Commit 3d109a4

Browse files
authored
Merge pull request #8777 from github/nickrolfe/post_update_node
Ruby: make PostUpdateNode public
2 parents e604756 + f1b8af1 commit 3d109a4

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPrivate.qll

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -820,24 +820,13 @@ string ppReprType(DataFlowType t) { result = t.toString() }
820820
pragma[inline]
821821
predicate compatibleTypes(DataFlowType t1, DataFlowType t2) { any() }
822822

823-
/**
824-
* A node associated with an object after an operation that might have
825-
* changed its state.
826-
*
827-
* This can be either the argument to a callable after the callable returns
828-
* (which might have mutated the argument), or the qualifier of a field after
829-
* an update to the field.
830-
*
831-
* Nodes corresponding to AST elements, for example `ExprNode`, usually refer
832-
* to the value before the update.
833-
*/
834-
abstract class PostUpdateNode extends Node {
823+
abstract class PostUpdateNodeImpl extends Node {
835824
/** Gets the node before the state update. */
836825
abstract Node getPreUpdateNode();
837826
}
838827

839828
private module PostUpdateNodes {
840-
class ExprPostUpdateNode extends PostUpdateNode, NodeImpl, TExprPostUpdateNode {
829+
class ExprPostUpdateNode extends PostUpdateNodeImpl, NodeImpl, TExprPostUpdateNode {
841830
private CfgNodes::ExprCfgNode e;
842831

843832
ExprPostUpdateNode() { this = TExprPostUpdateNode(e) }
@@ -851,7 +840,7 @@ private module PostUpdateNodes {
851840
override string toStringImpl() { result = "[post] " + e.toString() }
852841
}
853842

854-
private class SummaryPostUpdateNode extends SummaryNode, PostUpdateNode {
843+
private class SummaryPostUpdateNode extends SummaryNode, PostUpdateNodeImpl {
855844
private Node pre;
856845

857846
SummaryPostUpdateNode() { FlowSummaryImpl::Private::summaryPostUpdateNode(this, pre) }

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPublic.qll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,22 @@ class LocalSourceNode extends Node {
121121
LocalSourceNode backtrack(TypeBackTracker t2, TypeBackTracker t) { t2 = t.step(result, this) }
122122
}
123123

124+
/**
125+
* A node associated with an object after an operation that might have
126+
* changed its state.
127+
*
128+
* This can be either the argument to a callable after the callable returns
129+
* (which might have mutated the argument), or the qualifier of a field after
130+
* an update to the field.
131+
*
132+
* Nodes corresponding to AST elements, for example `ExprNode`, usually refer
133+
* to the value before the update.
134+
*/
135+
class PostUpdateNode extends Node instanceof PostUpdateNodeImpl {
136+
/** Gets the node before the state update. */
137+
Node getPreUpdateNode() { result = super.getPreUpdateNode() }
138+
}
139+
124140
cached
125141
private predicate hasLocalSource(Node sink, Node source) {
126142
// Declaring `source` to be a `SourceNode` currently causes a redundant check in the

ruby/ql/lib/codeql/ruby/typetracking/TypeTrackerSpecific.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ predicate basicStoreStep(Node nodeFrom, Node nodeTo, string content) {
147147
// TODO: support SetterMethodCall inside TuplePattern
148148
exists(ExprNodes::MethodCallCfgNode call |
149149
content = getSetterCallAttributeName(call.getExpr()) and
150-
nodeTo.(DataFlowPrivate::PostUpdateNode).getPreUpdateNode().asExpr() = call.getReceiver() and
150+
nodeTo.(DataFlowPublic::PostUpdateNode).getPreUpdateNode().asExpr() = call.getReceiver() and
151151
call.getExpr() instanceof AST::SetterMethodCall and
152152
call.getArgument(call.getNumberOfArguments() - 1) =
153153
nodeFrom.(DataFlowPublic::ExprNode).getExprNode()

0 commit comments

Comments
 (0)