Skip to content

Commit ac1b7eb

Browse files
committed
Remove SetterMethodCall in MkAttribute
1 parent a64f7cd commit ac1b7eb

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

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

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Node = DataFlowPublic::Node;
1616
class TypeTrackingNode = DataFlowPublic::LocalSourceNode;
1717

1818
private newtype TOptionalTypeTrackerContent =
19-
MkAttribute(string name) { name = getSetterCallAttributeName(_) } or
19+
MkAttribute(string name) { name = any(Ast::SetterMethodCall c).getTargetName() } or
2020
MkContent(DataFlowPublic::Content content) or
2121
MkNoContent()
2222

@@ -196,27 +196,14 @@ predicate basicStoreStep(Node nodeFrom, Node nodeTo, TypeTrackerContent content)
196196
predicate postUpdateStoreStep(Node nodeFrom, Node nodeTo, TypeTrackerContent content) {
197197
// TODO: support SetterMethodCall inside TuplePattern
198198
exists(ExprNodes::MethodCallCfgNode call |
199-
content = MkAttribute(getSetterCallAttributeName(call.getExpr())) and
199+
content = MkAttribute(call.getExpr().(Ast::SetterMethodCall).getTargetName()) and
200200
nodeTo.(DataFlowPublic::PostUpdateNode).getPreUpdateNode().asExpr() = call.getReceiver() and
201201
call.getExpr() instanceof Ast::SetterMethodCall and
202202
call.getArgument(call.getNumberOfArguments() - 1) =
203203
nodeFrom.(DataFlowPublic::ExprNode).getExprNode()
204204
)
205205
}
206206

207-
/**
208-
* Returns the name of the attribute being set by the setter method call, i.e.
209-
* the name of the setter method without the trailing `=`. In the following
210-
* example, the result is `"bar"`.
211-
*
212-
* ```rb
213-
* foo.bar = 1
214-
* ```
215-
*/
216-
private string getSetterCallAttributeName(Ast::SetterMethodCall call) {
217-
result = call.getTargetName()
218-
}
219-
220207
/**
221208
* Holds if `nodeTo` is the result of accessing the `content` content of `nodeFrom`.
222209
*/

0 commit comments

Comments
 (0)