Commit Graph

480 Commits

Author SHA1 Message Date
Prathamesh Sonpatki
538a459a3b
Squish the deprecation messages across the codebase
Sample example ->

Before:

prathamesh@Prathameshs-MacBook-Pro-2 blog *$ rails server thin
DEPRECATION WARNING: Passing the Rack server name as a regular argument is deprecated
and will be removed in the next Rails version. Please, use the -u
option instead.

After:

prathamesh@Prathameshs-MacBook-Pro-2 squish_app *$ rails server thin
DEPRECATION WARNING: Passing the Rack server name as a regular argument is deprecated and will be removed in the next Rails version. Please, use the -u option instead.
2019-03-11 19:22:37 +05:30
Kasper Timm Hansen
0fc1397784
Merge pull request #35559 from ashishprajapati/ashishprajapati/important_textual_improvements
Added missing guide links in documentation and minor wording fix
2019-03-09 22:54:21 +01:00
ashishprajapati
e3ef12b310 Added missing guide links in README documentation and minor wording fix [ci skip] 2019-03-10 03:17:01 +05:30
Abhay Nikam
027e492b6f Fix links in gemspec and docs from http to https. 2019-03-09 19:42:35 +05:30
Abhay Nikam
476abd403b Updated links from http to https in guides, docs, etc 2019-03-09 16:43:47 +05:30
Matthew Draper
5083f3fd60 Decrypt the ASt test config if available 2019-03-05 15:33:00 +10:30
George Claghorn
7c95c52247
Merge pull request #35412 from abhchand/correctly-load-blob-association
Ensure that the `_blob` association is properly loaded when attaching `::One`
2019-02-26 12:11:50 -05:00
Abhishek Chandrasekhar
32438ed64f [ActiveStorage] Ensure that the _blob association is properly loaded when attaching ::One
Consider a model with `One` and `Many` attachments configured:

    class User < ActiveRecord::Base
      has_one_attached :avatar
      has_many_attached :highlights
    end

=== One Attachment

After attaching `One` attachment (`:avatar`), we can see that the associated
`_blob` record (`:avatar_blob`) still returns as `nil`.

    user.avatar.attach(blob)
    user.avatar_attachment.present?  => true
    user.avatar_blob.present?        => false    # Incorrect!

This is a false negative. It happens because after the attachment and blob
are built:

  1. The record already has its `_blob` association loaded, as `nil`
  2. the `::Attachment` is associated with the record but the `::Blob` only gets
    associated with the `::Attachment`, not the record itself

In reality, the blob does in fact exist. We can verify this as follows:

    user.avatar.attach(blob)
    user.avatar_attachment.blob.present?    => true  # Blob does exist!

The fix in this change is to simply assign the `::Blob` when assigning
the `::Attachment`. After this fix is applied, we correctly observe:

    user.avatar.attach(blob)
    user.avatar_attachment.present?  => true
    user.avatar_blob.present?        => true    # Woohoo!

=== Many Attachments

We don't see this issue with `Many` attachments because the `_blob` association
is already loaded as part of attaching more/newer blobs.

    user.highlights.attach(blob)
    user.highlights_attachments.any?    => true
    user.highlights_blobs.any?          => true
2019-02-26 11:10:38 -05:00
Rafael Mendonça França
5e6e505083
Preparing for 6.0.0.beta2 release 2019-02-25 17:45:04 -05:00
Eugene Kenny
817ffc08bf Add missing require to active_storage.rb
Since b21f50d8ae36d9b50b673579e17bccbe55363b34, requiring active_storage
on its own has failed with the following error:

    activestorage/lib/active_storage.rb:55:in `<module:ActiveStorage>': undefined method `minutes' for 5:Integer (NoMethodError)
2019-02-20 21:07:34 +00:00
Abhay Nikam
d3f9226190 Delegated path_for to primary in the MirrorService 2019-02-14 23:06:42 +05:30
garytaylor
457dfc0621 Allow configuring the Azure Storage service with extra client options 2019-02-04 09:08:55 -05:00
Eileen M. Uchitelle
300c62f75c
Merge pull request #35043 from simoleone/activestorage/s3/content-type
include the content type when uploading to S3
2019-02-01 09:37:08 -05:00
alkesh26
a57f4defa7 ActiveStorage typo fix. 2019-01-31 19:42:32 +05:30
Carlos Ramirez III
f70defa1ba
Fix usage documentation in VideoAnalyzer
The code snippet within the usage documentation comment used the wrong object namespace for the ActiveStorage::Analyzer::VideoAnalyzer
2019-01-28 21:13:11 -08:00
Javan Makhmali
e3d43333db Add CHANGELOG entries for npm package renames [ci skip] 2019-01-28 06:29:26 -05:00
Simo Leone
c5b71c9bae
include the content type when uploading to S3 2019-01-24 17:05:49 +00:00
George Claghorn
c1e949e9e6 Prefer ImageProcessing's resize_to_limit macro over resize_to_fit
Don't upsize images smaller than the specified dimensions.
2019-01-24 11:46:42 -05:00
Gannon McGibbon
2e0ca9284a Revert ensure external redirects are explicitly allowed 2019-01-22 11:40:13 -05:00
Yuichi Takeuchi
ee65ca46e5 Fix ArgumentError: Unsafe redirect 2019-01-21 14:15:34 +09:00
Rafael Mendonça França
5a0230c67f
Preparing for 6.0.0.beta1 release 2019-01-18 15:42:12 -05:00
George Claghorn
9e34df0003
Merge pull request #33419 from bogdanvlviv/update-active_storage
`rake app:update` should update active_storage
2019-01-16 17:04:47 -06:00
Javan Makhmali
385d31d209 Minimize boilerplate setup code for JavaScript libraries 2019-01-16 16:15:43 -05:00
bogdanvlviv
2bad3f46cd
Add foreign key to active_storage_attachments for blob_id via new migration
We need this in order to be able to add this migration for users that
use ActiveStorage during update their apps from Rails 5.2 to Rails 6.0.

Related to #33405

`rake app:update` should update active_storage

`rake app:update` should execute `rake active_storage:update`
if it is used in the app that is being updated.
It will add new active_storage's migrations to users' apps during update Rails.

Context https://github.com/rails/rails/pull/33405#discussion_r204239399

Also, see a related discussion in the Campfire:
https://3.basecamp.com/3076981/buckets/24956/chats/12416418@1236713081
2019-01-16 13:13:23 +00:00
Javan Makhmali
86b489e3d6 Move all npm packages to @rails scope
Fixes #33083
2019-01-10 11:01:57 -05:00
Kasper Timm Hansen
647d7e6167
Revert "Revert "Merge pull request #34387 from yhirano55/rails_info_properties_json""
I reverted the wrong commit. Damn it.

This reverts commit f66a977fc7ae30d2a07124ad91924c4ee638a703.
2019-01-08 22:19:22 +01:00
Kasper Timm Hansen
f66a977fc7
Revert "Merge pull request #34387 from yhirano55/rails_info_properties_json"
We had a discussion on the Core team and we don't want to expose this information
as a JSON endpoint and not by default.

It doesn't make sense to expose this JSON locally and this controller is only
accessible in dev, so the proposed access from a production app seems off.

This reverts commit 8eaffe7e89719ac62ff29c2e4208cfbeb1cd1c38, reversing
changes made to b6e4305c3bca4c673996d0af9db0f4cfbf50215e.
2019-01-08 22:16:58 +01:00
Rafael França
1858614219
Merge pull request #34132 from ConfusedVorlon/enable_fragment_cache_log_in_dev
enable_fragment_cache_logging in dev by default
2019-01-08 14:15:16 -05:00
George Claghorn
ed51351536
Permit sending Active Storage purge and analysis jobs to separate queues 2019-01-01 19:40:59 -05:00
Arun Agrawal
50e3680768 Bump license years for 2019 2018-12-31 10:24:38 +07:00
Luciano Sousa
c329d323fc Permit generating variants of TIFF images 2018-12-30 18:14:49 -05:00
Julik Tarkhanov
e5f4162b61 Make Active Storage blob keys lowercase
Accommodate case-insensitive filesystems and database collations.
2018-12-30 11:56:22 -05:00
bogdanvlviv
2cfbdff63e
Use 6.0 default configs in Active Storage test dummy app 2018-12-30 03:10:31 +02:00
Cameron Bothner
372dda2a29 Don’t include an undefined X-CSRF-Token header
If there is not a `csrf-token` meta tag in the document, the blob record
XHR was including an `X-CSRF-Token` header set to the string
"undefined." Instead of setting it to undefined, it should not be
included in the absence of a meta tag.
2018-12-27 12:44:19 -05:00
Ryuta Kamizono
892e38c78e Enable Style/RedundantBegin cop to avoid newly adding redundant begin block
Currently we sometimes find a redundant begin block in code review
(e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205).

