-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Report Content-Security-Policy problems to honeybadger
Co-authored-by: Christina Chortaria <christinach@users.noreply.github.com>
- Loading branch information
1 parent
b055c70
commit 307085f
Showing
2 changed files
with
21 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
Rails.application.config.content_security_policy_report_only = true | ||
# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } | ||
|
||
Rails.application.config.content_security_policy do |policy| | ||
policy.default_src :self, :https | ||
policy.font_src :self, :https, :data | ||
policy.img_src :self, :https, :data | ||
policy.object_src :none | ||
policy.script_src :self, :https | ||
|
||
# TODO: Upgrade MathJax to the latest version, using yarn/npm rather than the CDN | ||
policy.style_src :self, "'unsafe-inline'" | ||
# policy.style_src :self, :https | ||
# policy.report_uri -> { "https://api.honeybadger.io/v1/browser/csp?api_key=#{ENV['HONEYBADGER_API_KEY']}&report_only=true&env=#{Rails.env}&context[user_id]=#{respond_to?(:current_user) ? current_user&.id : nil}" } | ||
end |