clamby 1.5.1 → 1.6.6
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/.gitignore +1 -0
- data/.travis.yml +4 -3
- data/CHANGELOG.md +13 -0
- data/README.md +29 -5
- data/clamby.gemspec +2 -1
- data/lib/clamby.rb +1 -0
- data/lib/clamby/command.rb +13 -7
- data/lib/clamby/version.rb +1 -1
- data/spec/clamby/command_spec.rb +10 -18
- metadata +24 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9bf0bfa99f769f41a964838dca46fcb5d6b4c2a2e1653ff43c3a40fde25480f
|
4
|
+
data.tar.gz: 95615a8f2c69aa42a593f909a426266253026c7bc3d24a74dfabb13dd931c526
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4af568ba3f78fb465a18625ff9e9fca343de65b95b155b57cd3b7156d19db876457837331896c3c9c6767326a93f6dcf01f73c5518180df9ff95b7af8868b5e
|
7
|
+
data.tar.gz: 3c2b5004c4b5dbb2fc627a2d20a79307361b5385b3b53dc0500fe1683430db9619d90a18e0aa414d28ce103bbbe9265409462c0d3845f0e6667a76ff788743a6
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
language: ruby
|
2
2
|
before_install:
|
3
|
-
- gem install bundler -v '
|
3
|
+
- gem install bundler -v '1.17.3'
|
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
|
9
|
+
- 2.5.3
|
10
|
+
- 2.6.3
|
11
|
+
- 2.6.5
|
11
12
|
install:
|
12
13
|
- sudo apt-get install clamav
|
13
14
|
- sudo freshclam
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
# v1.6.5
|
2
|
+
- [bennacer860](https://github.com/kobaltz/clamby/commits?author=bennacer860) - Added config data dir option
|
3
|
+
|
4
|
+
|
5
|
+
# v1.6.2
|
6
|
+
- [emilong](https://github.com/kobaltz/clamby/commits?author=emilong) - Handle nil exit status of clamav executable.
|
7
|
+
|
8
|
+
# v1.6.1
|
9
|
+
- [broder](https://github.com/kobaltz/clamby/commits?author=broder) - Fixed issue with detecting clamdscan version when using custom config file
|
10
|
+
|
11
|
+
# v1.6.0
|
12
|
+
- When checking version, use the executable configuration.
|
13
|
+
|
1
14
|
# v1.5.1
|
2
15
|
- [ahukkanen](https://github.com/kobaltz/clamby/commits?author=ahukkanen) - Configurable execution paths
|
3
16
|
|
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
|
|
@@ -80,7 +99,7 @@ Configuration is rather limited right now. You can exclude the check if `clamsca
|
|
80
99
|
:error_file_virus => false,
|
81
100
|
:fdpass => false,
|
82
101
|
:stream => false,
|
83
|
-
:
|
102
|
+
:output_level => 'medium', # one of 'off', 'low', 'medium', 'high'
|
84
103
|
:executable_path_clamscan => 'clamscan',
|
85
104
|
:executable_path_clamdscan => 'clamdscan',
|
86
105
|
:executable_path_freshclam => 'freshclam',
|
@@ -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
|
data/clamby.gemspec
CHANGED
@@ -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"
|
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
|
data/lib/clamby.rb
CHANGED
data/lib/clamby/command.rb
CHANGED
@@ -21,20 +21,23 @@ module Clamby
|
|
21
21
|
if Clamby.config[:daemonize]
|
22
22
|
args << '--fdpass' if Clamby.config[:fdpass]
|
23
23
|
args << '--stream' if Clamby.config[:stream]
|
24
|
-
args << "--config-file=#{Clamby.config[:config_file]}" if Clamby.config[:config_file]
|
25
24
|
end
|
26
25
|
|
26
|
+
args << "-d #{Clamby.config[:datadir]}" if Clamby.config[:datadir]
|
27
|
+
|
27
28
|
new.run scan_executable, *args
|
28
29
|
|
29
|
-
|
30
|
+
# $CHILD_STATUS maybe nil if the execution itself (not the client process)
|
31
|
+
# fails
|
32
|
+
case $CHILD_STATUS && $CHILD_STATUS.exitstatus
|
30
33
|
when 0
|
31
34
|
return false
|
32
|
-
when 2
|
35
|
+
when nil, 2
|
33
36
|
# clamdscan returns 2 whenever error other than a detection happens
|
34
37
|
if Clamby.config[:error_clamscan_client_error] && Clamby.config[:daemonize]
|
35
38
|
raise Clamby::ClamscanClientError.new("Clamscan client error")
|
36
39
|
end
|
37
|
-
|
40
|
+
|
38
41
|
# returns true to maintain legacy behavior
|
39
42
|
return true
|
40
43
|
else
|
@@ -46,12 +49,14 @@ module Clamby
|
|
46
49
|
|
47
50
|
# Update the virus definitions.
|
48
51
|
def self.freshclam
|
49
|
-
|
52
|
+
args = []
|
53
|
+
args << "--datadir=#{Clamby.config[:datadir]}" if Clamby.config[:datadir]
|
54
|
+
new.run 'freshclam', *args
|
50
55
|
end
|
51
56
|
|
52
57
|
# Show the ClamAV version. Also acts as a quick check if ClamAV functions.
|
53
58
|
def self.clamscan_version
|
54
|
-
new.run
|
59
|
+
new.run scan_executable, '--version'
|
55
60
|
end
|
56
61
|
|
57
62
|
# Run the given commands via a system call.
|
@@ -67,13 +72,14 @@ module Clamby
|
|
67
72
|
self.command = args | default_args
|
68
73
|
self.command = command.sort.unshift(executable_full)
|
69
74
|
|
70
|
-
system(
|
75
|
+
system(self.command.join(' '), system_options)
|
71
76
|
end
|
72
77
|
|
73
78
|
private
|
74
79
|
|
75
80
|
def default_args
|
76
81
|
args = []
|
82
|
+
args << "--config-file=#{Clamby.config[:config_file]}" if Clamby.config[:daemonize] && Clamby.config[:config_file]
|
77
83
|
args << '--quiet' if Clamby.config[:output_level] == 'low'
|
78
84
|
args << '--verbose' if Clamby.config[:output_level] == 'high'
|
79
85
|
args
|
data/lib/clamby/version.rb
CHANGED
data/spec/clamby/command_spec.rb
CHANGED
@@ -34,7 +34,7 @@ describe Clamby::Command do
|
|
34
34
|
|
35
35
|
describe 'passing file descriptor' do
|
36
36
|
it 'does not include fdpass in the command by default' do
|
37
|
-
Clamby.configure
|
37
|
+
Clamby.configure
|
38
38
|
expect(runner).to receive(:run).with('clamscan', good_path, '--no-summary')
|
39
39
|
allow(described_class).to receive(:new).and_return(runner)
|
40
40
|
|
@@ -60,7 +60,7 @@ describe Clamby::Command do
|
|
60
60
|
|
61
61
|
describe 'streaming files to clamd' do
|
62
62
|
it 'does not include stream in the command by default' do
|
63
|
-
Clamby.configure
|
63
|
+
Clamby.configure
|
64
64
|
expect(runner).to receive(:run).with('clamscan', good_path, '--no-summary')
|
65
65
|
allow(described_class).to receive(:new).and_return(runner)
|
66
66
|
|
@@ -86,32 +86,24 @@ describe Clamby::Command do
|
|
86
86
|
|
87
87
|
describe 'specifying config-file' do
|
88
88
|
it 'does not include the parameter in the clamscan command by default' do
|
89
|
-
Clamby.configure
|
90
|
-
expect(runner).to receive(:run).with('clamscan', good_path, '--no-summary')
|
91
|
-
allow(described_class).to receive(:new).and_return(runner)
|
89
|
+
Clamby.configure
|
92
90
|
|
93
|
-
described_class.
|
91
|
+
expect(described_class.new.send(:default_args)).not_to include(a_string_matching(/--config-file/))
|
94
92
|
end
|
95
93
|
it 'does not include the parameter in the clamdscan command by default' do
|
96
|
-
Clamby.configure(daemonize: true
|
97
|
-
expect(runner).to receive(:run).with('clamdscan', good_path, '--no-summary')
|
98
|
-
allow(described_class).to receive(:new).and_return(runner)
|
94
|
+
Clamby.configure(daemonize: true)
|
99
95
|
|
100
|
-
described_class.
|
96
|
+
expect(described_class.new.send(:default_args)).not_to include(a_string_matching(/--config-file/))
|
101
97
|
end
|
102
98
|
it 'omits the parameter when invoking clamscan if it is set' do
|
103
|
-
Clamby.configure(daemonize: false,
|
104
|
-
expect(runner).to receive(:run).with('clamscan', good_path, '--no-summary')
|
105
|
-
allow(described_class).to receive(:new).and_return(runner)
|
99
|
+
Clamby.configure(daemonize: false, config_file: 'clamd.conf')
|
106
100
|
|
107
|
-
described_class.
|
101
|
+
expect(described_class.new.send(:default_args)).not_to include('--config-file=clamd.conf')
|
108
102
|
end
|
109
103
|
it 'passes the parameter when invoking clamdscan if it is set' do
|
110
|
-
Clamby.configure(daemonize: true,
|
111
|
-
expect(runner).to receive(:run).with('clamdscan', good_path, '--no-summary', '--config-file=clamd.conf')
|
112
|
-
allow(described_class).to receive(:new).and_return(runner)
|
104
|
+
Clamby.configure(daemonize: true, config_file: 'clamd.conf')
|
113
105
|
|
114
|
-
described_class.
|
106
|
+
expect(described_class.new.send(:default_args)).to include('--config-file=clamd.conf')
|
115
107
|
end
|
116
108
|
end
|
117
109
|
|
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.
|
4
|
+
version: 1.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kobaltz
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-05 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: '
|
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: '
|
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.
|
@@ -86,7 +100,7 @@ homepage: ''
|
|
86
100
|
licenses:
|
87
101
|
- MIT
|
88
102
|
metadata: {}
|
89
|
-
post_install_message:
|
103
|
+
post_install_message:
|
90
104
|
rdoc_options: []
|
91
105
|
require_paths:
|
92
106
|
- lib
|
@@ -101,9 +115,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
115
|
- !ruby/object:Gem::Version
|
102
116
|
version: '0'
|
103
117
|
requirements: []
|
104
|
-
|
105
|
-
|
106
|
-
signing_key:
|
118
|
+
rubygems_version: 3.0.8
|
119
|
+
signing_key:
|
107
120
|
specification_version: 4
|
108
121
|
summary: Scan file uploads with ClamAV
|
109
122
|
test_files:
|