Skip to content

Commit 4217a50

Browse files
committed
Treat ActiveRecord.create as a model instantiation
1 parent 424f31a commit 4217a50

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ private string staticFinderMethodName() {
255255
result = baseName + ["", "!"]
256256
)
257257
or
258-
result = "new"
258+
result = ["new", "create"]
259259
}
260260

261261
// Gets the "final" receiver in a chain of method calls.

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ activeRecordInstances
1616
| ActiveRecord.rb:56:7:56:40 | call to find_by |
1717
| ActiveRecord.rb:60:5:60:33 | call to find_by |
1818
| ActiveRecord.rb:62:5:62:34 | call to find |
19+
| ActiveRecord.rb:72:5:72:24 | call to create |
20+
| ActiveRecord.rb:76:5:76:66 | call to create |
21+
| ActiveRecord.rb:80:5:80:68 | call to create |
22+
| ActiveRecord.rb:84:5:84:16 | call to create |
1923
| associations.rb:19:1:19:20 | ... = ... |
2024
| associations.rb:19:1:19:20 | ... = ... |
2125
| associations.rb:19:11:19:20 | call to new |
@@ -168,6 +172,10 @@ activeRecordModelInstantiations
168172
| ActiveRecord.rb:56:7:56:40 | call to find_by | ActiveRecord.rb:5:1:15:3 | User |
169173
| ActiveRecord.rb:60:5:60:33 | call to find_by | ActiveRecord.rb:5:1:15:3 | User |
170174
| ActiveRecord.rb:62:5:62:34 | call to find | ActiveRecord.rb:5:1:15:3 | User |
175+
| ActiveRecord.rb:72:5:72:24 | call to create | ActiveRecord.rb:17:1:21:3 | Admin |
176+
| ActiveRecord.rb:76:5:76:66 | call to create | ActiveRecord.rb:17:1:21:3 | Admin |
177+
| ActiveRecord.rb:80:5:80:68 | call to create | ActiveRecord.rb:17:1:21:3 | Admin |
178+
| ActiveRecord.rb:84:5:84:16 | call to create | ActiveRecord.rb:17:1:21:3 | Admin |
171179
| associations.rb:19:11:19:20 | call to new | associations.rb:1:1:3:3 | Author |
172180
| associations.rb:21:9:21:21 | call to posts | associations.rb:5:1:9:3 | Post |
173181
| associations.rb:21:9:21:28 | call to create | associations.rb:5:1:9:3 | Post |

0 commit comments

Comments
 (0)