ratonvirus 0.4.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +28 -0
- data/README.md +20 -0
- data/lib/ratonvirus/processable.rb +2 -2
- data/lib/ratonvirus/scanner/support/callbacks.rb +4 -4
- data/lib/ratonvirus/storage/active_storage.rb +11 -11
- data/lib/ratonvirus/storage/carrierwave.rb +3 -3
- data/lib/ratonvirus/storage/filepath.rb +2 -2
- data/lib/ratonvirus/storage/support/io_handling.rb +5 -0
- data/lib/ratonvirus/version.rb +1 -1
- metadata +8 -136
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5837213cdad0ffd1363940af339c4476926dc87546c6fc5c1fefdac457e747a6
|
|
4
|
+
data.tar.gz: 1bc2caa99dec67aca116bf8f650f2750483f5dd111111f5a074950ba12e2b4db
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d5844998f549d6e9b2a2d2e3260f737508977a66bbeb2526fa44135e262e839c3a99c904ea46bf2e52859d58892553f6656c362f57736e38d36a91ac3f6af364
|
|
7
|
+
data.tar.gz: 53c0c90eb8af893aa5e0bd0c5b002b25a0ec081338d36d4225cd29adf5a08ae8d13ae7d33f23e4a507894b2f8a78d40eadc29f38341d78966a9717f912fa1dac
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
# v0.6.0
|
|
2
|
+
|
|
3
|
+
Support for Rails 8
|
|
4
|
+
|
|
5
|
+
Changed:
|
|
6
|
+
|
|
7
|
+
- ActiveSupport dependency updated to `8.x` in order to support Rails 8
|
|
8
|
+
- The minimum Ruby version is now set to 3.2 as it is a requirement of Rails 8
|
|
9
|
+
- The development dependencies are removed from the `.gemspec` and moved to the local `Gemfile` within the development repository
|
|
10
|
+
- Handling `ActiveStorage::Attached::Changes::CreateMany` now fetches the new uploads through `change.pending_uploads` instead of `change.subchanges` in order to get access to the newly uploaded file objects [#41](https://github.com/mainio/ratonvirus/pull/41)
|
|
11
|
+
|
|
12
|
+
# v0.5.0
|
|
13
|
+
|
|
14
|
+
Changed:
|
|
15
|
+
|
|
16
|
+
- Scanning is now skipped for blobs that have a related attachment that has been persisted in order to avoid scanning the same file multiple times. We assume that the file needs to be scanned only once during the first time it is being attached to a record because otherwise it would be re-scanned every time when the attached record is updated (in which case the file would not be changed, as if the file is changed, also the attached blob is changed).
|
|
17
|
+
|
|
18
|
+
Fixed:
|
|
19
|
+
|
|
20
|
+
- Skip antivirus scan for persisted blobs [#39](https://github.com/mainio/ratonvirus/pull/39)
|
|
21
|
+
- XAmzContentSHA256Mismatch when using active storage with s3 backend [#36](https://github.com/mainio/ratonvirus/issues/36)
|
|
22
|
+
|
|
23
|
+
# v0.4.3
|
|
24
|
+
|
|
25
|
+
Fixed:
|
|
26
|
+
|
|
27
|
+
- Manual scan is not working for File objects [#32](https://github.com/mainio/ratonvirus/pull/32)
|
|
28
|
+
|
|
1
29
|
# v0.4.2
|
|
2
30
|
|
|
3
31
|
Fixed:
|
data/README.md
CHANGED
|
@@ -250,6 +250,26 @@ For installing ClamAV, refer to
|
|
|
250
250
|
For further information about the configurations and how to create custom
|
|
251
251
|
scanners, please refer to the [documentation](docs/index.md).
|
|
252
252
|
|
|
253
|
+
## Common issues
|
|
254
|
+
|
|
255
|
+
### NoMethodError (undefined method `attached?' ...)
|
|
256
|
+
|
|
257
|
+
Multiple issues have been opened because of users getting the following error
|
|
258
|
+
when trying to run a scan against a file path:
|
|
259
|
+
|
|
260
|
+
```
|
|
261
|
+
NoMethodError (undefined method `attached?' for "/path/to/file.pdf":String)
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Most of the times this issue is because you have not configured the storage
|
|
265
|
+
correctly. If you want to run direct scans against files, please use the
|
|
266
|
+
`:filepath` storage option as described at
|
|
267
|
+
[Manually checking for viruses](#manually-checking-for-viruses).
|
|
268
|
+
|
|
269
|
+
If you need both: scans against file paths and scans against Active Storage
|
|
270
|
+
attached files, please use the `:multi` storage option as described in the same
|
|
271
|
+
section of the documentation.
|
|
272
|
+
|
|
253
273
|
## License
|
|
254
274
|
|
|
255
275
|
MIT, see [LICENSE](LICENSE).
|
|
@@ -47,13 +47,13 @@ module Ratonvirus
|
|
|
47
47
|
module Callbacks
|
|
48
48
|
private
|
|
49
49
|
|
|
50
|
-
def run_callbacks(type,
|
|
50
|
+
def run_callbacks(type, *, &)
|
|
51
51
|
raise NotDefinedError, "No callbacks defined" if @_callbacks.nil?
|
|
52
52
|
raise NotDefinedError, "Callbacks for #{type} not defined" if @_callbacks[type].nil?
|
|
53
53
|
|
|
54
|
-
run_callback_callables
|
|
55
|
-
result = yield(*
|
|
56
|
-
run_callback_callables
|
|
54
|
+
run_callback_callables(@_callbacks[type][:before], *)
|
|
55
|
+
result = yield(*)
|
|
56
|
+
run_callback_callables(@_callbacks[type][:after], *)
|
|
57
57
|
|
|
58
58
|
result
|
|
59
59
|
end
|
|
@@ -15,7 +15,7 @@ module Ratonvirus
|
|
|
15
15
|
resource.is_a?(::ActiveStorage::Attached::Many)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
def process(resource, &
|
|
18
|
+
def process(resource, &)
|
|
19
19
|
return unless block_given?
|
|
20
20
|
return if resource.nil?
|
|
21
21
|
return unless resource.attached?
|
|
@@ -24,13 +24,13 @@ module Ratonvirus
|
|
|
24
24
|
|
|
25
25
|
case change
|
|
26
26
|
when ::ActiveStorage::Attached::Changes::CreateOne
|
|
27
|
-
handle_create_one(change, &
|
|
27
|
+
handle_create_one(change, &)
|
|
28
28
|
when ::ActiveStorage::Attached::Changes::CreateMany
|
|
29
|
-
handle_create_many(change, &
|
|
29
|
+
handle_create_many(change, &)
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
def asset_path(asset, &
|
|
33
|
+
def asset_path(asset, &)
|
|
34
34
|
return unless block_given?
|
|
35
35
|
return unless asset.is_a?(Array)
|
|
36
36
|
|
|
@@ -40,10 +40,10 @@ module Ratonvirus
|
|
|
40
40
|
# These files should be already locally stored but their permissions
|
|
41
41
|
# can prevent the virus scanner executable from accessing them.
|
|
42
42
|
# Therefore, a temporary file is created for them as well.
|
|
43
|
-
io_path(asset[1], ext, &
|
|
43
|
+
io_path(asset[1], ext, &)
|
|
44
44
|
when Hash
|
|
45
45
|
io = asset[1].fetch(:io)
|
|
46
|
-
io_path(io, ext, &
|
|
46
|
+
io_path(io, ext, &) if io
|
|
47
47
|
when ::ActiveStorage::Blob
|
|
48
48
|
asset[1].open do |tempfile|
|
|
49
49
|
prepare_for_scanner tempfile.path
|
|
@@ -82,20 +82,20 @@ module Ratonvirus
|
|
|
82
82
|
|
|
83
83
|
private
|
|
84
84
|
|
|
85
|
-
def handle_create_one(change, &
|
|
86
|
-
yield_processable_from(change, &
|
|
85
|
+
def handle_create_one(change, &)
|
|
86
|
+
yield_processable_from(change, &)
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
def handle_create_many(change, &block)
|
|
90
|
-
change.
|
|
90
|
+
change.pending_uploads.each do |subchange|
|
|
91
91
|
yield_processable_from(subchange, &block)
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
|
|
95
|
-
def yield_processable_from(change, &
|
|
95
|
+
def yield_processable_from(change, &)
|
|
96
96
|
attachable = change.attachable
|
|
97
97
|
return unless attachable
|
|
98
|
-
return if attachable.is_a?(::ActiveStorage::Blob)
|
|
98
|
+
return if attachable.is_a?(::ActiveStorage::Blob) && change.attachment.persisted?
|
|
99
99
|
|
|
100
100
|
# If the attachable is a string, it is a reference to an already
|
|
101
101
|
# existing blob. This can happen e.g. when the file blob is uploaded
|
|
@@ -11,13 +11,13 @@ module Ratonvirus
|
|
|
11
11
|
|
|
12
12
|
def accept?(resource)
|
|
13
13
|
if resource.is_a?(Array)
|
|
14
|
-
resource.all?
|
|
14
|
+
resource.all?(::CarrierWave::Uploader::Base)
|
|
15
15
|
else
|
|
16
16
|
resource.is_a?(::CarrierWave::Uploader::Base)
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
def asset_path(asset, &
|
|
20
|
+
def asset_path(asset, &)
|
|
21
21
|
return unless block_given?
|
|
22
22
|
return if asset.nil?
|
|
23
23
|
return if asset.file.nil?
|
|
@@ -32,7 +32,7 @@ module Ratonvirus
|
|
|
32
32
|
# scan on.
|
|
33
33
|
io = StringIO.new(asset.file.read)
|
|
34
34
|
ext = File.extname(asset.file.path)
|
|
35
|
-
io_path(io, ext, &
|
|
35
|
+
io_path(io, ext, &)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
def asset_remove(asset)
|
|
@@ -20,7 +20,7 @@ module Ratonvirus
|
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
def asset_path(asset, &
|
|
23
|
+
def asset_path(asset, &)
|
|
24
24
|
return unless block_given?
|
|
25
25
|
|
|
26
26
|
return unless asset
|
|
@@ -29,7 +29,7 @@ module Ratonvirus
|
|
|
29
29
|
if asset.respond_to?(:path)
|
|
30
30
|
# A file asset that responds to path (e.g. default `File`
|
|
31
31
|
# object).
|
|
32
|
-
asset_path(asset.path, &
|
|
32
|
+
asset_path(asset.path, &)
|
|
33
33
|
|
|
34
34
|
return
|
|
35
35
|
end
|
|
@@ -23,8 +23,13 @@ module Ratonvirus
|
|
|
23
23
|
begin
|
|
24
24
|
tempfile.binmode
|
|
25
25
|
if io.is_a?(StringIO)
|
|
26
|
+
orig_pos = io.pos
|
|
27
|
+
io.rewind
|
|
28
|
+
|
|
26
29
|
# cannot specify src_offset for non-IO
|
|
27
30
|
IO.copy_stream(io, tempfile)
|
|
31
|
+
|
|
32
|
+
io.pos = orig_pos
|
|
28
33
|
else
|
|
29
34
|
IO.copy_stream(io, tempfile, nil, 0)
|
|
30
35
|
end
|
data/lib/ratonvirus/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ratonvirus
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Antti Hukkanen
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activesupport
|
|
@@ -16,140 +15,14 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - "~>"
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
18
|
+
version: '8.0'
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
23
|
- - "~>"
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: rake
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '13.0'
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '13.0'
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: rspec
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - "~>"
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '3.0'
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - "~>"
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '3.0'
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: rspec-rails
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - "~>"
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: '4.0'
|
|
62
|
-
type: :development
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - "~>"
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: '4.0'
|
|
69
|
-
- !ruby/object:Gem::Dependency
|
|
70
|
-
name: simplecov
|
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
|
72
|
-
requirements:
|
|
73
|
-
- - "~>"
|
|
74
|
-
- !ruby/object:Gem::Version
|
|
75
|
-
version: 0.18.0
|
|
76
|
-
type: :development
|
|
77
|
-
prerelease: false
|
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
-
requirements:
|
|
80
|
-
- - "~>"
|
|
81
|
-
- !ruby/object:Gem::Version
|
|
82
|
-
version: 0.18.0
|
|
83
|
-
- !ruby/object:Gem::Dependency
|
|
84
|
-
name: activemodel
|
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
|
86
|
-
requirements:
|
|
87
|
-
- - "~>"
|
|
88
|
-
- !ruby/object:Gem::Version
|
|
89
|
-
version: '7.0'
|
|
90
|
-
type: :development
|
|
91
|
-
prerelease: false
|
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
-
requirements:
|
|
94
|
-
- - "~>"
|
|
95
|
-
- !ruby/object:Gem::Version
|
|
96
|
-
version: '7.0'
|
|
97
|
-
- !ruby/object:Gem::Dependency
|
|
98
|
-
name: activestorage
|
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
|
100
|
-
requirements:
|
|
101
|
-
- - "~>"
|
|
102
|
-
- !ruby/object:Gem::Version
|
|
103
|
-
version: '7.0'
|
|
104
|
-
type: :development
|
|
105
|
-
prerelease: false
|
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
-
requirements:
|
|
108
|
-
- - "~>"
|
|
109
|
-
- !ruby/object:Gem::Version
|
|
110
|
-
version: '7.0'
|
|
111
|
-
- !ruby/object:Gem::Dependency
|
|
112
|
-
name: carrierwave
|
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
|
114
|
-
requirements:
|
|
115
|
-
- - "~>"
|
|
116
|
-
- !ruby/object:Gem::Version
|
|
117
|
-
version: '2.1'
|
|
118
|
-
type: :development
|
|
119
|
-
prerelease: false
|
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
-
requirements:
|
|
122
|
-
- - "~>"
|
|
123
|
-
- !ruby/object:Gem::Version
|
|
124
|
-
version: '2.1'
|
|
125
|
-
- !ruby/object:Gem::Dependency
|
|
126
|
-
name: rubocop
|
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
|
128
|
-
requirements:
|
|
129
|
-
- - "~>"
|
|
130
|
-
- !ruby/object:Gem::Version
|
|
131
|
-
version: 1.11.0
|
|
132
|
-
type: :development
|
|
133
|
-
prerelease: false
|
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
-
requirements:
|
|
136
|
-
- - "~>"
|
|
137
|
-
- !ruby/object:Gem::Version
|
|
138
|
-
version: 1.11.0
|
|
139
|
-
- !ruby/object:Gem::Dependency
|
|
140
|
-
name: rubocop-rspec
|
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
|
142
|
-
requirements:
|
|
143
|
-
- - "~>"
|
|
144
|
-
- !ruby/object:Gem::Version
|
|
145
|
-
version: 2.2.0
|
|
146
|
-
type: :development
|
|
147
|
-
prerelease: false
|
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
-
requirements:
|
|
150
|
-
- - "~>"
|
|
151
|
-
- !ruby/object:Gem::Version
|
|
152
|
-
version: 2.2.0
|
|
25
|
+
version: '8.0'
|
|
153
26
|
description: Adds antivirus check capability for Rails applications.
|
|
154
27
|
email:
|
|
155
28
|
- antti.hukkanen@mainiotech.fi
|
|
@@ -184,8 +57,8 @@ files:
|
|
|
184
57
|
homepage: https://github.com/mainio/ratonvirus
|
|
185
58
|
licenses:
|
|
186
59
|
- MIT
|
|
187
|
-
metadata:
|
|
188
|
-
|
|
60
|
+
metadata:
|
|
61
|
+
rubygems_mfa_required: 'true'
|
|
189
62
|
rdoc_options: []
|
|
190
63
|
require_paths:
|
|
191
64
|
- lib
|
|
@@ -193,15 +66,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
193
66
|
requirements:
|
|
194
67
|
- - ">="
|
|
195
68
|
- !ruby/object:Gem::Version
|
|
196
|
-
version: '2
|
|
69
|
+
version: '3.2'
|
|
197
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
71
|
requirements:
|
|
199
72
|
- - ">="
|
|
200
73
|
- !ruby/object:Gem::Version
|
|
201
74
|
version: '0'
|
|
202
75
|
requirements: []
|
|
203
|
-
rubygems_version: 3.
|
|
204
|
-
signing_key:
|
|
76
|
+
rubygems_version: 3.6.9
|
|
205
77
|
specification_version: 4
|
|
206
78
|
summary: Provides antivirus checks for Rails.
|
|
207
79
|
test_files: []
|