Skip to content

Commit 9f99a3c

Browse files
committed
Ruby: Model sanitize ActionView helper
1 parent 9e625ac commit 9f99a3c

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ private class ActionViewHtmlSafeCall extends HtmlSafeCall {
3838
*/
3939
abstract class HtmlEscapeCall extends MethodCall {
4040
// "h" is aliased to "html_escape" in ActiveSupport
41-
HtmlEscapeCall() { this.getMethodName() = ["html_escape", "html_escape_once", "h"] }
41+
HtmlEscapeCall() { this.getMethodName() = ["html_escape", "html_escape_once", "h", "sanitize"] }
4242
}
4343

4444
/**

ruby/ql/test/query-tests/security/cwe-079/app/views/foo/bars/show.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,6 @@
7575

7676
<%# BAD: javasript_include_tag called with remote input %>
7777
<%= javascript_include_tag params[:url] %>
78+
79+
<%# GOOD: input is sanitized %>
80+
<%= sanitize(params[:comment]).html_safe %>

0 commit comments

Comments
 (0)