Skip to content

Commit abc283e

Browse files
committed
remove ErbFile refs
1 parent e403fc7 commit abc283e

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

ql/src/codeql_ruby/frameworks/ActionController.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ class ActionControllerActionMethod extends Method, HTTP::Server::RequestHandler:
6868
* corresponding template file at
6969
* `<source_prefix>/app/views/<subpath>/<method_name>.html.erb`.
7070
*/
71-
ErbFile getDefaultTemplateFile() {
71+
// TODO: result should be `ErbFile`
72+
File getDefaultTemplateFile() {
7273
exists(string templatePath, string sourcePrefix, string subPath, string controllerPath |
7374
controllerPath = this.getLocation().getFile().getAbsolutePath() and
7475
sourcePrefix = controllerPath.regexpCapture("^(.*)/app/controllers/.*$", 1) and
@@ -183,7 +184,8 @@ class ActionControllerHelperMethod extends Method {
183184
* Gets an `ActionControllerControllerClass` associated with the given `ErbFile`
184185
* according to Rails path conventions.
185186
*/
186-
ActionControllerControllerClass getAssociatedControllerClass(ErbFile f) {
187+
// TODO: parameter should be `ErbFile`
188+
ActionControllerControllerClass getAssociatedControllerClass(File f) {
187189
exists(string localPrefix, string sourcePrefix, string controllerPath |
188190
controllerPath = result.getLocation().getFile().getAbsolutePath() and
189191
sourcePrefix = f.getAbsolutePath().regexpCapture("^(.*)/app/views/(?:.*?)/(?:[^/]*)$", 1) and

ql/src/codeql_ruby/frameworks/ActionView.qll

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ predicate inActionViewContext(AstNode n) {
1111
n.getEnclosingModule() instanceof ViewComponentClass
1212
or
1313
// Within a template
14-
n.getLocation().getFile() instanceof ErbFile
14+
// TODO: n.getLocation().getFile() instanceof ErbFile
15+
n.getLocation().getFile().getExtension() = "erb"
1516
}
1617

1718
/**
@@ -35,7 +36,10 @@ private class ActionViewContextCall extends MethodCall {
3536
inActionViewContext(this)
3637
}
3738

38-
predicate isInErbFile() { this.getLocation().getFile() instanceof ErbFile }
39+
predicate isInErbFile() {
40+
// TODO: this.getLocation().getFile() instanceof ErbFile
41+
this.getLocation().getFile().getExtension() = "erb"
42+
}
3943
}
4044

4145
/** A call to the `raw` method to output a value without HTML escaping. */
@@ -94,7 +98,8 @@ abstract class RenderCall extends MethodCall {
9498
/**
9599
* Get the template file to be rendered by this call, if any.
96100
*/
97-
ErbFile getTemplateFile() { result.getAbsolutePath().matches(this.getTemplatePathPatterns()) }
101+
// TODO: parameter should be `ErbFile`
102+
File getTemplateFile() { result.getAbsolutePath().matches(this.getTemplatePathPatterns()) }
98103

99104
/**
100105
* Get the local variables passed as context to the renderer

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ query predicate redirectToCalls(RedirectToCall c) { any() }
1414

1515
query predicate actionControllerHelperMethods(ActionControllerHelperMethod m) { any() }
1616

17-
query predicate getAssociatedControllerClasses(ActionControllerControllerClass cls, ErbFile f) {
17+
// TODO: second parameter should be `ErbFile`
18+
query predicate getAssociatedControllerClasses(ActionControllerControllerClass cls, File f) {
1819
cls = getAssociatedControllerClass(f)
1920
}

0 commit comments

Comments
 (0)