ratonvirus 0.4.2 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf996f1b6f63fe570fb46f62c91625c0e8ad3ec073f595802d580c399c1fca27
4
- data.tar.gz: 6ad46dd7435948e0750b00cb78820f550b1edd8229923ed84e118ac09feacbde
3
+ metadata.gz: ad1408747188a58c2a0d1ad7fea36a4a2144daf86c3f0ab82e568beb0eb78335
4
+ data.tar.gz: 4d47b462f78bef2abfc611780ce85972e63ab35318c8492146f5b87aec4ad507
5
5
  SHA512:
6
- metadata.gz: 3eacdeb037efa1a36dc2c7c600d39cd29c52ca23abebe2f28b054046de9e73553dcb7b53b1907f2db6075df7af0cb85b9be2c869dcf3c0a8ed6dc747580caa27
7
- data.tar.gz: 47e950609423daec9177c450bcf96d7dab1273ec288ecf4becc8f881f04121207487b05271bd035c2fe8036d1f198f6a0202e2d6a5e458bcd9d2338ac21933e7
6
+ metadata.gz: 717b88a5ba971f64de16d81a6af5e4bb82a4832fce8780801c63eaf64aa231dcb1fdbb549efa40a30d64661f18c31c6f1b5c80af7bd93f768f75b126a30fde2f
7
+ data.tar.gz: 1195298ca2136fad104b00b0eb56ed9f1552c2cd6122cc08487d93cbf82793de188b3c31239a56e32ae6f86b1006be96fd8c0e1365b1c282b3d2078c356f97b7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ # v0.5.0
2
+
3
+ Changed:
4
+
5
+ - 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).
6
+
7
+ Fixed:
8
+
9
+ - Skip antivirus scan for persisted blobs [#39](https://github.com/mainio/ratonvirus/pull/39)
10
+ - XAmzContentSHA256Mismatch when using active storage with s3 backend [#36](https://github.com/mainio/ratonvirus/issues/36)
11
+
12
+ # v0.4.3
13
+
14
+ Fixed:
15
+
16
+ - Manual scan is not working for File objects [#32](https://github.com/mainio/ratonvirus/pull/32)
17
+
1
18
  # v0.4.2
2
19
 
3
20
  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).
@@ -95,7 +95,7 @@ module Ratonvirus
95
95
  def yield_processable_from(change, &_block)
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
@@ -24,7 +24,7 @@ module Ratonvirus
24
24
  return unless block_given?
25
25
 
26
26
  return unless asset
27
- return if asset.empty?
27
+ return if asset.respond_to?(:empty?) && asset.empty?
28
28
 
29
29
  if asset.respond_to?(:path)
30
30
  # A file asset that responds to path (e.g. default `File`
@@ -33,7 +33,6 @@ module Ratonvirus
33
33
 
34
34
  return
35
35
  end
36
-
37
36
  # Plain file path string provided as resource
38
37
  yield asset
39
38
  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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ratonvirus
4
- VERSION = "0.4.2"
4
+ VERSION = "0.5.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ratonvirus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antti Hukkanen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-25 00:00:00.000000000 Z
11
+ date: 2026-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport