Commit Graph

97 Commits

Author SHA1 Message Date
George Claghorn
93e6a0ec55 Fix attaching blobs to optimistically-locked records
Explicitly declare inverse associations so ActiveStorage::Attachment touches the original record instance.

Closes #31542.
2018-01-08 14:34:03 -05:00
George Claghorn
a736e82170 Document automatic width-height swapping [ci skip] 2018-01-07 10:04:14 -05:00
George Claghorn
19185c4dea Remove redundant sentences [ci skip] 2018-01-07 09:56:45 -05:00
George Claghorn
1223782598 Tweak engine for readability 2018-01-07 09:02:22 -05:00
Rosa Gutierrez
d40284b1a4
Force content disposition to attachment for specific content types
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.
2018-01-05 16:32:32 +01:00
George Claghorn
a72473f032 Configure previewer/analyzer command paths centrally 2018-01-03 22:01:31 -05:00
Arun Agrawal
15b3275a29
Merge pull request #31606 from yhirano55/bump_license_years_for_2018
Bump license years for 2018
2017-12-31 23:55:45 +05:30
George Claghorn
609dbb84c3 Expose ActiveStorage::Analyzer#logger in API docs [ci skip]
Clarify that it's public API and may be used in third-party analyzers.
2017-12-31 13:16:21 -05:00
George Claghorn
a470317b2c Expose ActiveStorage::Previewer#logger in API docs [ci skip]
Clarify that it's public API intended for use by third-party previewers. It shouldn't be removed without deprecation even though it isn't used by the built-in previewers.
2017-12-31 13:08:36 -05:00
George Claghorn
11995d6fd5 Suppress noise from drawing command invocations 2017-12-31 13:02:15 -05:00
George Claghorn
316d87e412 Append extension to tempfile name
Fixes analyzing an SVG image without an XML declaration. ImageMagick occasionally looks to the extension when it can't discern the type of an image file from its contents.

References #31356.
2017-12-31 10:36:58 -05:00
Yoshiyuki Hirano
b20354afcc Bump license years for 2018 2017-12-31 22:36:55 +09:00
George Claghorn
311af752cf Restrict variants to variable image blobs 2017-12-15 10:45:00 -05:00
Jeffrey Guenther
1c5358e472 Merge branch 'master' into activestorage-guide 2017-12-14 19:03:28 -08:00
Eileen M. Uchitelle
2fb78dc305
Merge pull request #31391 from 5t111111/fix-active_storage-installation-failure-in-engine
Fix active_storage installation failure when in engine
2017-12-13 08:10:44 -05:00
Hirofumi Wakasugi
66a22dee1c Invoke app-prefixed active storage task when in engine 2017-12-13 22:05:17 +09:00
Yoshiyuki Hirano
4c590e9d2e Return nil instead of false if raise Azure::Core::Http::HTTPError
* If it raise error `Azure::Core::Http::HTTPError`, return `nil` instead of `false` in
  `ActiveStorage::Service::AzureStorageService#delete`.

* Other services behave as same as this.
2017-12-12 02:57:38 +09:00
Jeffrey Guenther
a822287cef Merge branch 'master' into activestorage-guide 2017-12-08 13:25:54 -08:00
George Claghorn
da8e0ba03c Swap raw video width and height if angle is 90 or 270 degrees 2017-12-08 13:15:04 -05:00
George Claghorn
e8286ee272 Fix customizing Content-Type via GCS service URLs 2017-12-07 15:16:24 -05:00
Kasper Timm Hansen
7609ca08ce
Fix instrumention name: delete_prefixed like the others. 2017-12-03 18:06:29 +01:00
George Claghorn
8c5a7fbefd
Purge variants with their blobs 2017-12-02 22:43:28 -05:00
George Claghorn
b852ef2660
Make ASt previewer/analyzer binary paths configurable 2017-12-01 11:07:30 -05:00
George Claghorn
d041a1dcba Add ActiveStorage::Previewer#logger to match ActiveStorage::Analyzer#logger 2017-11-30 23:54:03 -05:00
Jeffrey Guenther
241b5f1ceb Merge branch 'master' into activestorage-guide 2017-11-30 08:43:37 -08:00
yuuji.yaginuma
9d65ac30fd Use credentials instead of keyfile in GCS sevice
The `keyfile` was renamed to `credentials` in `google-cloud-storage` 1.8.0.
https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/google-cloud-storage/CHANGELOG.md#180--2017-11-14

Although `keyfile` can still be used, but it looks like deprecate.
ddf7b2a856/google-cloud-storage/lib/google/cloud/storage.rb (L589...L590)

Therefore, I think that should use `credentials` in newly generated
applications.

Ref: https://github.com/GoogleCloudPlatform/google-cloud-ruby/issues/1802
2017-11-29 13:17:04 +09:00
Rafael Mendonça França
2837d0f334
Preparing for 5.2.0.beta2 release 2017-11-28 14:41:02 -05:00
Rafael Mendonça França
cceeeb6e57
Preparing for 5.2.0.beta1 release 2017-11-27 14:50:03 -05:00
George Claghorn
fbb12910bd Avoid connecting to GCS during app boot 2017-11-23 19:48:25 -05:00
Jeffrey Guenther
c73001f4b7 Merge branch 'master' into activestorage-guide 2017-11-20 17:01:27 -08:00
George Claghorn
1d24e47140
Provide attachment writers
Permit creating a record and attaching files in a single step.

    # Before:
    User.create!(user_params.except(:avatar)).tap do |user|
      user.avatar.attach(user_params[:avatar])
    end

    # After:
    User.create!(user_params)

[Yoshiyuki Hirano & George Claghorn]
2017-11-20 18:06:06 -05:00
George Claghorn
e05e2ae44f Permit attaching files to new records
Closes #31164.
2017-11-19 17:34:07 -05:00
George Claghorn
499a4164ce Introduce ActiveStorage::Attached::{One,Many}#detach 2017-11-14 10:42:51 -05:00
Jeffrey Guenther
d0550ff671 Merge branch 'master' into activestorage-guide 2017-11-09 09:31:16 -08:00
George Claghorn
daf77db65d Remove needless block parameter 2017-11-07 09:06:23 -05:00
George Claghorn
86938c495e
Fix streaming downloads from S3/Azure Storage
Closes #31073.
2017-11-06 21:29:37 -05:00
George Claghorn
9ec6736205 Permit configuring Active Storage's job queue 2017-11-03 11:29:21 -04:00
Jeffrey Guenther
2def806f07 Fixes typo in docs 2017-11-02 16:57:13 -07:00
George Claghorn
aa6bcbbac8 Allow third-party previewers/analyzers to customize their tempdirs 2017-11-02 15:07:41 -04:00
George Claghorn
f4d1aa5310 Use the indicative mood consistently [ci skip] 2017-10-22 23:14:44 -04:00
George Claghorn
398e4fecde Fix links [ci skip] 2017-10-22 13:36:37 -04:00
George Claghorn
605484079d Extract metadata from images and videos 2017-10-22 13:16:59 -04:00
Akira Matsuda
20c9111990 [Active Storage] require_relative => require 2017-10-21 22:48:29 +09:00
Ryuta Kamizono
83b7cb3a47 Fix "warning: `*' interpreted as argument prefix" 2017-09-30 05:40:55 +09:00
George Claghorn
d30586211b Preview PDFs and videos 2017-09-28 16:43:37 -04:00
Yoshiyuki Hirano
704bf9b9c6 Add with_attached_* scope to has_one_attached macro
* For avoiding N+1 problem, added `with_attached_*` scope to
  `has_one_attached` macro.
2017-09-19 06:02:00 +09:00
Yoshiyuki Hirano
7d14bda3a7 Fix file missing in activestorage's example code [ci skip]
* File.open("~/face.jpg") raise error:
  `Errno::ENOENT: No such file or directory @ rb_sysopen - ~/face.jpg`
2017-09-17 21:00:23 +09:00
George Claghorn
cffa32f95d Avoid making HTTP requests to generate signed URLs for GCS objects 2017-09-13 22:44:04 -04:00
David Heinemeier Hansson
69f976b859 Add credentials using a generic EncryptedConfiguration class (#30067)
* WIP: Add credentials using a generic EncryptedConfiguration class

This is sketch code so far.

* Flesh out EncryptedConfiguration and test it

* Better name

* Add command and generator for credentials

* Use the Pathnames

* Extract EncryptedFile from EncryptedConfiguration and add serializers

* Test EncryptedFile

* Extract serializer validation

* Stress the point about losing comments

* Allow encrypted configuration to be read without parsing for display

* Use credentials by default and base them on the master key

* Derive secret_key_base in test/dev, source it from credentials in other envs

And document the usage.

* Document the new credentials setup

* Stop generating the secrets.yml file now that we have credentials

* Document what we should have instead

Still need to make it happen, tho.

* [ci skip] Keep wording to `key base`; prefer defaults.

Usually we say we change defaults, not "spec" out a release.

Can't use backticks in our sdoc generated documentation either.

* Abstract away OpenSSL; prefer MessageEncryptor.

* Spare needless new when raising.

* Encrypted file test shouldn't depend on subclass.

* [ci skip] Some woordings.

* Ditch serializer future coding.

* I said flip it. Flip it good.

* [ci skip] Move require_master_key to the real production.rb.

* Add require_master_key to abort the boot process.

In case the master key is required in a certain environment
we should inspect that the key is there and abort if it isn't.

* Print missing key message and exit immediately.

Spares us a lengthy backtrace and prevents further execution.

I've verified the behavior in a test app, but couldn't figure the
test out as loading the app just exits immediately with:

```
/Users/kasperhansen/Documents/code/rails/activesupport/lib/active_support/testing/isolation.rb:23:in `load': marshal data too short (ArgumentError)
	from /Users/kasperhansen/Documents/code/rails/activesupport/lib/active_support/testing/isolation.rb:23:in `run'
	from /Users/kasperhansen/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/minitest-5.10.2/lib/minitest.rb:830:in `run_one_method'
	from /Users/kasperhansen/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/minitest-5.10.2/lib/minitest/parallel.rb:32:in `block (2 levels) in start'
```

It's likely we need to capture and prevent the exit somehow.
Kernel.stub(:exit) didn't work. Leaving it for tomorrow.

* Fix require_master_key config test.

Loading the app would trigger the `exit 1` per require_master_key's
semantics, which then aborted the test.

Fork and wait for the child process to finish, then inspect the
exit status.

Also check we aborted because of a missing master key, so something
else didn't just abort the boot.

Much <3 to @tenderlove for the tip.

* Support reading/writing configs via methods.

* Skip needless deep symbolizing.

* Remove save; test config reader elsewhere.

* Move secret_key_base check to when we're reading it.

Otherwise we'll abort too soon since we don't assign the secret_key_base
to secrets anymore.

* Add missing string literal comments; require unneeded yaml require.

* ya ya ya, rubocop.

* Add master_key/credentials after bundle.

Then we can reuse the existing message on `rails new bc4`.

It'll look like:

```
Using web-console 3.5.1 from https://github.com/rails/web-console.git (at master@ce985eb)
Using rails 5.2.0.alpha from source at `/Users/kasperhansen/Documents/code/rails`
Using sass-rails 5.0.6
Bundle complete! 16 Gemfile dependencies, 72 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Adding config/master.key to store the master encryption key: 97070158c44b4675b876373a6bc9d5a0

Save this in a password manager your team can access.

If you lose the key, no one, including you, can access anything encrypted with it.

      create  config/master.key
```

And that'll be executed even if `--skip-bundle` was passed.

* Ensure test app has secret_key_base.

* Assign secret_key_base to app or omit.

* Merge noise

* Split options for dynamic delegation into its own method and use deep symbols to make it work

* Update error to point to credentials instead

* Appease Rubocop

* Validate secret_key_base when reading it.

Instead of relying on the validation in key_generator move that into
secret_key_base itself.

* Fix generator and secrets test.

Manually add config.read_encrypted_secrets since it's not there by default
anymore.

Move mentions of config/secrets.yml to config/credentials.yml.enc.

* Remove files I have no idea how they got here.

* [ci skip] swap secrets for credentials.

* [ci skip] And now, changelogs are coming.
2017-09-11 20:21:20 +02:00
Yuji Yaginuma
83bfe07583 Use v3 of the AWS SDK 2017-09-09 23:22:10 -04:00