clamby 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14e5489bd2c961059e2642dfcd7e472a838c449d114ba7ce7849eb4a7d8a2ae9
4
- data.tar.gz: a0e7743a75f54442325af1773d923eb3ead7342efb6fd147733020c2ad85551b
3
+ metadata.gz: 8580f01b4d5f65af4ee327b290e6e17f074fafb351a95a07d079c4eebad54ae1
4
+ data.tar.gz: 8b0bc003922e5490d24464954cb01a40084aaf3b7344243c9110a3d1811e57db
5
5
  SHA512:
6
- metadata.gz: ec80ea427e309f396664d599e28e742ddbf1913f1f4c5a58e3be43557bd9ad0f85276827e58511d2132ce4c89e6ab577082d0e7dcc471dfea92cf3c08b448e44
7
- data.tar.gz: '079f33a665afff1f99e6df4e8c6c7be877b5bade43d8d2fc4270976b77de7b84fc2cdeec8f1791c19b8c79b8ac921cd90e6974a448af0db6c96a2bac28601654'
6
+ metadata.gz: 6f7b78e3b031158253bd4cc7809d87a0570710ed7239f3fd837bcab4235baf5bcc182a29fa22669523d037658f2387601973eb36bc6981bc760aeeb03fd392d1
7
+ data.tar.gz: 56c12c45b4ecc6c9c6162243a8483226213f908d5df10655f409cb106b78881c3f0abfd781f7175757dbc2f50c9abb714952c5085ef420d021f77fe285a29ab3
@@ -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
  ![Clamby Logo](https://raw.github.com/kobaltz/clamby/master/clamby_logo.png)
2
2
 
3
3
  [![GemVersion](https://badge.fury.io/rb/clamby.png)](https://badge.fury.io/rb/clamby.png)
4
+ [![Build Status](https://travis-ci.org/kobaltz/clamby.svg?branch=master)](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***
@@ -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
@@ -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] && Clamby.config[:daemonize]
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
- raise "`#{executable}` is not permitted" unless EXECUTABLES.include?(executable)
66
+ executable_full = executable_path(executable)
67
67
  self.command = args | default_args
68
- self.command = command.sort.unshift(executable)
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
 
@@ -1,3 +1,3 @@
1
1
  module Clamby
2
- VERSION = "1.5.0"
2
+ VERSION = "1.5.1"
3
3
  end
@@ -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
@@ -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.0
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-15 00:00:00.000000000 Z
11
+ date: 2018-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler