aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/lib
Commit message (Collapse)AuthorAgeFilesLines
* Add foreign key to active_storage_attachments for `blob_id` via new migrationbogdanvlviv2019-01-161-0/+7
| | | | | | | | | | | | | | | | | | 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
* Permit sending Active Storage purge and analysis jobs to separate queuesGeorge Claghorn2019-01-012-2/+16
|
* Bump license years for 2019Arun Agrawal2018-12-311-1/+1
|
* Permit generating variants of TIFF imagesLuciano Sousa2018-12-301-0/+2
|
* Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin blockRyuta Kamizono2018-12-214-68/+44
| | | | | | | | | | 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.
* Fix `ArgumentError` when uploading to amazon s3Hiroki Sanpei2018-11-281-1/+1
|
* Prevent content type and disposition bypass in storage service URLsRosa Gutierrez2018-11-277-22/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Add progressive JPG to default variable content typesMaurice Kühlborn2018-11-211-0/+1
|
* Merge pull request #33829 from mtsmfm/encode-filenameKasper Timm Hansen2018-09-231-1/+4
|\ | | | | Encode Content-Disposition filenames on send_data and send_file
| * Encode Content-Disposition filenames on send_data and send_fileFumiaki MATSUSHIMA2018-09-131-1/+4
| |
* | Configure Active Storage route prefixChris Bisnett2018-09-142-0/+2
|/ | | | | | | | | | | Applications can configure the route prefix prepended to the Active Storage routes. By default this maintains the previous prefix `/rails/active_storage` but supports custom prefixes. Before this change the route for serving blobs is fixed to `/rails/active_storage/blobs/:signed_id/*filename`. After this change it's possible to configure the route to something like `/files/blobs/:signed_id/*filename`.
* Handle only specifically relevant Azure HTTPErrorsCameron Bothner2018-08-231-5/+7
| | | | | | | | | The Azure gem uses `Azure::Core::Http::HTTPError` for everything: checksum mismatch, missing object, network unavailable, and many more. (https://www.rubydoc.info/github/yaxia/azure-storage-ruby/Azure/Core/Http/HTTPError). Rescuing that class obscures all sorts of configuration errors. We should check the type of error in those rescue blocks, and reraise when needed.
* Revert "Merge pull request #33667 from ↵George Claghorn2018-08-231-13/+7
| | | | | | | cbothner/azure-service-swallowing-all-errors" This reverts commit b204d167c5cfebd59f771d406178e371811ac43a, reversing changes made to de6a200f82a3de399fa685d583503bc88dbc5e9f.
* Handle only specifically relevant Azure HTTPErrorsCameron Bothner2018-08-231-7/+13
| | | | | | | | | The Azure gem uses `Azure::Core::Http::HTTPError` for everything: checksum mismatch, missing object, network unavailable, and many more. (https://www.rubydoc.info/github/yaxia/azure-storage-ruby/Azure/Core/Http/HTTPError). Rescuing that class obscures all sorts of configuration errors. We should check the type of error in those rescue blocks, and reraise when needed.
* Translate service-specific missing object exceptions into a generic oneCameron Bothner2018-08-215-18/+72
| | | | | | | | | `ActiveStorage::Blob#download` and `ActiveStorage::Blob#open` raise `ActiveStorage::FileNotFoundError` when the corresponding file is missing from the storage service. Services translate service-specific missing object exceptions (e.g. `Google::Cloud::NotFoundError` for the GCS service and `Errno::ENOENT` for the disk service) into `ActiveStorage::FileNotFoundError`.
* Document all Active Storage error classes [ci skip]George Claghorn2018-08-101-0/+8
|
* Add a generic base class for Active Storage exceptionsGeorge Claghorn2018-08-101-4/+7
| | | | | | Closes #33292. [Andrei Makarov & George Claghorn]
* Extract transformersGeorge Claghorn2018-08-104-0/+127
|
* Camelize instead of classifyingGeorge Claghorn2018-08-061-1/+1
| | | | | | | Avoid mangling service names that end in S: "GCS".classify # => "GC" "GCS".camelize # => "GCS"
* Improve ActiveStorage service adapter error handlingJoel Taylor2018-08-061-1/+3
|
* Fix uploading Tempfiles to Azure StorageGeorge Claghorn2018-08-031-1/+1
| | | | Closes #32530.
* Remove another unused requireGeorge Claghorn2018-08-021-2/+0
|
* Remove unused requireGeorge Claghorn2018-08-011-2/+0
|
* Ignore concurrently-deleted files when deleting by prefix from GCSGeorge Claghorn2018-07-301-1/+7
|
* Update ActiveStorage::Previewer docsGeorge Claghorn2018-07-291-2/+2
| | | | PDFPreviewer became MuPDFPreviewer in 0b717c2. Previewers are simple enough that we can just provide a single example.
* Log streaming downloadsGeorge Claghorn2018-07-261-0/+2
|
* Remove unused attributeGeorge Claghorn2018-07-212-5/+5
|
* Fix replacing many attachments via assign and attachGeorge Claghorn2018-07-171-0/+4
|
* Fix that successive ActiveStorage::Attached::Many#attach calls would ↵George Claghorn2018-07-161-1/+11
| | | | overwrite previous attachments
* Support HTTP Range downloads from diskGeorge Claghorn2018-07-151-4/+4
| | | | Closes #32193.
* Clear attachment changes on reloadGeorge Claghorn2018-07-131-0/+4
|
* Implement ActiveStorage::Attached::{One,Many}#attach in terms of changesGeorge Claghorn2018-07-135-38/+30
|
* Fix that detaching could purgeGeorge Claghorn2018-07-132-2/+2
|
* Fix analyzing new blobs from uploaded files on attachGeorge Claghorn2018-07-131-18/+4
|
* Raise an ArgumentError instead of a RuntimeErrorGeorge Claghorn2018-07-081-1/+1
|
* Store newly-uploaded files on save rather than assignmentGeorge Claghorn2018-07-0712-138/+326
|
* Fix that models can clobber each others' attachment reflectionsGeorge Claghorn2018-07-071-2/+2
| | | | | | | | | | | | | | Consider the following model definitions: class User < ApplicationRecord has_one_attached :avatar end class Group < ApplicationRecord has_one_attached :avatar end If you attempt to reflect on the User model's avatar attachment via User.reflect_on_attachment, you could receive a reflection for the Group model's avatar attachment. Fix this by ensuring that each model class uses its own Hash object to track attachment reflections.
* Remove vestigial require on ActiveStorage GCSServiceBibek Shrestha2018-07-041-1/+0
| | | | | | | | | | | | The file `filename.rb` as mentioned in `require "active_storage/filename"` belongs to the `app` folder while GCSService belongs to the lib folder. Looking at the git blame, it was added in commit https://github.com/rails/rails/commit/ccac681122db9747fec9512076772bca345e24b9#diff-bda6a610ef1575b2c8458c96b7f12578 where ActiveStorage::Filename was actually used. But it is no longer required on master and therefore can be removed. This allows anyone to use GCSService directly without enabling ActiveStorage engine.
* Tweak Previewer::PopplerPDFPreviewer#pdftoppm_exists?utilum2018-06-291-1/+1
| | | | Does not warn `instance variable @pdftoppm_exists not initialized`.
* Update service.rbishanray2018-06-241-1/+1
|
* Permit configuring the default service URL expiryGeorge Claghorn2018-06-213-2/+2
|
* Update ffmpeg -> FFmpeg, mutools|mupdf -> muPDFutilum2018-06-082-3/+3
| | | | [ci skip]
* Exclude upload time from instrumented preview timeGeorge Claghorn2018-06-031-5/+10
|
* Merge pull request #33018 from kddeisz/defined-attachmentsRafael França2018-06-013-0/+85
|\ | | | | ActiveStorage reflection
| * Ensure reflection_class_for is privateKevin Deisz2018-05-311-12/+13
| |
| * Move ActiveStorage reflection logic entirely into ActiveStorageKevin Deisz2018-05-312-0/+72
| |
| * Reflection for attachmentsKevin Deisz2018-05-301-0/+12
| | | | | | | | Add the ability to reflect on the attachments that have been defined using ActiveRecord::Reflection.
* | Include blob ID in tempfile name for debugging convenienceGeorge Claghorn2018-05-301-5/+1
|/
* Fix referenceGeorge Claghorn2018-05-281-1/+1
|
* Verify integrity after chunked downloadGeorge Claghorn2018-05-283-2/+11
|