File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed
ruby/ql/lib/codeql/ruby/dataflow/internal Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -272,18 +272,17 @@ class LocalSourceNode extends Node {
272272 key = result .getArgument ( 0 ) .getConstantValue ( )
273273 }
274274
275+ private CallNode getAnElementWriteCall ( ) {
276+ result = this .getAMethodCall ( "[]=" ) and
277+ result .getNumberOfArguments ( ) = 2
278+ }
279+
275280 /**
276281 * Gets a value stored as an element on this node, such as the `x` in `obj[key] = x`.
277282 *
278283 * Concretely, this gets the second argument from any call to `[]=` where this node flows to the receiver.
279284 */
280- Node getAnElementWriteValue ( ) {
281- exists ( CallNode call |
282- call = this .getAMethodCall ( "[]=" ) and
283- call .getNumberOfArguments ( ) = 2 and
284- result = call .getArgument ( 1 )
285- )
286- }
285+ Node getAnElementWriteValue ( ) { result = this .getAnElementWriteCall ( ) .getArgument ( 1 ) }
287286
288287 /**
289288 * Gets the `x` in `obj[key] = x`, where this node flows to `obj`.
@@ -293,8 +292,7 @@ class LocalSourceNode extends Node {
293292 */
294293 Node getAnElementWriteValue ( ConstantValue key ) {
295294 exists ( CallNode call |
296- call = this .getAMethodCall ( "[]=" ) and
297- call .getNumberOfArguments ( ) = 2 and
295+ call = this .getAnElementWriteCall ( ) and
298296 call .getArgument ( 0 ) .getConstantValue ( ) = key and
299297 result = call .getArgument ( 1 )
300298 )
You can’t perform that action at this time.
0 commit comments