Skip to content

Commit 22d7b04

Browse files
committed
Ruby: Fix <<
1 parent e3115b5 commit 22d7b04

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

ruby/ql/lib/codeql/ruby/frameworks/ActiveRecord.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,9 @@ private class ActiveRecordAssociationMethodCall extends DataFlow::CallNode {
618618
(
619619
assoc.isCollection() and
620620
(
621-
this.getMethodName() = pluralize(model) + ["", "=", "<<"]
621+
this.getMethodName() = pluralize(model) + ["", "="]
622+
or
623+
this.getMethodName() = "<<"
622624
or
623625
this.getMethodName() = model + ["_ids", "_ids="]
624626
)

ruby/ql/test/library-tests/frameworks/active_record/ActiveRecord.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ activeRecordInstances
3939
| associations.rb:27:9:27:28 | call to create |
4040
| associations.rb:29:1:29:7 | author2 |
4141
| associations.rb:29:1:29:13 | call to posts |
42+
| associations.rb:29:1:29:22 | ... << ... |
4243
| associations.rb:29:18:29:22 | post2 |
4344
| associations.rb:31:1:31:5 | post1 |
4445
| associations.rb:31:1:31:12 | __synth__0 |
@@ -175,6 +176,8 @@ activeRecordModelInstantiations
175176
| associations.rb:27:9:27:21 | call to posts | associations.rb:5:1:9:3 | Post |
176177
| associations.rb:27:9:27:28 | call to create | associations.rb:5:1:9:3 | Post |
177178
| associations.rb:29:1:29:13 | call to posts | associations.rb:5:1:9:3 | Post |
179+
| associations.rb:29:1:29:22 | ... << ... | associations.rb:11:1:13:3 | Tag |
180+
| associations.rb:29:1:29:22 | ... << ... | associations.rb:15:1:17:3 | Comment |
178181
| associations.rb:31:1:31:12 | call to author= | associations.rb:1:1:3:3 | Author |
179182
| associations.rb:35:1:35:14 | call to comments | associations.rb:15:1:17:3 | Comment |
180183
| associations.rb:35:1:35:21 | call to create | associations.rb:15:1:17:3 | Comment |

0 commit comments

Comments
 (0)