File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
ql/lib/codeql/ruby/frameworks Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,13 @@ private class ActionControllerHtmlSafeCall extends HtmlSafeCall {
134
134
}
135
135
}
136
136
137
+ // A call to `html_escape` from within a controller.
138
+ private class ActionControllerHtmlEscapeCall extends HtmlEscapeCall {
139
+ ActionControllerHtmlEscapeCall ( ) {
140
+ this .getEnclosingModule ( ) instanceof ActionControllerControllerClass
141
+ }
142
+ }
143
+
137
144
/**
138
145
* A call to the `redirect_to` method, used in an action to redirect to a
139
146
* specific URL/path or to a different action in this controller.
Original file line number Diff line number Diff line change @@ -25,6 +25,29 @@ private class ActionViewHtmlSafeCall extends HtmlSafeCall {
25
25
ActionViewHtmlSafeCall ( ) { inActionViewContext ( this ) }
26
26
}
27
27
28
+ /**
29
+ * A call to a method named "html_escape", "html_escape_once", or "h".
30
+ */
31
+ abstract class HtmlEscapeCall extends MethodCall {
32
+ // "h" is aliased to "html_escape" in ActiveSupport
33
+ HtmlEscapeCall ( ) { this .getMethodName ( ) = [ "html_escape" , "html_escape_once" , "h" ] }
34
+ }
35
+
36
+ class RailsHtmlEscaping extends Escaping:: Range , DataFlow:: CallNode {
37
+ RailsHtmlEscaping ( ) { this .asExpr ( ) .getExpr ( ) instanceof HtmlEscapeCall }
38
+
39
+ override DataFlow:: Node getAnInput ( ) { result = this .getArgument ( 0 ) }
40
+
41
+ override DataFlow:: Node getOutput ( ) { result = this }
42
+
43
+ override string getKind ( ) { result = Escaping:: getHtmlKind ( ) }
44
+ }
45
+
46
+ // A call to `html_escape` from within a template.
47
+ private class ActionViewHtmlEscapeCall extends HtmlEscapeCall {
48
+ ActionViewHtmlEscapeCall ( ) { inActionViewContext ( this ) }
49
+ }
50
+
28
51
// A call in a context where some commonly used `ActionView` methods are available.
29
52
private class ActionViewContextCall extends MethodCall {
30
53
ActionViewContextCall ( ) {
You can’t perform that action at this time.
0 commit comments