aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/content_security_policy_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Add support for prefetch-src directiveyuuji.yaginuma2018-05-031-0/+6
| | | | | | | Specification: https://w3c.github.io/webappsec-csp/#directive-prefetch-src This directive can already be used as an experimental feature in Chrome. Ref: https://bugs.chromium.org/p/chromium/issues/detail?id=801561
* Pass nonce to CSP policy from outsideAndrew White2018-04-181-21/+72
|
* Output only one nonce in CSP header per requestAndrey Novikov2018-04-171-5/+23
|
* Add WebSocket URI support to CSP DSL mappingsStephen Solis2018-04-121-0/+6
|
* Always yield a CSP policy instanceAndrew White2018-03-081-12/+58
| | | | | 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-0/+14
| | | | | | | | 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/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Remove trailing semi-colon from CSPAndrew White2018-02-191-32/+32
| | | | | | | | | Although the spec[1] is defined in such a way that a trailing semi-colon is valid it also doesn't allow a semi-colon by itself to indicate an empty policy. Therefore it's easier (and valid) just to omit it rather than to detect whether the policy is empty or not. [1]: https://www.w3.org/TR/CSP2/#policy-syntax
* Revert "Merge pull request #32045 from eagletmt/skip-csp-header"Andrew White2018-02-191-20/+2
| | | | | | | | | This reverts commit 86f7c269073a3a9e6ddec9b957deaa2716f2627d, reversing changes made to 5ece2e4a4459065b5efd976aebd209bbf0cab89b. If a policy is set then we should generate it even if it's empty. However what is happening is that we're accidentally generating an empty policy when the initializer is commented out by default.
* Skip generating empty CSP header when no policy is configuredKohei Suzuki2018-02-181-2/+20
| | | | | | | | `Rails.application.config.content_security_policy` is configured with no policies by default. In this case, Content-Security-Policy header should not be generated instead of generating the header with no directives. Firefox also warns "Content Security Policy: Couldn't process unknown directive ''".
* Fix CSP copy boolean directives (#31326)Simon Dawson2017-12-051-0/+9
| | | Use Object#deep_dup to safely duplicate policy values
* Add DSL for configuring Content-Security-Policy headerAndrew White2017-11-271-0/+359
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy