aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/test/models/blob_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Revert "MethodCallAssertions is a regular player of the team ↵Rafael Mendonça França2019-08-021-0/+3
| | | | | | ActiveSupport::TestCase now" This reverts commit 98d0f7ebd34b858f12a12dcf37ae54fdbb5cab64.
* MethodCallAssertions is a regular player of the team ActiveSupport::TestCase nowAkira Matsuda2019-08-021-3/+0
| | | | It's used everywhere, clean and mature enough
* url -> URL where apt except inside actionpack/Sharang Dashputre2019-04-011-5/+5
|
* Add ActiveStorage::Service#openGeorge Claghorn2019-03-281-5/+3
|
* Make Active Storage blob keys lowercaseJulik Tarkhanov2018-12-301-0/+4
| | | Accommodate case-insensitive filesystems and database collations.
* Fix broken `ActiveStorage::BlobTest`yuuji.yaginuma2018-11-281-1/+1
| | | | `ActiveStorage::Filename#parameters` was removed by #33829.
* Prevent content type and disposition bypass in storage service URLsRosa Gutierrez2018-11-271-7/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Encode Content-Disposition filenames on send_data and send_fileFumiaki MATSUSHIMA2018-09-131-1/+1
|
* Ignore ActiveRecord::InvalidForeignKey in ActiveStorage::Blob#purgeJasper Martin2018-07-261-2/+2
| | | Do nothing instead of raising an error when it’s called on an attached blob.
* Test that ActiveStorage::Blob#purge fails when attachments existGeorge Claghorn2018-07-201-0/+8
|
* Store newly-uploaded files on save rather than assignmentGeorge Claghorn2018-07-071-14/+8
|
* Permit configuring the default service URL expiryGeorge Claghorn2018-06-211-3/+3
|
* Remove errant debugger callGeorge Claghorn2018-05-301-1/+0
|
* Include blob ID in tempfile name for debugging convenienceGeorge Claghorn2018-05-301-5/+9
|
* Verify integrity after chunked downloadGeorge Claghorn2018-05-281-1/+11
|
* Permit opening a blob in a custom tempdirGeorge Claghorn2018-05-171-0/+12
|
* Add ActiveStorage::Blob#openGeorge Claghorn2018-05-161-0/+9
| | | | [David Robertson & George Claghorn]
* Add option to ActiveStorage::Blob to set extract_content_type_from_ioRyan Davidson2018-05-081-0/+10
| | | | | | | This adds a boolean argument called identify to ActiveStorage::Blob methods #create_after_upload, #build_after_upload and #upload. It allows a user to bypass the automatic content_type inference from the io.
* Stream blobs from disk in 5 MB chunksGeorge Claghorn2018-04-291-3/+3
| | | | Match other services, which all use a 5 MB chunk size.
* Use a current model to provide the host for service urlsAndrew White2018-04-061-1/+1
| | | | | | | Trying to pass the current request down to the service so that it can create full urls instead of paths makes the API messy so use a model based on ActiveSupport::CurrentAttributes to provide the current host to services that need it (primarily the disk service).
* Generate root-relative paths in Active Storage disk service URL methodsGeorge Claghorn2018-03-051-1/+1
| | | | Fixes #32129.
* Add ActiveStorage::Blob.unattached scopefatkodima2018-02-121-0/+17
|
* Fix `blob.service_url` for supports string or nil `:filename` option.Jason Lee2018-02-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | - Make sure `blob.service_url` present a `ActiveStorage::Filename` type to `serivce.url`. - Add `ActiveStorage::Filename.wrap` method. before: ```rb blob.service_url(filename: ActiveStorage::Filename.new("new.txt")) blob.service_url(filename: "new.txt") => NoMethodError: undefined method `parameters' for "new.txt":String params = {} blob.service_url(filename: params[:filename]) => NoMethodError: undefined method `parameters' for nil:NilClass ``` after: ```rb blob.service_url(filename: "new.txt") blob.service_url(filename: nil) ```
* Allow `ActiveStorage::Blob#service_url` to pass addition options to ↵Jason Lee2018-02-011-0/+20
| | | | | | | | | | | | | | | | | | | | | | | `service.url`. Because there have some service needs more parameters for file URL: https://www.alibabacloud.com/help/doc-detail/44687.htm ```rb class AliyunService < Service def url(key, options = {}) image_process = options[:oss_process] || "image/resize,w_800" "http://image-demo.oss-cn-hangzhou.aliyuncs.com/example.jpg?x-oss-process=#{image_process}" end end ``` Use case: ```erb <%= image_tag @user.avatar.service_url(oss_process: "image/resize,m_fill,h_100,w_100" %> ```
* Add a test for ActiveStorage::Blob#image? and ActiveStorage::Blob#video?Shuhei Kitagawa2018-01-291-0/+12
|
* Use assert_predicate and assert_not_predicateDaniel Colson2018-01-251-2/+2
|
* Extract content types from blob dataGeorge Claghorn2018-01-151-1/+11
|
* Allow overriding filename in `Blob#service_url`Rosa Gutierrez2018-01-081-3/+14
| | | | | | | This is useful when we have several representations for the same underlying file, each one with a different name, and we need to provide a custom download URL based on that name and not that of the underlying file.
* Force content disposition to attachment for specific content typesRosa Gutierrez2018-01-051-0/+9
| | | | | | | | | | | | | | In this way we avoid HTML, XML, SVG and other files that can be rendered by the browser to be served inline by default. Depending on the origin from where these files are served, this might lead to XSS vulnerabilities, and in the best case, to more realistic phishing attacks and open redirects. We force it rather than falling back to it when other disposition is not provided. Otherwise it would be possible for someone to force inline just by passing `disposition=inline` in the URL. The list of content types to be served as attachments is configurable.
* Purge variants with their blobsGeorge Claghorn2017-12-021-1/+9
|
* Encode Content-Disposition filenames according to RFC 2231George Claghorn2017-08-211-1/+1
| | | | Closes #30134.
* DRYGeorge Claghorn2017-08-201-1/+1
|
* Add missing test for Blob#purgeJon Moss2017-08-171-0/+7
|
* Use frozen string literal in Active StorageKoichi ITO2017-08-121-0/+2
|
* Add 'activestorage/' from commit '3f4a7218a4a4923a0e7ce1b2eb0d2888ce30da58'Rafael Mendonça França2017-07-311-0/+47
git-subtree-dir: activestorage git-subtree-mainline: 0d58e7e478e79c2d6b2a39a4444d2a17a903b2a6 git-subtree-split: 3f4a7218a4a4923a0e7ce1b2eb0d2888ce30da58