aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/http
Commit message (Collapse)AuthorAgeFilesLines
* Add support for automatic nonce generation for Rails UJSAndrew White2018-02-191-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+1
| | | | | | | | | 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-10/+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/+10
| | | | | | | | `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 ''".
* Partly revert 1e526788e6b1d3f42f4d8fdca20e588d42838c80bogdanvlviv2018-02-171-1/+4
| | | | | | Some attr_readers should be `protected` instead of `private` See https://travis-ci.org/rails/rails/builds/342800276
* Rails 6 requires Ruby 2.3+Jeremy Daer2018-02-171-6/+1
|
* Enable autocorrect for `Lint/EndAlignment` copKoichi ITO2018-01-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ### Summary This PR changes .rubocop.yml. Regarding the code using `if ... else ... end`, I think the coding style that Rails expects is as follows. ```ruby var = if cond a else b end ``` However, the current .rubocop.yml setting does not offense for the following code. ```ruby var = if cond a else b end ``` I think that the above code expects offense to be warned. Moreover, the layout by autocorrect is unnatural. ```ruby var = if cond a else b end ``` This PR adds a setting to .rubocop.yml to make an offense warning and autocorrect as expected by the coding style. And this change also fixes `case ... when ... end` together. Also this PR itself is an example that arranges the layout using `rubocop -a`. ### Other Information Autocorrect of `Lint/EndAlignment` cop is `false` by default. https://github.com/bbatsov/rubocop/blob/v0.51.0/config/default.yml#L1443 This PR changes this value to `true`. Also this PR has changed it together as it is necessary to enable `Layout/ElseAlignment` cop to make this behavior.
* Merge pull request #31289 from witlessbird/fips-compatibilityEileen M. Uchitelle2017-12-141-1/+1
|\ | | | | Initial support for running Rails on FIPS-certified systems
| * Introduced `ActiveSupport::Digest` that allows to specify hash function ↵Dmitri Dolguikh2017-12-121-1/+1
| | | | | | | | | | | | | | | | implementation and defaults to `Digest::MD5`. Replaced calls to `::Digest::MD5.hexdigest` with calls to `ActiveSupport::Digest.hexdigest`.
* | Add missing requireyuuji.yaginuma2017-12-051-0/+2
| | | | | | | | | | | | | | Follow up of 3c442b6df91e291ebbf17f37444414bf5f10fbe6 Without this require, it will fail when run CSP test alone. Ref: https://travis-ci.org/rails/rails/jobs/311715758#L2976
* | Fix CSP copy boolean directives (#31326)Simon Dawson2017-12-051-5/+1
|/ | | Use Object#deep_dup to safely duplicate policy values
* Fix typo in mime type registeringGuillermo Iguaran2017-11-291-1/+1
|
* Restore mpeg mime type, delete less common mime typesGuillermo Iguaran2017-11-291-9/+4
| | | | See discussion in #31251
* Register "audio/mp4" mime type with :m4a symbolGuillermo Iguaran2017-11-291-1/+1
|
* Register most popular audio/video/font mime types supported by modern browsersGuillermo Iguaran2017-11-281-1/+19
|
* Add DSL for configuring Content-Security-Policy headerAndrew White2017-11-272-0/+234
| | | | https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
* Merge pull request #31078 from aeroastro/feature/fix-typoRafael França2017-11-091-2/+2
|\ | | | | Fix typoes on ActionDispatch::HTTP::FilterParameters
| * Fix typo on ActionDispatc::HTTP::FilterParametersTakumasa Ochi2017-11-071-2/+2
| |
* | Edited comment from request.rbhaneru2017-11-031-1/+1
| |
* | Remove mention of X-Post-Data-Format header [ci skip]Eugene Kenny2017-10-281-3/+0
| | | | | | | | | | Support for this header was removed when `actionpack-xml_parser` was extracted, and has since been dropped from the gem.
* | Remove deprecated `ActionController::ParamsParser::ParseError`Rafael Mendonça França2017-10-231-5/+0
| |
* | [Action Pack] require => require_relativeAkira Matsuda2017-10-214-11/+11
| | | | | | | | | | This basically reverts e9fca7668b9eba82bcc832cb0061459703368397, d08da958b9ae17d4bbe4c9d7db497ece2450db5f, d1fe1dcf8ab1c0210a37c2a78c1ee52cf199a66d, and 68eaf7b4d5f2bb56d939f71c5ece2d61cf6680a3
* | Implement H2 Early Hints for Railseileencodes2017-10-041-0/+17
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When puma/puma#1403 is merged Puma will support the Early Hints status code for sending assets before a request has finished. While the Early Hints spec is still in draft, this PR prepares Rails to allowing this status code. If the proxy server supports Early Hints, it will send H2 pushes to the client. This PR adds a method for setting Early Hints Link headers via Rails, and also automatically sends Early Hints if supported from the `stylesheet_link_tag` and the `javascript_include_tag`. Once puma supports Early Hints the `--early-hints` argument can be passed to the server to enable this or set in the puma config with `early_hints(true)`. Note that for Early Hints to work in the browser the requirements are 1) a proxy that can handle H2, and 2) HTTPS. To start the server with Early Hints enabled pass `--early-hints` to `rails s`. This has been verified to work with h2o, Puma, and Rails with Chrome. The commit adds a new option to the rails server to enable early hints for Puma. Early Hints spec: https://tools.ietf.org/html/draft-ietf-httpbis-early-hints-04 [Eileen M. Uchitelle, Aaron Patterson]
* Merge pull request #30367 from ptoomey3/consistent-cache-control-headersAaron Patterson2017-09-052-8/+13
|\ | | | | Normalize/process Cache-Control headers consistently
| * Don't touch an unused headerPatrick Toomey2017-08-231-1/+0
| | | | | | | | | | | | The prior logic explictly set `Cache-Control` to `nil`. But, we would only reach that logic if the header was not set to begin with. So, rather than give it any value at all, just leave it alone.
| * Decouple the merge/normalization and conditional cache control logicPatrick Toomey2017-08-232-5/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The prior logic was trying to do too many things at once. For all responses, we want to perform two distinct steps: * Merge/normalize the `Cache-Control` values found in HTTP headers and those found in the `@cache_control` hash. * Conditionally set a default `Cache-Control` header value when we have an ETag This change separates these concerns since the merge/normalize step should occur for all responses, but the second should only occur when we have already set an ETag/last modified value. Normally ETag middleware will set a default `Cache-Control`, but only if an existing ETag is not already set. So, in the cases where an ETag is set, we need to set the default `Cache-Control` value ourselves.
| * This constant is no longer usedPatrick Toomey2017-08-221-1/+0
| |
| * Let middleware handle default cache behaviorPatrick Toomey2017-08-221-1/+2
| |
| * Normalize/process Cach-Control headers consistentlyPatrick Toomey2017-08-221-3/+1
| | | | | | | | | | | | | | | | | | | | In the existing logic, the `Cache-Control` header may or may not get normalized by additional logic depending on whether `response.cache_conrol` has been modified. This leads to inconsistent behavior, since sometimes `Cache-Control` can contain whatever a user sets and sometimes it gets normalized, based on the logic inside of `set_conditional_cache_control!`. It seems like this normalization process should happen regardless to ensure consistent behavior.
* | Use tt in doc for ActionPack [ci skip]Yoshiyuki Hirano2017-08-261-1/+1
|/
* Update links to use https link instead of http [ci skip]Yoshiyuki Hirano2017-08-222-10/+10
|
* Merge pull request #29777 from yui-knk/set_content_typeMatthew Draper2017-08-021-3/+2
|\ | | | | Refactoring `Response#charset=`
| * Brush up local variables assignmentyui-knk2017-07-131-3/+2
| |
| * Use `#set_content_type` instead of `#set_header`yui-knk2017-07-131-1/+1
| | | | | | | | | | | | By this commit, `#set_header` is called only via `#set_content_type`. This commit makes the role of `#charset=` more clear.
* | Path parameters should default to UTF8eileencodes2017-08-012-9/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit changes the behavior such the path_params now default to UTF8 just like regular parameters. This also changes the behavior such that if a path parameter contains invalid UTF8 it returns a 400 bad request. Previously the behavior was to encode the path params as binary but that's not the same as query params. So this commit makes path params behave the same as query params. It's important to test with a path that's encoded as binary because that's how paths are encoded from the socket. The test that was altered was changed to make the behavior for bad encoding the same as query params. We want to treat path params the same as query params. The params in the test are invalid UTF8 so they should return a bad request. Fixes #29669 *Eileen M. Uchitelle, Aaron Patterson, & Tsukuru Tanimichi*
* | Use frozen string literal in actionpack/Kir Shatrov2017-07-2912-0/+24
| |
* | Make actionpack frozen string friendlyKir Shatrov2017-07-241-1/+1
| |
* | `Response#charset=` uses `default_charset` when `nil` is passedyui-knk2017-07-131-1/+1
|/
* [Action Pack] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-112-0/+2
|
* Prepare AP and AR to be frozen string friendlyKir Shatrov2017-07-062-1/+3
|
* Merge branch 'master' into require_relative_2017Xavier Noria2017-07-021-1/+1
|\
| * Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-0214-14/+0
| | | | | | | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
| * Merge pull request #29540 from kirs/rubocop-frozen-stringMatthew Draper2017-07-0214-0/+14
| |\ | | | | | | | | | Enforce frozen string in Rubocop
| | * Enforce frozen string in RubocopKir Shatrov2017-07-0114-0/+14
| | |
| * | Merge pull request #29506 from pat/frozen-string-literalsMatthew Draper2017-07-021-1/+1
| |\ \ | | |/ | |/| | | | Make ActiveSupport frozen-string-literal friendly.
| | * Make ActionMailer frozen string literal friendly.Pat Allan2017-06-201-1/+1
| | |
* | | [Action Dispatch] require => require_relativeAkira Matsuda2017-07-014-11/+11
|/ /
* | Merge branch 'master' into bug/filtered_parameters_classLeonel Galán2017-06-163-6/+4
|\|
| * Use mattr_accessor default: option throughout the projectGenadi Samokovarov2017-06-033-6/+4
| |
* | Merge branch 'master' into bug/filtered_parameters_classLeonel Galán2017-05-173-7/+17
|\|