clamby 1.6.2 → 1.6.5

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: 386be08fb41c318b1c32997c00f9df9ed3ee78796ceaded3927cb4672d45b370
4
- data.tar.gz: b1ed8cbc7842eb3ee4699cb4759c7ccb707bde51d82efc5ce5ff467f1dd9730b
3
+ metadata.gz: ea8e0af4d5353040a1d77f2d083e9273116d176b35466a252469c6229fcdd615
4
+ data.tar.gz: 7e16db099c92c3d0f5936b18656b648ed79379d84eddca7ab7b1ebff029e0f9a
5
5
  SHA512:
6
- metadata.gz: 5f0e78c730b651e66bce6710df83f13a5e250540dcfb7ba840584561e509666950513bd07221a46b6833ffab9356ade9e0cc1fe2250de622bb4a0f5a2378502f
7
- data.tar.gz: 17069ecf45fd0d5b48cfef58ba45ef489c7468dd2a5a0bcf4388058ef2fa651e8c6bb0cf802ca2f382a0c6fc4fc1215ffdd046e677667d06d6e960311b134042
6
+ metadata.gz: 4b0cbbfb2ac384a60e7f22805a4b3d519dad097a6a4d5420f5bf5204f5b6f086ab6aae4844deb9ea8fa09f4846370b8be5fa65ce66f7884c6f4d198dadf1780e
7
+ data.tar.gz: 583abcfd57e5e73ee0875a57af769c1c6acf86c81c2f4de736e7158d71652431c24aaf12eb8b92fecefb589d3a70e34decb0ce0f39a7fdae2748c3979b536d54
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  .DS_Store/
19
+ .byebug_history
@@ -4,11 +4,11 @@ before_install:
4
4
  - gem install rake
5
5
  - gem install rspec
6
6
  rvm:
7
- - 2.0.0
8
- - 2.1.1
9
7
  - 2.3.4
10
8
  - 2.4.1
11
9
  - 2.5.3
10
+ - 2.6.3
11
+ - 2.6.5
12
12
  install:
13
13
  - sudo apt-get install clamav
14
14
  - sudo freshclam
data/README.md CHANGED
@@ -17,14 +17,14 @@ Just add `gem 'clamby'` to your `Gemfile` and run `bundle install`.
17
17
 
18
18
  You can use two methods to scan a file for a virus:
19
19
 
20
- If you use `safe?` to scan a file, it will return true if no viruses were found, false if a virus was found, and nil if there was a problem finding the file or if there was a problem using `clamscan`
20
+ If you use `safe?` to scan a file, it will return `true` if no viruses were found, `false` if a virus was found, and `nil` if there was a problem finding the file or if there was a problem using `clamscan`
21
21
 
22
- `safe?(path_to_file)`
22
+ `Clamby.safe?(path_to_file)`
23
23
 
24
- If you use `virus?` to scan a file, it will return true if a virus was found, false if no virus was found, and nil if there was a problem finding the file or if there was a problem using `clamscan`
24
+ If you use `virus?` to scan a file, it will return `true` if a virus was found, `false` if no virus was found, and `nil` if there was a problem finding the file or if there was a problem using `clamscan`
25
25
 
26
26
 
27
- `virus?(path_to_file)`
27
+ `Clamby.virus?(path_to_file)`
28
28
 
29
29
  In your model with the uploader, you can add the scanner to a before method to scan the file. When a file is scanned, a successful scan will return `true`. An unsuccessful scan will return `false`. A scan may be unsuccessful for a number of reasons; `clamscan` could not be found, `clamscan` returned a virus, or the file which you were trying to scan could not be found.
30
30
 
@@ -64,6 +64,25 @@ It's good to note that Clamby will not by default delete files which had a virus
64
64
  end
