Skip to content

Commit 3d9f9af

Browse files
authored
Merge pull request github#15566 from hmac/hmac-actioncontroller-regex
Ruby: Fix ActionController path regex
2 parents 99497e5 + 3a90d78 commit 3d9f9af

20 files changed

+256
-237
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,8 @@ predicate controllerTemplateFile(ActionControllerClass cls, ErbFile templateFile
374374
controllerPath = getActionControllerClassRelativePath(cls) and
375375
// `sourcePrefix` is either a prefix path ending in a slash, or empty if
376376
// the rails app is at the source root
377-
sourcePrefix = [controllerPath.regexpCapture("^(.*/)app/controllers/(?:.*?)/(?:[^/]*)$", 1), ""] and
377+
sourcePrefix =
378+
[controllerPath.regexpCapture("^(.*/)app/controllers/(?:[^/]+/)?(?:[^/]*)$", 1), ""] and
378379
controllerPath = sourcePrefix + "app/controllers/" + subPath + "_controller.rb"
379380
|
380381
sourcePrefix + "app/views/" + subPath = templateFile.getParentContainer().getRelativePath()

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

Lines changed: 110 additions & 92 deletions
Large diffs are not rendered by default.

ruby/ql/test/library-tests/frameworks/action_controller/Filters.expected

Lines changed: 144 additions & 144 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)