Skip to content

Commit fe65fb8

Browse files
authored
Merge pull request github#12360 from kaspersv/kaspersv/actioncontroller-prevent-bad-join
ActionController: Prevent bad join
2 parents f2f9725 + 9cac4bb commit fe65fb8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,15 +520,15 @@ ActionControllerClass getAssociatedControllerClass(ErbFile f) {
520520
* templates in `app/views/` and `app/views/layouts/`.
521521
*/
522522
predicate controllerTemplateFile(ActionControllerClass cls, ErbFile templateFile) {
523-
exists(string templatesPath, string sourcePrefix, string subPath, string controllerPath |
523+
exists(string sourcePrefix, string subPath, string controllerPath |
524524
controllerPath = cls.getLocation().getFile().getRelativePath() and
525-
templatesPath = templateFile.getParentContainer().getRelativePath() and
526525
// `sourcePrefix` is either a prefix path ending in a slash, or empty if
527526
// the rails app is at the source root
528527
sourcePrefix = [controllerPath.regexpCapture("^(.*/)app/controllers/(?:.*?)/(?:[^/]*)$", 1), ""] and
529528
controllerPath = sourcePrefix + "app/controllers/" + subPath + "_controller.rb" and
530529
(
531-
templatesPath = sourcePrefix + "app/views/" + subPath or
530+
sourcePrefix + "app/views/" + subPath = templateFile.getParentContainer().getRelativePath()
531+
or
532532
templateFile.getRelativePath().matches(sourcePrefix + "app/views/layouts/" + subPath + "%")
533533
)
534534
)

0 commit comments

Comments
 (0)