Skip to content

Commit 3031b39

Browse files
committed
Ruby: prevent bad join in ActionController.qll
1 parent 61cd05c commit 3031b39

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,21 @@ class ActionControllerActionMethod extends Method, HTTP::Server::RequestHandler:
9292
* May return multiple results.
9393
*/
9494
ActionDispatch::Route getARoute() {
95-
result.getController() + "_controller" =
96-
ActionDispatch::underscore(namespaceDeclaration(controllerClass)) and
97-
isActionControllerMethod(this, result.getAction(), controllerClass)
95+
exists(string name |
96+
isRoute(result, name, controllerClass) and
97+
isActionControllerMethod(this, name, controllerClass)
98+
)
9899
}
99100
}
100101

102+
private predicate isRoute(
103+
ActionDispatch::Route route, string name, ActionControllerControllerClass controllerClass
104+
) {
105+
route.getController() + "_controller" =
106+
ActionDispatch::underscore(namespaceDeclaration(controllerClass)) and
107+
name = route.getAction()
108+
}
109+
101110
// A method call with a `self` receiver from within a controller class
102111
private class ActionControllerContextCall extends MethodCall {
103112
private ActionControllerControllerClass controllerClass;

0 commit comments

Comments
 (0)