clamby 1.3.2 → 1.4.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 +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/clamby.rb +19 -5
- data/lib/clamby/exception.rb +2 -1
- data/lib/clamby/version.rb +1 -1
- data/spec/clamby_spec.rb +42 -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: d8a7e48c2bd0285d60fe7ece07fd72bca337e33fefb86d5304b6278132047d44
|
4
|
+
data.tar.gz: d2489bc3655ecf95667fa41f9aa39e104404fb9d0eccbbf5447dd6cd9e78b307
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a505ca85b244f599a0270a9e94e46305b1230fb2502eebbffbc441e86e78d7e668ab534fb39a2f086eb14a330c68706bd15104a387aec2e518108e9e4f912e3
|
7
|
+
data.tar.gz: 2401278d0d3721113268156994ed39eed440619b90f1e25dd42b62db99681eeeaa3aa23c9d5d7c7c59477ccd1875f93192f052a350ea9d83d3836517ec5ff724
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
# v1.4.0
|
2
|
+
- [emilong](https://github.com/kobaltz/clamby/commits/master?author=emilong) added `:error_clamscan_client_error => false` option to prevent error from missing running daemon or clamscan.
|
3
|
+
|
1
4
|
# v1.3.2
|
2
5
|
- [emilong](https://github.com/kobaltz/clamby/commits/master?author=emilong) added `stream` option
|
3
6
|
|
data/lib/clamby.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "English"
|
1
2
|
require "clamby/version"
|
2
3
|
require "clamby/exception"
|
3
4
|
module Clamby
|
@@ -5,6 +6,7 @@ module Clamby
|
|
5
6
|
:check => true,
|
6
7
|
:daemonize => false,
|
7
8
|
:error_clamscan_missing => true,
|
9
|
+
:error_clamscan_client_error => false,
|
8
10
|
:error_file_missing => true,
|
9
11
|
:error_file_virus => false,
|
10
12
|
:fdpass => false,
|
@@ -21,7 +23,7 @@ module Clamby
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def self.safe?(path)
|
24
|
-
value =
|
26
|
+
value = virus?(path)
|
25
27
|
return nil if value.nil?
|
26
28
|
! value
|
27
29
|
end
|
@@ -44,12 +46,24 @@ module Clamby
|
|
44
46
|
def self.virus?(path)
|
45
47
|
return nil unless scanner_exists?
|
46
48
|
return nil unless file_exists?(path)
|
47
|
-
|
49
|
+
system(*system_command(path))
|
48
50
|
|
49
|
-
|
50
|
-
|
51
|
+
case $CHILD_STATUS.exitstatus
|
52
|
+
when 0
|
53
|
+
return false
|
54
|
+
when 2
|
55
|
+
# clamdscan returns 2 whenever error other than a detection happens
|
56
|
+
if @config[:error_clamscan_client_error] && @config[:daemonize]
|
57
|
+
raise Exceptions::ClamscanClientError.new("Clamscan client error")
|
58
|
+
end
|
59
|
+
|
60
|
+
# returns true to maintain legacy behavior
|
61
|
+
return true
|
62
|
+
else
|
63
|
+
return true unless @config[:error_file_virus]
|
51
64
|
|
52
|
-
|
65
|
+
raise Exceptions::VirusDetected.new("VIRUS DETECTED on #{Time.now}: #{path}")
|
66
|
+
end
|
53
67
|
end
|
54
68
|
|
55
69
|
def self.scanner_exists?
|
data/lib/clamby/exception.rb
CHANGED
data/lib/clamby/version.rb
CHANGED
data/spec/clamby_spec.rb
CHANGED
@@ -97,4 +97,46 @@ describe Clamby do
|
|
97
97
|
expect(Clamby.system_command(good_path)).to eq ["clamdscan", "--stream", good_path, "--no-summary"]
|
98
98
|
end
|
99
99
|
end
|
100
|
+
|
101
|
+
context 'error_clamscan_client_error option' do
|
102
|
+
it 'is false by default' do
|
103
|
+
expect(Clamby.config[:error_clamscan_client_error]).to eq false
|
104
|
+
end
|
105
|
+
it 'accepts an error_clamscan_client_error option in the config' do
|
106
|
+
Clamby.configure(error_clamscan_client_error: true)
|
107
|
+
expect(Clamby.config[:error_clamscan_client_error]).to eq true
|
108
|
+
end
|
109
|
+
|
110
|
+
before {
|
111
|
+
Clamby.configure(check: false)
|
112
|
+
allow_any_instance_of(Process::Status).to receive(:exitstatus).and_return(2)
|
113
|
+
allow(Clamby).to receive(:system)
|
114
|
+
}
|
115
|
+
|
116
|
+
context 'when false' do
|
117
|
+
before { Clamby.configure(error_clamscan_client_error: false) }
|
118
|
+
|
119
|
+
it 'virus? returns true when the daemonized client exits with status 2' do
|
120
|
+
Clamby.configure(daemonize: true)
|
121
|
+
expect(Clamby.virus?(good_path)).to eq true
|
122
|
+
end
|
123
|
+
it 'returns true when the client exits with status 2' do
|
124
|
+
Clamby.configure(daemonize: false)
|
125
|
+
expect(Clamby.virus?(good_path)).to eq true
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
context 'when true' do
|
130
|
+
before { Clamby.configure(error_clamscan_client_error: true) }
|
131
|
+
|
132
|
+
it 'virus? raises when the daemonized client exits with status 2' do
|
133
|
+
Clamby.configure(daemonize: true)
|
134
|
+
expect { Clamby.virus?(good_path) }.to raise_error(Exceptions::ClamscanClientError)
|
135
|
+
end
|
136
|
+
it 'returns true when the client exits with status 2' do
|
137
|
+
Clamby.configure(daemonize: false)
|
138
|
+
expect(Clamby.virus?(good_path)).to eq true
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
100
142
|
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.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kobaltz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|