1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionview/lib/action_view
Andrew White 31abee0341 Add support for automatic nonce generation for Rails UJS
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.
2018-02-19 15:59:34 +00:00
..
helpers Add support for automatic nonce generation for Rails UJS 2018-02-19 15:59:34 +00:00
locale
renderer fix(streaming_template_renderer): I18n.locale broken in layout. I18n gem stores the current locale in Thread.current[:local] (see: https://github.com/svenfuchs/i18n/blob/master/lib/i18n.rb#L23). StreamingTemplateRenderer is implemented with Fiber which have its own stack of locals and can not access Thread.current.locals(keys, see: https://ruby-doc.org/core-2.2.0/Thread.html#class-Thread-label-Fiber-local+vs.+Thread-local). 2017-11-25 21:32:02 +01:00
tasks Use frozen string literal in actionview/ 2017-07-24 11:53:43 +03:00
template Remove unused MissingRequestError 2017-10-31 08:48:15 +09:00
testing [Action View] require_relative => require 2017-10-21 22:48:28 +09:00
base.rb [Action View] require_relative => require 2017-10-21 22:48:28 +09:00
buffers.rb Use frozen string literal in actionview/ 2017-07-24 11:53:43 +03:00
context.rb Remove :api: tag that has leaked on the doc directly [ci skip] 2017-09-30 18:42:46 +09:00
dependency_tracker.rb [Action View] require_relative => require 2017-10-21 22:48:28 +09:00
digestor.rb Introduced ActiveSupport::Digest that allows to specify hash function implementation 2017-12-12 11:23:54 -08:00
flows.rb Use frozen string literal in actionview/ 2017-07-24 11:53:43 +03:00
gem_version.rb Start Rails 6.0 development!!! 2018-01-30 18:51:17 -05:00
helpers.rb Add support for automatic nonce generation for Rails UJS 2018-02-19 15:59:34 +00:00
layouts.rb [Action View] require_relative => require 2017-10-21 22:48:28 +09:00
log_subscriber.rb [Action View] rubocop -a --only Layout/EmptyLineAfterMagicComment 2017-07-11 13:12:32 +09:00
lookup_context.rb [Action View] require_relative => require 2017-10-21 22:48:28 +09:00
model_naming.rb Use frozen string literal in actionview/ 2017-07-24 11:53:43 +03:00
path_set.rb Use frozen string literal in actionview/ 2017-07-24 11:53:43 +03:00
railtie.rb Make form_with_generates_ids default in Rails 5.2 2017-11-25 11:56:31 -05:00
record_identifier.rb [Action View] require_relative => require 2017-10-21 22:48:28 +09:00
rendering.rb [Action View] require_relative => require 2017-10-21 22:48:28 +09:00
routing_url_for.rb Use frozen string literal in actionview/ 2017-07-24 11:53:43 +03:00
template.rb Fix outdated comment [ci skip] 2017-09-02 17:38:02 +09:00
test_case.rb Fix some typos. 2017-10-10 23:08:03 -04:00
version.rb Use frozen string literal in actionview/ 2017-07-24 11:53:43 +03:00
view_paths.rb Use frozen string literal in actionview/ 2017-07-24 11:53:43 +03:00