Skip to content

Commit 09abd6d

Browse files
committed
Update CSS CSP to avoid inline styling, add CSS links to head
1 parent 22da63d commit 09abd6d

File tree

5 files changed

+7
-5
lines changed

5 files changed

+7
-5
lines changed

examples/webui-ext/web/views/redis_info.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<%= style_tag "redis_info/css/ext.css" %>
1+
<% style_tag "redis_info/css/ext.css" %>
22

33
<div class="header-container">
44
<h1><%= t('Redis') %></h1>

lib/sidekiq/web.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def self.reset!
8686

8787
def call(env)
8888
env[:web_config] = Sidekiq::Web.configure
89-
env[:csp_nonce] = SecureRandom.base64(16)
89+
env[:csp_nonce] = SecureRandom.hex(8)
9090
env[:redis_pool] = self.class.redis_pool
9191
app.call(env)
9292
end

lib/sidekiq/web/application.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Application
2323
"media-src 'self'",
2424
"object-src 'none'",
2525
"script-src 'self' 'nonce-!placeholder!'",
26-
"style-src 'self' https: http: 'unsafe-inline'", # TODO Nonce in 8.0
26+
"style-src 'self' 'nonce-!placeholder!'",
2727
"worker-src 'self'",
2828
"base-uri 'self'"
2929
].join("; ").freeze

lib/sidekiq/web/helpers.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ def style_tag(location, **kwargs)
1818
nonce: csp_nonce,
1919
href: location
2020
}
21-
html_tag(:link, attrs.merge(kwargs))
21+
add_to_head do
22+
html_tag(:link, attrs.merge(kwargs))
23+
end
2224
end
2325

2426
def script_tag(location, **kwargs)

web/views/_poll_link.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<% if pollable? %>
22
<a class="live-poll-start live-poll btn btn-primary"><%= t('LivePoll') %></a>
3-
<a class="live-poll-stop live-poll btn btn-primary active"><%= t('StopPolling') %></a>
3+
<a class="live-poll-stop live-poll btn btn-primary active" style="display: none"><%= t('StopPolling') %></a>
44
<% end %>

0 commit comments

Comments
 (0)