I'd like to enable `Style/RedundantBegin` cop to avoid that, since
rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5
(https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with
that situation than before.
2018-12-21 06:12:42 +09:00
Ryuta Kamizono
8034dde023 Module#{define_method,alias_method,undef_method,remove_method} become public since Ruby 2.5
https://bugs.ruby-lang.org/issues/14133
2018-12-21 01:39:18 +09:00
Kasper Timm Hansen
1b7c3222e8
Require Ruby 2.5 for Rails 6.
Generally followed the pattern for https://github.com/rails/rails/pull/32034

* Removes needless CI configs for 2.4
* Targets 2.5 in rubocop
* Updates existing CHANGELOG entries for fewer merge conflicts
* Removes Hash#slice extension as that's inlined on Ruby 2.5.
* Removes the need for send on define_method in MethodCallAssertions.
2018-12-19 21:47:50 +01:00
Yuji Yaginuma
222757618e
Merge pull request #34585 from marceloperini/marceloperini/33795
add require 'database/setup' in activestorage/test/service/s3_service_test.rb
2018-12-03 08:29:57 +09:00
Richard Macklin
fb0c81d349 Remove obsolete yarn.lock files and check in root yarn.lock file 2018-12-02 10:02:14 -08:00
Marcelo Perini Veloso
ce40e85194
add require 'database/setup' in activestorage/test/service/s3_service_test.rb 2018-12-01 15:47:54 -02:00
yuuji.yaginuma
6ca2f2acb2 metadata is not passed to service
Ref: 604fac6d71/activestorage/app/models/active_storage/blob.rb (L256-L264)

This fixes broken `GCSServiceTest`.
https://travis-ci.org/rails/rails/jobs/461868394#L6624-L6626

Follow up to  #34576.
2018-12-01 09:12:55 +09:00
Yannick Schutz
7bd21e8575
Add a test with extra keys to active_storage Service#upload 2018-11-30 15:54:38 +01:00
Hiroki Sanpei
4deb88ca26 Fix ArgumentError when uploading to amazon s3 2018-11-28 17:06:29 +09:00
yuuji.yaginuma
ac721c8552 Fix "warning: ambiguous first argument; put parentheses or a space even after `/' operator" 2018-11-28 11:29:03 +09:00
yuuji.yaginuma
b7ec129de5 text is treated as attachment 2018-11-28 10:35:57 +09:00
yuuji.yaginuma
c2ef8bbf52 Fix broken ActiveStorage::BlobTest
`ActiveStorage::Filename#parameters` was removed by #33829.
2018-11-28 10:16:07 +09:00
yuuji.yaginuma
7e7a60bd3f Remove duplicated test
Since 06ab7b27ea1c1ab357085439abacdb464f6742bf,
`GCSServiceTest#test_signed_URL_response_headers` is broken.
https://travis-ci.org/rails/rails/jobs/460454477#L7084-L7087

This seems to be due to lack of `content_type` at upload.
This is solved by specifying `conten_type`.

However, since the same content is also tested with `test_upload_with_content_type`,
it will be duplicated content, so I think that can remove `test_signed_URL_response_headers`.
2018-11-28 10:01:03 +09:00
Adrian Hawrylak
2c279aa980 Fix minor Active Storage docs typo [ci skip] 2018-11-28 00:27:58 +01:00
Rosa Gutierrez
06ab7b27ea Prevent content type and disposition bypass in storage service URLs
* Force content-type to binary on service urls for relevant content types

We have a list of content types that must be forcibly served as binary,
but in practice this only means to serve them as attachment always. We
should also set the Content-Type to the configured binary type.

As a bonus: add text/cache-manifest to the list of content types to be
served as binary by default.

* Store content-disposition and content-type in GCS

Forcing these in the service_url when serving the file works fine for S3
and Azure, since these services include params in the signature.
However, GCS specifically excludes response-content-disposition and
response-content-type from the signature, which means an attacker can
modify these and have files that should be served as text/plain attachments
served as inline HTML for example. This makes our attempt to force
specific files to be served as binary and as attachment can be easily
bypassed.

The only way this can be forced in GCS is by storing
content-disposition and content-type in the object metadata.

* Update GCS object metadata after identifying blob

In some cases we create the blob and upload the data before identifying
the content-type, which means we can't store that in GCS right when
uploading. In these, after creating the attachment, we enqueue a job to
identify the blob, and set the content-type.

In other cases, files are uploaded to the storage service via direct
upload link. We create the blob before the direct upload, which happens
independently from the blob creation itself. We then mark the blob as
identified, but we have already the content-type we need without having
put it in the service.

In these two cases, then, we need to update the metadata in the GCS
service.

* Include content-type and disposition in the verified key for disk service

This prevents an attacker from modifying these params in the service
signed URL, which is particularly important when we want to force them
to have specific values for security reasons.

* Allow only a list of specific content types to be served inline

This is different from the content types that must be served as binary
in the sense that any content type not in this list will be always
served as attachment but with its original content type. Only types in
this list are allowed to be served either inline or as attachment.

Apart from forcing this in the service URL, for GCS we need to store the
disposition in the metadata.

Fix CVE-2018-16477.
2018-11-27 15:36:27 -05:00
Tasos Maschalidis
d6fcc419fe ASt direct uploads: account for <button type="submit"> elements 2018-11-24 14:54:05 -05:00