mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
Ruby: Reorganise ActionDispatch framework
Put routing modelling inside a Routing module.
This commit is contained in:
@@ -83,7 +83,7 @@ class ActionControllerActionMethod extends Method, HTTP::Server::RequestHandler:
|
||||
* Gets a route to this handler, if one exists.
|
||||
* May return multiple results.
|
||||
*/
|
||||
ActionDispatch::Route getARoute() {
|
||||
ActionDispatch::Routing::Route getARoute() {
|
||||
exists(string name |
|
||||
isRoute(result, name, controllerClass) and
|
||||
isActionControllerMethod(this, name, controllerClass)
|
||||
@@ -93,10 +93,10 @@ class ActionControllerActionMethod extends Method, HTTP::Server::RequestHandler:
|
||||
|
||||
pragma[nomagic]
|
||||
private predicate isRoute(
|
||||
ActionDispatch::Route route, string name, ActionControllerControllerClass controllerClass
|
||||
ActionDispatch::Routing::Route route, string name, ActionControllerControllerClass controllerClass
|
||||
) {
|
||||
route.getController() + "_controller" =
|
||||
ActionDispatch::underscore(namespaceDeclaration(controllerClass)) and
|
||||
ActionDispatch::Routing::underscore(namespaceDeclaration(controllerClass)) and
|
||||
name = route.getAction()
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@ private import codeql.ruby.frameworks.ActionDispatch
|
||||
private import codeql.ruby.frameworks.ActionController
|
||||
|
||||
query predicate actionDispatchRoutes(
|
||||
ActionDispatch::Route r, string method, string path, string controller, string action
|
||||
ActionDispatch::Routing::Route r, string method, string path, string controller, string action
|
||||
) {
|
||||
r.getHttpMethod() = method and
|
||||
r.getPath() = path and
|
||||
@@ -12,13 +12,13 @@ query predicate actionDispatchRoutes(
|
||||
}
|
||||
|
||||
query predicate actionDispatchControllerMethods(
|
||||
ActionDispatch::Route r, ActionControllerActionMethod m
|
||||
ActionDispatch::Routing::Route r, ActionControllerActionMethod m
|
||||
) {
|
||||
m.getARoute() = r
|
||||
}
|
||||
|
||||
query predicate underscore(string input, string output) {
|
||||
output = ActionDispatch::underscore(input) and
|
||||
output = ActionDispatch::Routing::underscore(input) and
|
||||
input in [
|
||||
"Foo", "FooBar", "Foo::Bar", "FooBar::Baz", "Foo::Bar::Baz", "Foo::Bar::BazQuux", "invalid",
|
||||
"HTTPServerRequest", "LotsOfCapitalLetters"
|
||||
|
||||
Reference in New Issue
Block a user