65
65
  ```
66
66
 
67
+ ## with ActiveStorage
68
+
69
+ With ActiveStorage, you don't have access to the file through normal methods, so you'll have to access the file through the `attachment_changes`.
70
+
71
+ ```ruby
72
+ class User < ApplicationRecord
73
+ has_one_attached :avatar
74
+ before_save :scan_for_viruses
75
+
76
+ private
77
+
78
+ def scan_for_viruses
79
+ return unless self.attachment_changes['avatar']
80
+
81
+ path = self.attachment_changes['avatar'].attachable.tempfile.path
82
+ Clamby.safe?(path)
83
+ end
84
+ end
85
+ ```
67
86
 
68
87
  # Configuration
69
88
 
@@ -161,6 +180,11 @@ This opens the root crontab file in a text editor. Add the following line
161
180
 
162
181
  `57 08 * * * sudo freshclam`
163
182
 
183
+ # Contributors
184
+
185
+ <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
186
+ <!-- ALL-CONTRIBUTORS-LIST:END -->
187
+
164
188
  # LICENSE
165
189
 
166
190
  Copyright (c) 2016 kobaltz
@@ -18,7 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.5"
21
+ spec.add_development_dependency "bundler"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "byebug"
24
25
  end
@@ -15,6 +15,7 @@ module Clamby
15
15
  :fdpass => false,
16
16
  :stream => false,
17
17
  :output_level => 'medium',
18
+ :datadir => nil,
18
19
  :executable_path_clamscan => 'clamscan',
19
20
  :executable_path_clamdscan => 'clamdscan',
20
21
  :executable_path_freshclam => 'freshclam',
@@ -23,6 +23,10 @@ module Clamby
23
23
  args << '--stream' if Clamby.config[:stream]
24
24
  end
25
25
 
26
+ puts "use db : #{Clamby.config[:datadir]}"
27
+ args << "-d #{Clamby.config[:datadir]}" if Clamby.config[:datadir]
28
+ puts args.join(' ')
29
+
26
30
  new.run scan_executable, *args
27
31
 
28
32
  # $CHILD_STATUS maybe nil if the execution itself (not the client process)
@@ -35,7 +39,7 @@ module Clamby
35
39
  if Clamby.config[:error_clamscan_client_error] && Clamby.config[:daemonize]
36
40
  raise Clamby::ClamscanClientError.new("Clamscan client error")
37
41
  end
38
-
42
+
39
43
  # returns true to maintain legacy behavior
40
44
  return true
41
45
  else
@@ -47,7 +51,9 @@ module Clamby
47
51
 
48
52
  # Update the virus definitions.
49
53
  def self.freshclam
50
- new.run 'freshclam'
54
+ args = []
55
+ args << "--datadir=#{Clamby.config[:datadir]}" if Clamby.config[:datadir]
56
+ new.run 'freshclam', *args
51
57
  end
52
58
 
53
59
  # Show the ClamAV version. Also acts as a quick check if ClamAV functions.
@@ -68,7 +74,7 @@ module Clamby
68
74
  self.command = args | default_args
69
75
  self.command = command.sort.unshift(executable_full)
70
76
 
71
- system(*self.command, system_options)
77
+ system(self.command.join(' '), system_options)
72
78
  end
73
79
 
74
80
  private
@@ -1,3 +1,3 @@
1
1
  module Clamby
2
- VERSION = "1.6.2"
2
+ VERSION = "1.6.5"
3
3
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clamby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.2
4
+ version: 1.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - kobaltz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-10 00:00:00.000000000 Z
11
+ date: 2020-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.5'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.5'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: Clamby allows users to scan files uploaded with Paperclip or Carrierwave.
56
70
  If a file has a virus, then you can delete this file and discard it without causing
57
71
  harm to other users.
@@ -101,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
115
  - !ruby/object:Gem::Version
102
116
  version: '0'
103
117
  requirements: []
104
- rubygems_version: 3.0.3
118
+ rubygems_version: 3.0.8
105
119
  signing_key:
106
120
  specification_version: 4
107
121
  summary: Scan file uploads with ClamAV