aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #35412 from abhchand/correctly-load-blob-associationGeorge Claghorn2019-02-263-0/+7
|\ | | | | Ensure that the `_blob` association is properly loaded when attaching `::One`
| * [ActiveStorage] Ensure that the `_blob` association is properly loaded when ↵Abhishek Chandrasekhar2019-02-263-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Preparing for 6.0.0.beta2 releaseRafael Mendonça França2019-02-253-2/+7
|/
* Add missing require to active_storage.rbEugene Kenny2019-02-201-0/+1
| | | | | | | 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)
* Delegated path_for to primary in the MirrorServiceAbhay Nikam2019-02-142-1/+5
|
* Allow configuring the Azure Storage service with extra client optionsgarytaylor2019-02-041-2/+2
|
* Merge pull request #35043 from simoleone/activestorage/s3/content-typeEileen M. Uchitelle2019-02-012-2/+20
|\ | | | | include the content type when uploading to S3
| * include the content type when uploading to S3Simo Leone2019-01-242-2/+20
| |
* | ActiveStorage typo fix.alkesh262019-01-311-1/+1
| |
* | Fix usage documentation in VideoAnalyzerCarlos Ramirez III2019-01-281-1/+1
| | | | | | The code snippet within the usage documentation comment used the wrong object namespace for the ActiveStorage::Analyzer::VideoAnalyzer
* | Add CHANGELOG entries for npm package renames [ci skip]Javan Makhmali2019-01-281-0/+6
| |
* | Prefer ImageProcessing's resize_to_limit macro over resize_to_fitGeorge Claghorn2019-01-245-12/+12
|/ | | | Don't upsize images smaller than the specified dimensions.
* Revert ensure external redirects are explicitly allowedGannon McGibbon2019-01-222-2/+2
|
* Fix ArgumentError: Unsafe redirectYuichi Takeuchi2019-01-214-2/+57
|
* Preparing for 6.0.0.beta1 releaseRafael Mendonça França2019-01-183-2/+4
|
* Merge pull request #33419 from bogdanvlviv/update-active_storageGeorge Claghorn2019-01-162-0/+14
|\ | | | | `rake app:update` should update active_storage
| * Add foreign key to active_storage_attachments for `blob_id` via new migrationbogdanvlviv2019-01-162-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Minimize boilerplate setup code for JavaScript librariesJavan Makhmali2019-01-161-2/+1
|/
* Move all npm packages to @rails scopeJavan Makhmali2019-01-102-2/+2
| | | | Fixes #33083
* Revert "Revert "Merge pull request #34387 from ↵Kasper Timm Hansen2019-01-081-0/+3
| | | | | | | | yhirano55/rails_info_properties_json"" I reverted the wrong commit. Damn it. This reverts commit f66a977fc7ae30d2a07124ad91924c4ee638a703.
* Revert "Merge pull request #34387 from yhirano55/rails_info_properties_json"Kasper Timm Hansen2019-01-081-3/+0
| | | | | | | | | | | 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.
* Merge pull request #34132 from ConfusedVorlon/enable_fragment_cache_log_in_devRafael França2019-01-081-0/+1
|\ | | | | enable_fragment_cache_logging in dev by default
| * enable_fragment_cache_loggingRob Jonson2018-10-091-0/+1
| | | | | | | | | | | | | | | | fragment caching was refactored in (I think 5.2) and by default doesn't log cache info this is confusing in development where rails dev:cache now turns on caching, but doesn't show any different logging output better to enable debugging by default for dev - and let people turn it off if preferred
* | Permit sending Active Storage purge and analysis jobs to separate queuesGeorge Claghorn2019-01-016-3/+31
| |
* | Bump license years for 2019Arun Agrawal2018-12-312-2/+2
| |
* | Permit generating variants of TIFF imagesLuciano Sousa2018-12-304-0/+17
| |
* | Make Active Storage blob keys lowercaseJulik Tarkhanov2018-12-304-4/+24
| | | | | | Accommodate case-insensitive filesystems and database collations.
* | Use 6.0 default configs in Active Storage test dummy appbogdanvlviv2018-12-301-1/+1
| |
* | Don’t include an undefined X-CSRF-Token headerCameron Bothner2018-12-273-2/+15
| | | | | | | | | | | | | | 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.
* | Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin blockRyuta Kamizono2018-12-2111-280/+224
| | | | | | | | | | | | | | | | | | | | 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.
* | Module#{define_method,alias_method,undef_method,remove_method} become public ↵Ryuta Kamizono2018-12-212-2/+2
| | | | | | | | | | | | since Ruby 2.5 https://bugs.ruby-lang.org/issues/14133
* | Require Ruby 2.5 for Rails 6.Kasper Timm Hansen2018-12-192-3/+3
| | | | | | | | | | | | | | | | | | | | 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.
* | Merge pull request #34585 from marceloperini/marceloperini/33795Yuji Yaginuma2018-12-031-0/+1
|\ \ | | | | | | add require 'database/setup' in activestorage/test/service/s3_service_test.rb
| * | add require 'database/setup' in activestorage/test/service/s3_service_test.rbMarcelo Perini Veloso2018-12-011-0/+1
| | |
* | | Remove obsolete yarn.lock files and check in root yarn.lock fileRichard Macklin2018-12-021-1923/+0
|/ /
* | `metadata` is not passed to serviceyuuji.yaginuma2018-12-011-2/+1
| | | | | | | | | | | | | | | | | | Ref: https://github.com/rails/rails/blob/604fac6d7191fca102380b1a5f5eb9c619fb407f/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.
* | Add a test with extra keys to active_storage Service#uploadYannick Schutz2018-11-301-0/+19
| |
* | Fix `ArgumentError` when uploading to amazon s3Hiroki Sanpei2018-11-282-1/+5
| |
* | Fix "warning: ambiguous first argument; put parentheses or a space even ↵yuuji.yaginuma2018-11-281-3/+3
| | | | | | | | after `/' operator"
* | text is treated as `attachment`yuuji.yaginuma2018-11-281-2/+2
| |
* | Fix broken `ActiveStorage::BlobTest`yuuji.yaginuma2018-11-281-1/+1
| | | | | | | | `ActiveStorage::Filename#parameters` was removed by #33829.
* | Remove duplicated testyuuji.yaginuma2018-11-281-14/+0
| | | | | | | | | | | | | | | | | | | | | | | | 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`.
* | Fix minor Active Storage docs typo [ci skip]Adrian Hawrylak2018-11-281-1/+1
| |
* | Prevent content type and disposition bypass in storage service URLsRosa Gutierrez2018-11-2714-38/+172
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* | ASt direct uploads: account for <button type="submit"> elementsTasos Maschalidis2018-11-242-4/+4
| |
* | Add progressive JPG to default variable content typesMaurice Kühlborn2018-11-212-0/+5
| |
* | Amend CVE note and security guide section wordingsGannon McGibbon2018-11-061-3/+3
| | | | | | | | | | | | | | Reword first sentence of dep management and CVE section of security guide. Also, reword and move gemspec notes above deps. [ci skip]
* | Add CVE note to security guide and gemspecsGannon McGibbon2018-11-061-0/+3
| | | | | | | | [ci skip]
* | update activestorage attachment model documentation reflect recent behavior ↵Kyle Keesling2018-10-241-3/+2
|/ | | | changes
* Point to requiring the ASt engine in the installation instructions [ci skip]Donnie Propst2018-10-081-0/+2
|