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 {
272
272
key = result .getArgument ( 0 ) .getConstantValue ( )
273
273
}
274
274
275
+ private CallNode getAnElementWriteCall ( ) {
276
+ result = this .getAMethodCall ( "[]=" ) and
277
+ result .getNumberOfArguments ( ) = 2
278
+ }
279
+
275
280
/**
276
281
* Gets a value stored as an element on this node, such as the `x` in `obj[key] = x`.
277
282
*
278
283
* Concretely, this gets the second argument from any call to `[]=` where this node flows to the receiver.
279
284
*/
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 ) }
287
286
288
287
/**
289
288
* Gets the `x` in `obj[key] = x`, where this node flows to `obj`.
@@ -293,8 +292,7 @@ class LocalSourceNode extends Node {
293
292
*/
294
293
Node getAnElementWriteValue ( ConstantValue key ) {
295
294
exists ( CallNode call |
296
- call = this .getAMethodCall ( "[]=" ) and
297
- call .getNumberOfArguments ( ) = 2 and
295
+ call = this .getAnElementWriteCall ( ) and
298
296
call .getArgument ( 0 ) .getConstantValue ( ) = key and
299
297
result = call .getArgument ( 1 )
300
298
)
You can’t perform that action at this time.
0 commit comments