carrierwave-bombshelter 0.1.1.6 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -3
- data/lib/carrierwave/bombshelter.rb +6 -2
- data/lib/carrierwave/bombshelter/version.rb +1 -1
- data/lib/locale/en.yml +1 -1
- data/lib/locale/ru.yml +1 -1
- metadata +3 -5
- data/lib/locale/fr.yml +0 -5
- data/lib/locale/tr.yml +0 -5
- data/lib/locale/zh-TW.yml +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7c3a39b71c781524915e471ed4e30b5bd2537b7
|
4
|
+
data.tar.gz: 7a5da68b7018a758449334c576c774c404b61c41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd06151492894cc3b0a32220e6cba3004563a60b0183b54d720f7d0a1965e921fd1f0b16b7d3fefb35e58bc45161fd7275a38ec8a4ee4859a33b1cc25cf4d9f8
|
7
|
+
data.tar.gz: 4154b8f5264f7fad9830b61ed9c814baf767bd76a256ed2c660a17f904225e967976b84a37b70d487a5aaecffc2059835567783a5a6bb8d90b71fe30a166903a
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/DarthSim/carrierwave-bombshelter.svg)](https://travis-ci.org/DarthSim/carrierwave-bombshelter)
|
4
4
|
|
5
|
-
BombShelter is a module which protects your uploaders from
|
5
|
+
BombShelter is a module which protects your uploaders from image bombs like [https://www.bamsoftware.com/hacks/deflate.html]() and [http://www.openwall.com/lists/oss-security/2016/05/03/18](). It checks type and pixel dimensions of uploaded image before ImageMagick touches it.
|
6
6
|
|
7
7
|
<a href="https://evilmartians.com/">
|
8
8
|
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54">
|
@@ -10,7 +10,7 @@ BombShelter is a module which protects your uploaders from [image bombs](https:/
|
|
10
10
|
|
11
11
|
## How it works
|
12
12
|
|
13
|
-
BombShelter uses [fastimage](https://github.com/sdsykes/fastimage) gem, which reads just a header of an image to get info about it. BombShelter compares pixel dimensions of the uploaded image with
|
13
|
+
BombShelter uses [fastimage](https://github.com/sdsykes/fastimage) gem, which reads just a header of an image to get info about it. BombShelter compares type and pixel dimensions of the uploaded image with allowed ones and raises integrity error if image is too big or have unsupported type. Works perfectly with ActiveRecord validators.
|
14
14
|
|
15
15
|
## Installation
|
16
16
|
|
@@ -38,7 +38,23 @@ class YourUploader < CarrierWave::Uploader::Base
|
|
38
38
|
end
|
39
39
|
```
|
40
40
|
|
41
|
-
|
41
|
+
You can change allowed image types by defining `image_type_whitelist` method (default are `[:jpeg, :png, :gif]`):
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
class YourUploader < CarrierWave::Uploader::Base
|
45
|
+
include CarrierWave::BombShelter
|
46
|
+
|
47
|
+
def image_type_whitelist
|
48
|
+
%i(bmp jpeg png gif)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
```
|
52
|
+
|
53
|
+
**Note:** Whitelisted file types should be supported by [fastimage](https://github.com/sdsykes/fastimage).
|
54
|
+
|
55
|
+
**Warning:** Allowing `svg` and `mvg` is totally insecure.
|
56
|
+
|
57
|
+
You can change maximum allowed dimensions by defining `max_pixel_dimensions` method (default is 4096x4096):
|
42
58
|
|
43
59
|
```ruby
|
44
60
|
class YourUploader < CarrierWave::Uploader::Base
|
@@ -54,6 +70,10 @@ end
|
|
54
70
|
|
55
71
|
Bug reports and pull requests are welcome on GitHub at https://github.com/DarthSim/carrierwave-bombshelter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org/) code of conduct.
|
56
72
|
|
73
|
+
#### Locales
|
74
|
+
|
75
|
+
Please don't create PRs that add locales. I can't maintain locales of languages that I don't know, and I can't poke you every time when I need to add a new string.
|
76
|
+
|
57
77
|
## License
|
58
78
|
|
59
79
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
@@ -26,6 +26,10 @@ module CarrierWave
|
|
26
26
|
[4096, 4096]
|
27
27
|
end
|
28
28
|
|
29
|
+
def image_type_whitelist
|
30
|
+
%i(jpeg png gif)
|
31
|
+
end
|
32
|
+
|
29
33
|
private
|
30
34
|
|
31
35
|
def protect_from_image_bomb!(new_file)
|
@@ -35,9 +39,9 @@ module CarrierWave
|
|
35
39
|
end
|
36
40
|
|
37
41
|
def check_image_type!(image)
|
38
|
-
return if image.type
|
42
|
+
return if image.type && image_type_whitelist.include?(image.type)
|
39
43
|
raise CarrierWave::IntegrityError,
|
40
|
-
I18n.translate(:'errors.messages.
|
44
|
+
I18n.translate(:'errors.messages.unsupported_image_type')
|
41
45
|
end
|
42
46
|
|
43
47
|
def check_pixel_dimensions!(image)
|
data/lib/locale/en.yml
CHANGED
data/lib/locale/ru.yml
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-bombshelter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DarthSim
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04
|
11
|
+
date: 2016-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -126,10 +126,7 @@ files:
|
|
126
126
|
- lib/carrierwave/bombshelter.rb
|
127
127
|
- lib/carrierwave/bombshelter/version.rb
|
128
128
|
- lib/locale/en.yml
|
129
|
-
- lib/locale/fr.yml
|
130
129
|
- lib/locale/ru.yml
|
131
|
-
- lib/locale/tr.yml
|
132
|
-
- lib/locale/zh-TW.yml
|
133
130
|
homepage: https://github.com/DarthSim/carrierwave-bombshelter
|
134
131
|
licenses:
|
135
132
|
- MIT
|
@@ -155,3 +152,4 @@ signing_key:
|
|
155
152
|
specification_version: 4
|
156
153
|
summary: Protect your carrierwave from image bombs
|
157
154
|
test_files: []
|
155
|
+
has_rdoc:
|
data/lib/locale/fr.yml
DELETED
data/lib/locale/tr.yml
DELETED