aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal/content_security_policy.rb
Commit message (Collapse)AuthorAgeFilesLines
* Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-131-1/+0
| | | | | | | | | | | We sometimes say "✂️ newline after `private`" in a code review (e.g. https://github.com/rails/rails/pull/18546#discussion_r23188776, https://github.com/rails/rails/pull/34832#discussion_r244847195). Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style `EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059). That cop and enforced style will reduce the our code review cost.
* Always yield a CSP policy instanceAndrew White2018-03-081-1/+5
| | | | | If the app has the CSP disabled globally allow a controller action to enable the policy for that request.
* Add the ability to disable the global CSP in a controllerAndrew White2018-03-081-1/+5
| | | | | | | | e.g: class LegacyPagesController < ApplicationController content_security_policy false, only: :index end
* Add support for automatic nonce generation for Rails UJSAndrew White2018-02-191-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | Because the UJS library creates a script tag to process responses it normally requires the script-src attribute of the content security policy to include 'unsafe-inline'. To work around this we generate a per-request nonce value that is embedded in a meta tag in a similar fashion to how CSRF protection embeds its token in a meta tag. The UJS library can then read the nonce value and set it on the dynamically generated script tag to enable it to execute without needing 'unsafe-inline' enabled. Nonce generation isn't 100% safe - if your script tag is including user generated content in someway then it may be possible to exploit an XSS vulnerability which can take advantage of the nonce. It is however an improvement on a blanket permission for inline scripts. It is also possible to use the nonce within your own script tags by using `nonce: true` to set the nonce value on the tag, e.g <%= javascript_tag nonce: true do %> alert('Hello, World!'); <% end %> Fixes #31689.
* Add DSL for configuring Content-Security-Policy headerAndrew White2017-11-271-0/+26
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy