clamby 1.5.0 → 1.5.1
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 +3 -0
- data/README.md +21 -1
- data/lib/clamby.rb +4 -1
- data/lib/clamby/command.rb +8 -3
- data/lib/clamby/version.rb +1 -1
- data/spec/clamby/command_spec.rb +53 -0
- data/spec/clamby_spec.rb +35 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8580f01b4d5f65af4ee327b290e6e17f074fafb351a95a07d079c4eebad54ae1
|
4
|
+
data.tar.gz: 8b0bc003922e5490d24464954cb01a40084aaf3b7344243c9110a3d1811e57db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f7b78e3b031158253bd4cc7809d87a0570710ed7239f3fd837bcab4235baf5bcc182a29fa22669523d037658f2387601973eb36bc6981bc760aeeb03fd392d1
|
7
|
+
data.tar.gz: 56c12c45b4ecc6c9c6162243a8483226213f908d5df10655f409cb106b78881c3f0abfd781f7175757dbc2f50c9abb714952c5085ef420d021f77fe285a29ab3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
# v1.5.1
|
2
|
+
- [ahukkanen](https://github.com/kobaltz/clamby/commits?author=ahukkanen) - Configurable execution paths
|
3
|
+
|
1
4
|
# v1.5.0
|
2
5
|
- Exceptions are now raised under Clamby module - could be breaking change
|
3
6
|
- [szajbus](https://github.com/kobaltz/clamby/commits?author=szajbus) fixed specs! and updated README
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|

|
2
2
|
|
3
3
|
[](https://badge.fury.io/rb/clamby.png)
|
4
|
+
[](https://travis-ci.org/kobaltz/clamby)
|
4
5
|
|
5
6
|
This gem depends on the [clamscan](http://www.clamav.net/) and `freshclam` daemons to be installed already.
|
6
7
|
|
@@ -79,7 +80,10 @@ Configuration is rather limited right now. You can exclude the check if `clamsca
|
|
79
80
|
:error_file_virus => false,
|
80
81
|
:fdpass => false,
|
81
82
|
:stream => false,
|
82
|
-
:output => 'medium' # one of 'off', 'low', 'medium', 'high'
|
83
|
+
:output => 'medium', # one of 'off', 'low', 'medium', 'high'
|
84
|
+
:executable_path_clamscan => 'clamscan',
|
85
|
+
:executable_path_clamdscan => 'clamdscan',
|
86
|
+
:executable_path_freshclam => 'freshclam',
|
83
87
|
})
|
84
88
|
```
|
85
89
|
|
@@ -112,6 +116,22 @@ Setting the `stream` configuration option will stream the file to the daemon. Th
|
|
112
116
|
- *medium*: show errors and briefly what happened _(default)_
|
113
117
|
- *high*: as verbose as possible
|
114
118
|
|
119
|
+
#### Executable paths
|
120
|
+
|
121
|
+
Setting any of the executable paths makes Clamby to use those paths instead of
|
122
|
+
the defaults for the system calls. The default configuration for these should be
|
123
|
+
perfectly fine for most use cases but it may be required to configure custom
|
124
|
+
paths in case ClamAV is manually installed to a custom location.
|
125
|
+
|
126
|
+
In order to configure the paths, use the following configuration options:
|
127
|
+
|
128
|
+
- *executable_path_clamscan*: defines the executable path for the `clamscan`
|
129
|
+
executable, defaults to `clamscan`
|
130
|
+
- *executable_path_clamdscan*: defines the executable path for the `clamdscan`
|
131
|
+
executable, defaults to `clamdscan`
|
132
|
+
- *executable_path_freshclam*: defines the executable path for the `freshclam`
|
133
|
+
executable, defaults to `freshclam`
|
134
|
+
|
115
135
|
# Dependencies
|
116
136
|
|
117
137
|
***Ubuntu***
|
data/lib/clamby.rb
CHANGED
@@ -14,7 +14,10 @@ module Clamby
|
|
14
14
|
:error_file_virus => false,
|
15
15
|
:fdpass => false,
|
16
16
|
:stream => false,
|
17
|
-
:output_level => 'medium'
|
17
|
+
:output_level => 'medium',
|
18
|
+
:executable_path_clamscan => 'clamscan',
|
19
|
+
:executable_path_clamdscan => 'clamdscan',
|
20
|
+
:executable_path_freshclam => 'freshclam',
|
18
21
|
}.freeze
|
19
22
|
|
20
23
|
@config = DEFAULT_CONFIG.dup
|
data/lib/clamby/command.rb
CHANGED
@@ -21,7 +21,7 @@ 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]
|
24
|
+
args << "--config-file=#{Clamby.config[:config_file]}" if Clamby.config[:config_file]
|
25
25
|
end
|
26
26
|
|
27
27
|
new.run scan_executable, *args
|
@@ -63,9 +63,9 @@ module Clamby
|
|
63
63
|
# run('clamscan', file, '--verbose')
|
64
64
|
# run('clamscan', '-V')
|
65
65
|
def run(executable, *args)
|
66
|
-
|
66
|
+
executable_full = executable_path(executable)
|
67
67
|
self.command = args | default_args
|
68
|
-
self.command = command.sort.unshift(
|
68
|
+
self.command = command.sort.unshift(executable_full)
|
69
69
|
|
70
70
|
system(*self.command, system_options)
|
71
71
|
end
|
@@ -88,6 +88,11 @@ module Clamby
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
+
def executable_path(executable)
|
92
|
+
raise "`#{executable}` is not permitted" unless EXECUTABLES.include?(executable)
|
93
|
+
Clamby.config[:"executable_path_#{executable}"]
|
94
|
+
end
|
95
|
+
|
91
96
|
def self.file_exists?(path)
|
92
97
|
return true if File.file?(path)
|
93
98
|
|
data/lib/clamby/version.rb
CHANGED
data/spec/clamby/command_spec.rb
CHANGED
@@ -114,5 +114,58 @@ describe Clamby::Command do
|
|
114
114
|
described_class.scan(good_path)
|
115
115
|
end
|
116
116
|
end
|
117
|
+
|
118
|
+
describe 'specifying custom executable paths' do
|
119
|
+
let(:runner) { described_class.new }
|
120
|
+
let(:custom_path) { '/custom/path' }
|
121
|
+
|
122
|
+
before do
|
123
|
+
Clamby.configure(
|
124
|
+
executable_path_clamscan: "#{custom_path}/clamscan",
|
125
|
+
executable_path_clamdscan: "#{custom_path}/clamdscan",
|
126
|
+
executable_path_freshclam: "#{custom_path}/freshclam",
|
127
|
+
)
|
128
|
+
allow(described_class).to receive(:new).and_return(runner)
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'executes the freshclam executable from the custom path' do
|
132
|
+
expect(runner).to receive(:system).with(
|
133
|
+
"#{custom_path}/freshclam",
|
134
|
+
{}
|
135
|
+
) { system("exit 0", out: File::NULL) }
|
136
|
+
|
137
|
+
described_class.freshclam
|
138
|
+
end
|
139
|
+
|
140
|
+
context 'when not set with daemonize' do
|
141
|
+
before { Clamby.configure(daemonize: false) }
|
142
|
+
|
143
|
+
it 'executes the clamscan executable from the custom path' do
|
144
|
+
expect(runner).to receive(:system).with(
|
145
|
+
"#{custom_path}/clamscan",
|
146
|
+
'--no-summary',
|
147
|
+
good_path,
|
148
|
+
{}
|
149
|
+
) { system("exit 0", out: File::NULL) }
|
150
|
+
|
151
|
+
described_class.scan(good_path)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
context 'when set with daemonize' do
|
156
|
+
before { Clamby.configure(daemonize: true) }
|
157
|
+
|
158
|
+
it 'executes the clamdscan executable from the custom path' do
|
159
|
+
expect(runner).to receive(:system).with(
|
160
|
+
"#{custom_path}/clamdscan",
|
161
|
+
'--no-summary',
|
162
|
+
good_path,
|
163
|
+
{}
|
164
|
+
) { system("exit 0", out: File::NULL) }
|
165
|
+
|
166
|
+
described_class.scan(good_path)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
117
170
|
end
|
118
171
|
end
|
data/spec/clamby_spec.rb
CHANGED
@@ -107,4 +107,39 @@ describe Clamby do
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
110
|
+
|
111
|
+
context 'executable paths' do
|
112
|
+
context 'executable_path_clamscan option' do
|
113
|
+
it 'is clamscan by default' do
|
114
|
+
expect(Clamby.config[:executable_path_clamscan]).to eq 'clamscan'
|
115
|
+
end
|
116
|
+
it 'accepts an executable_path_clamscan option in the config' do
|
117
|
+
path = '/custom/path/clamscan'
|
118
|
+
Clamby.configure(executable_path_clamscan: path)
|
119
|
+
expect(Clamby.config[:executable_path_clamscan]).to eq path
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context 'executable_path_clamdscan option' do
|
124
|
+
it 'is clamdscan by default' do
|
125
|
+
expect(Clamby.config[:executable_path_clamdscan]).to eq 'clamdscan'
|
126
|
+
end
|
127
|
+
it 'accepts an executable_path_clamdscan option in the config' do
|
128
|
+
path = '/custom/path/clamdscan'
|
129
|
+
Clamby.configure(executable_path_clamdscan: path)
|
130
|
+
expect(Clamby.config[:executable_path_clamdscan]).to eq path
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
context 'executable_path_freshclam option' do
|
135
|
+
it 'is freshclam by default' do
|
136
|
+
expect(Clamby.config[:executable_path_freshclam]).to eq 'freshclam'
|
137
|
+
end
|
138
|
+
it 'accepts an executable_path_freshclam option in the config' do
|
139
|
+
path = '/custom/path/freshclam'
|
140
|
+
Clamby.configure(executable_path_freshclam: path)
|
141
|
+
expect(Clamby.config[:executable_path_freshclam]).to eq path
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
110
145
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clamby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kobaltz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|