Skip to content

Commit

Permalink
Relax CSP for style-src
Browse files Browse the repository at this point in the history
Followup to sidekiq#6270 (comment)

A nonce doesn't work with `unsafe-inline`, so just go back to how it was previously. Keep
this as a task for later instead
  • Loading branch information
Earlopain committed May 9, 2024
1 parent 8f7606b commit 2afc80a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/sidekiq/web/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class WebApplication
"media-src 'self'",
"object-src 'none'",
"script-src 'self' 'nonce-!placeholder!'",
"style-src 'self' 'nonce-!placeholder!'",
"style-src 'self' https: http: 'unsafe-inline'", # TODO Nonce in 8.0
"worker-src 'self'",
"base-uri 'self'"
].join("; ").freeze
Expand Down
2 changes: 1 addition & 1 deletion test/web_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def job_params(job, score)
get "/", {}
policies = last_response.headers["Content-Security-Policy"].split("; ")
assert_includes(policies, "connect-src 'self' https: http: wss: ws:")
assert_includes(policies, "style-src 'self' 'nonce-#{last_request.env[:csp_nonce]}'")
assert_includes(policies, "style-src 'self' https: http: 'unsafe-inline'")
assert_includes(policies, "script-src 'self' 'nonce-#{last_request.env[:csp_nonce]}'")
assert_includes(policies, "object-src 'none'")
assert_operator(24, :>=, last_request.env[:csp_nonce].length)
Expand Down

0 comments on commit 2afc80a

Please sign in to comment.