|
1 | 1 | <%# BAD: An instance variable rendered without escaping %> |
2 | | -<a href="<%= raw @user_website %>">website</a> <%# $ Alert[rb/reflected-xss] %> |
| 2 | +<a href="<%= raw @user_website %>">website</a> |
3 | 3 |
|
4 | 4 | <%# BAD: A local rendered raw as a local variable %> |
5 | | -<%= raw display_text %> <%# $ Alert[rb/reflected-xss] %> |
| 5 | +<%= raw display_text %> |
6 | 6 |
|
7 | 7 | <%# BAD: A local rendered raw via the local_assigns hash %> |
8 | | -<%= raw local_assigns[:display_text] %> <%# $ Alert[rb/reflected-xss] %> |
| 8 | +<%= raw local_assigns[:display_text] %> |
9 | 9 |
|
10 | 10 | <% key = :display_text %> |
11 | 11 | <%# BAD: A local rendered raw via the locals_assigns hash %> |
12 | | -<%= raw local_assigns[key] %> <%# $ Alert[rb/reflected-xss] %> |
| 12 | +<%= raw local_assigns[key] %> |
13 | 13 |
|
14 | 14 | <ul> |
15 | 15 | <% for key in [:display_text, :safe_text] do %> |
16 | 16 | <%# BAD: A local rendered raw via the locals hash %> |
17 | | - <li><%= raw local_assigns[key] %></li> <%# $ Alert[rb/reflected-xss] %> |
| 17 | + <li><%= raw local_assigns[key] %></li> |
18 | 18 | <% end %> |
19 | 19 | </ul> |
20 | 20 |
|
|
32 | 32 |
|
33 | 33 | <%# BAD: html_safe marks string as not requiring HTML escaping %> |
34 | 34 | <%= |
35 | | - display_text.html_safe <%# $ Alert[rb/reflected-xss] %> |
| 35 | + display_text.html_safe |
36 | 36 | %> |
37 | 37 |
|
38 | 38 | <%# BAD: html_safe marks string as not requiring HTML escaping %> |
39 | 39 | <%= |
40 | | - @instance_text.html_safe <%# $ Alert[rb/reflected-xss] %> |
| 40 | + @instance_text.html_safe |
41 | 41 | %> |
42 | 42 |
|
43 | 43 | <%= render partial: 'foo/bars/widget', locals: { display_text: "widget_" + display_text } %> |
44 | 44 |
|
45 | 45 | <%# BAD: user_name is a helper method that returns unsanitized user-input %> |
46 | | -<%= user_name.html_safe %> <%# $ Alert[rb/reflected-xss] %> |
| 46 | +<%= user_name.html_safe %> |
47 | 47 |
|
48 | 48 | <%# BAD: user_name_memo is a helper method that returns unsanitized user-input %> |
49 | 49 | <%# TODO: we miss this because the return value from user_name_memo is not properly linked to this call %> |
50 | | -<%= user_name_memo.html_safe %> <%# $ Alert[rb/reflected-xss] %> |
| 50 | +<%= user_name_memo.html_safe %> |
51 | 51 |
|
52 | 52 | <%# BAD: unsanitized user-input should not be passed to link_to as the URL %> |
53 | | -<%= link_to "user website", params[:website] %> <%# $ Alert[rb/reflected-xss] %> |
| 53 | +<%= link_to "user website", params[:website] %> |
54 | 54 |
|
55 | 55 | <%# BAD: unsanitized user-input should not be passed to link_to as the URL %> |
56 | | -<%= link_to params[:website], class: "user-link" do %> <%# $ Alert[rb/reflected-xss] %> |
| 56 | +<%= link_to params[:website], class: "user-link" do %> |
57 | 57 | user website |
58 | 58 | <% end %> |
59 | 59 |
|
|
70 | 70 | %> |
71 | 71 |
|
72 | 72 | <%# BAD: simple_format called with sanitize: false %> |
73 | | -<%= simple_format(params[:comment], sanitize: false) %> <%# $ Alert[rb/reflected-xss] %> |
| 73 | +<%= simple_format(params[:comment], sanitize: false) %> |
74 | 74 |
|
75 | 75 | <%# BAD: javasript_include_tag called with remote input %> |
76 | | -<%= javascript_include_tag params[:url] %> <%# $ Alert[rb/reflected-xss] %> |
| 76 | +<%= javascript_include_tag params[:url] %> |
77 | 77 |
|
78 | 78 | <%# GOOD: input is sanitized %> |
79 | 79 | <%= sanitize(params[:comment]).html_safe %> |
80 | 80 |
|
81 | 81 | <%# BAD: A local rendered raw as a local variable %> |
82 | | -<%== display_text %> <%# $ Alert[rb/reflected-xss] %> |
| 82 | +<%== display_text %> |
83 | 83 |
|
84 | 84 | <%# BAD: translate preserves taint %> |
85 | | -<%= raw translate("welcome", name: display_text) %> <%# $ Alert[rb/reflected-xss] %> |
86 | | -<%= raw t("welcome", name: display_text) %> <%# $ Alert[rb/reflected-xss] %> |
| 85 | +<%= raw translate("welcome", name: display_text) %> |
| 86 | +<%= raw t("welcome", name: display_text) %> |
87 | 87 |
|
88 | 88 | <%# GOOD: translate sanitizes for html keys %> |
89 | 89 | <%= raw t("welcome1.html", name: display_text) %> |
0 commit comments