Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add CSP #2704

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

add CSP #2704

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@
# See the Securing Rails Applications Guide for more information:
# https://guides.rubyonrails.org/security.html#content-security-policy-header

# Rails.application.configure do
# 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
# policy.style_src :self, :https
# # Specify URI for violation reports
# # policy.report_uri "/csp-violation-report-endpoint"
# end
Rails.application.configure do
config.content_security_policy do |policy|
policy.default_src :self, :https
policy.font_src :self, :https, :data

Check failure on line 10 in config/initializers/content_security_policy.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/ExtraSpacing: Unnecessary spacing detected.
policy.img_src :self, :https, :data

Check failure on line 11 in config/initializers/content_security_policy.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/ExtraSpacing: Unnecessary spacing detected.
policy.connect_src :self, :https, "ws://#{ENV["PUSHER_SOCKET_HOST"]}:#{ENV["PUSHER_WS_PORT"]}" if ENV["PUSHER_SOCKET_HOST"].present?
policy.object_src :none

Check failure on line 13 in config/initializers/content_security_policy.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/ExtraSpacing: Unnecessary spacing detected.
policy.script_src :self, "cdn.ckeditor.com", "www.clarity.ms", :unsafe_inline, :unsafe_eval, :https

Check failure on line 14 in config/initializers/content_security_policy.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/ExtraSpacing: Unnecessary spacing detected.
policy.style_src :self, "cdn.ckeditor.com", :https, :unsafe_inline

Check failure on line 15 in config/initializers/content_security_policy.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/ExtraSpacing: Unnecessary spacing detected.
# Specify URI for violation reports
# policy.report_uri "/csp-violation-report-endpoint"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a violation endpoint so we can monitor them - think we can do this with appsignal not sure

end
#
# # Generate session nonces for permitted importmap and inline scripts
# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
# config.content_security_policy_nonce_directives = %w(script-src)
#
# # Report violations without enforcing the policy.
# # config.content_security_policy_report_only = true

Check failure on line 25 in config/initializers/content_security_policy.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/CommentIndentation: Incorrect indentation detected (column 0 instead of 2).
# end
end
Loading