Skip to content

Commit 4a39bc8

Browse files
authored
Merge pull request #10598 from hmac/hmac/actioncontroller-metal
Ruby: Identify ActionController::Metal controllers
2 parents 8ab5617 + eada74a commit 4a39bc8

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Subclasses of `ActionController::Metal` are now recognised as controllers.

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ class ActionControllerControllerClass extends ClassDeclaration {
3232
API::getTopLevelMember("ActionController").getMember("Base"),
3333
// In Rails applications `ApplicationController` typically extends `ActionController::Base`, but we
3434
// treat it separately in case the `ApplicationController` definition is not in the database.
35-
API::getTopLevelMember("ApplicationController")
35+
API::getTopLevelMember("ApplicationController"),
36+
// ActionController::Metal technically doesn't contain all of the
37+
// methods available in Base, such as those for rendering views.
38+
// However we prefer to be over-sensitive in this case in order to find
39+
// more results.
40+
API::getTopLevelMember("ActionController").getMember("Metal")
3641
].getASubclass().getAValueReachableFromSource().asExpr().getExpr()
3742
}
3843

ruby/ql/test/library-tests/frameworks/ActionController.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ actionControllerControllerClasses
88
| app/controllers/foo/bars_controller.rb:3:1:46:3 | BarsController |
99
| app/controllers/photos_controller.rb:1:1:4:3 | PhotosController |
1010
| app/controllers/posts_controller.rb:1:1:10:3 | PostsController |
11+
| app/controllers/tags_controller.rb:1:1:2:3 | TagsController |
1112
| app/controllers/users/notifications_controller.rb:2:3:5:5 | NotificationsController |
1213
actionControllerActionMethods
1314
| active_record/ActiveRecord.rb:27:3:38:5 | some_request_handler |
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class TagsController < ActionController::Metal
2+
end

0 commit comments

Comments
 (0)