clamav-client 2.0.1 → 3.0.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/.travis.yml +4 -1
- data/ChangeLog.md +34 -0
- data/README.md +29 -0
- data/clamav-client.gemspec +1 -1
- data/lib/clamav/commands/command.rb +7 -11
- data/lib/clamav/responses.rb +3 -7
- data/lib/clamav/responses/error_response.rb +5 -0
- data/lib/clamav/responses/success_response.rb +5 -0
- data/lib/clamav/responses/virus_response.rb +6 -0
- data/test/ci-setup.sh +7 -0
- data/test/integration/clamav/client_test.rb +29 -19
- data/test/integration/clamav/util_test.rb +12 -5
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11dfc16043cb078ca8546e7d1c6a8b3a8566998d
|
4
|
+
data.tar.gz: 36153ccbb6af07644a62fe8bc3bed19a45bb0c65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 412d152f55ad56fd5dc93845a2e2706550248324462f752de4e2f0c3c709830d5285dbbb66d6282f9d2d4da37d5c4ee6a1e21481800440891164218da97fbd6c
|
7
|
+
data.tar.gz: c73336041272d4f4608dc649b5d82c1e4ce9f2c06cb582e870754b9b5ad912e0f87447c88a08872d9259b6678497763c172b9a69eca5dcbdf4573684fb7f0023
|
data/.travis.yml
CHANGED
data/ChangeLog.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Unreleased (3.0.0)
|
2
|
+
|
3
|
+
* README: Added instructions to install ClamAV on Ubuntu, RedHat and CentOS
|
4
|
+
* INSTREAM: fixed a problem parsing the "FOUND" response
|
5
|
+
* VirusReponse: The virus file name is now held by the VirusReponse object
|
6
|
+
|
7
|
+
|
8
|
+
# 2.0.1
|
9
|
+
|
10
|
+
* README.md : ClamAV's setup notes
|
11
|
+
* clamav-client.gemspec : Upgrade gem after yanking it on RG
|
12
|
+
|
13
|
+
# 2.0.0
|
14
|
+
|
15
|
+
* lib/clamav/commands/instream_command: Support of INSTREAM
|
16
|
+
* lib/clamav/responses.rb : Change insufficient comparison
|
17
|
+
* README.md: Now backward-compatible back to Ruby 1.9.2
|
18
|
+
* lib/clamav/client.rb : Configure with constants
|
19
|
+
* CLAMD_UNIX_SOCKET
|
20
|
+
* CLAMD_TCP_HOST
|
21
|
+
* CLAMD_TCP_PORT
|
22
|
+
* clamav-client.gemspec : Add the minitest gem for older Rubies
|
23
|
+
* .travis.yml : New test script. Add support for more Rubies
|
24
|
+
* lib/clamav/connection : remove keyword arguments
|
25
|
+
* travis.yml : Add basic configuration
|
26
|
+
* lib/clamav/wrapper.rb : Host common code
|
27
|
+
* lib/clamav/commands/command : Remove dead code
|
28
|
+
* Code format consistency.
|
29
|
+
* Explicit #call() to better document usage.
|
30
|
+
* Code typos; Ruby highlighting; wording.
|
31
|
+
|
32
|
+
# 1.0.0
|
33
|
+
|
34
|
+
* Initial release
|
data/README.md
CHANGED
@@ -20,6 +20,29 @@ Alternatively, you can spawn a `pry` console right away by just running:
|
|
20
20
|
|
21
21
|
$ rake console
|
22
22
|
|
23
|
+
### Installing ClamAV's daemon
|
24
|
+
|
25
|
+
#### On OSX
|
26
|
+
|
27
|
+
If you are using brew, just run
|
28
|
+
|
29
|
+
```shell
|
30
|
+
brew install clamav
|
31
|
+
```
|
32
|
+
#### On Linux (Ubuntu)
|
33
|
+
```shell
|
34
|
+
sudo apt-get install clamav-daemon clamav-freshclam clamav-unofficial-sigs
|
35
|
+
sudo freshclam
|
36
|
+
sudo service clamav-daemon start
|
37
|
+
```
|
38
|
+
#### On Linux (RedHat, CentOS)
|
39
|
+
```shell
|
40
|
+
sudo yum install clamd clamav clamav-db
|
41
|
+
sudo freshclam
|
42
|
+
sudo service clamd start
|
43
|
+
```
|
44
|
+
Under RedHat/CentOS the UNIX Socket, located at `/var/run/clamav/clamd.sock`
|
45
|
+
|
23
46
|
## Requirements
|
24
47
|
|
25
48
|
* Ruby >= 1.9.2
|
@@ -157,6 +180,12 @@ over the `CLAMD_UNIX_SOCKET`.
|
|
157
180
|
|
158
181
|
Sets the socket path of the ClamAV daemon.
|
159
182
|
|
183
|
+
Under RedHat/CentOS this can either be set via an environment variable (above) or in the ClamAV::Connection call
|
184
|
+
```
|
185
|
+
connection = ClamAV::Connection.new(socket: ::UNIXSocket.new('/var/run/clamav/clamd.sock'), wrapper: ::ClamAV::Wrappers::NewLineWrapper.new)
|
186
|
+
client = ClamAV::Client.new(connection)
|
187
|
+
```
|
188
|
+
|
160
189
|
#### CLAMD_TCP_HOST and CLAMD_TCP_PORT
|
161
190
|
|
162
191
|
Sets the host and port of the ClamAV daemon.
|
data/clamav-client.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:<< 'lib'
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = "clamav-client"
|
6
|
-
spec.version = "
|
6
|
+
spec.version = "3.0.0"
|
7
7
|
spec.authors = ["Franck Verrot"]
|
8
8
|
spec.email = ["franck@verrot.fr"]
|
9
9
|
spec.summary = %q{ClamAV::Client connects to a Clam Anti-Virus clam daemon and send commands.}
|
@@ -21,23 +21,19 @@ require 'clamav/responses/virus_response'
|
|
21
21
|
module ClamAV
|
22
22
|
module Commands
|
23
23
|
class Command
|
24
|
-
Statuses = {
|
25
|
-
'OK' => ClamAV::SuccessResponse,
|
26
|
-
'ERROR' => ClamAV::ErrorResponse,
|
27
|
-
'ClamAV-Test-Signature FOUND' => ClamAV::VirusResponse
|
28
|
-
}
|
29
24
|
|
30
25
|
def call; raise NotImplementedError.new; end
|
31
26
|
|
32
27
|
protected
|
33
28
|
|
29
|
+
# OK response looks like "1: stream: OK" or "1: /tmp/NOT_A_VIRUS.TXT: OK"
|
30
|
+
# FOUND response looks like "1: stream: Eicar-Test-Signature FOUND" or "1: /tmp/EICAR.COM: Eicar-Test-Signature FOUND"
|
34
31
|
def get_status_from_response(str)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
Statuses[status].new(filepath)
|
32
|
+
/^(?<id>\d+): (?<filepath>.*): (?<virus_name>.*)\s?(?<status>(OK|FOUND))$/ =~ str
|
33
|
+
case status
|
34
|
+
when 'OK' then ClamAV::SuccessResponse.new(filepath)
|
35
|
+
when 'FOUND' then ClamAV::VirusResponse.new(filepath, virus_name.strip)
|
36
|
+
else ClamAV::ErrorResponse.new(str)
|
41
37
|
end
|
42
38
|
end
|
43
39
|
|
data/lib/clamav/responses.rb
CHANGED
@@ -16,17 +16,13 @@
|
|
16
16
|
|
17
17
|
module ClamAV
|
18
18
|
class Response
|
19
|
-
def initialize(file)
|
20
|
-
@file = file
|
21
|
-
end
|
22
19
|
|
20
|
+
attr_reader :file, :virus_name, :error_str
|
21
|
+
|
22
|
+
# Not sure if this is still required?
|
23
23
|
def ==(other)
|
24
24
|
@file == other.file && self.class == other.class
|
25
25
|
end
|
26
26
|
|
27
|
-
protected
|
28
|
-
|
29
|
-
attr_reader :file
|
30
|
-
|
31
27
|
end
|
32
28
|
end
|
data/test/ci-setup.sh
ADDED
@@ -40,32 +40,42 @@ describe "ClamAV::Client Integration Tests" do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
describe "scan" do
|
43
|
+
let(:base_path) { File.expand_path('../../../../', __FILE__) }
|
44
|
+
|
43
45
|
it "can be started" do
|
44
|
-
dir = File.
|
46
|
+
dir = File.join(base_path, 'test/fixtures')
|
45
47
|
results = client.execute(ClamAV::Commands::ScanCommand.new(dir))
|
46
48
|
|
47
|
-
expected_results =
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
expected_results = {
|
50
|
+
"#{base_path}/test/fixtures/clamavtest.gz" => ClamAV::VirusResponse,
|
51
|
+
"#{base_path}/test/fixtures/clamavtest.txt" => ClamAV::VirusResponse,
|
52
|
+
"#{base_path}/test/fixtures/clamavtest.zip" => ClamAV::VirusResponse,
|
53
|
+
"#{base_path}/test/fixtures/innocent.txt" => ClamAV::SuccessResponse
|
54
|
+
}
|
55
|
+
|
56
|
+
results.each do |result|
|
57
|
+
expected_result = expected_results[result.file]
|
58
|
+
assert_equal expected_result, result.class
|
59
|
+
end
|
54
60
|
end
|
55
61
|
end
|
56
62
|
|
57
63
|
describe "instream" do
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
let(:dir) { File.expand_path('../../../../test/fixtures', __FILE__) }
|
65
|
+
|
66
|
+
it "can recognize a sane file" do
|
67
|
+
command = build_command_for_file('innocent.txt')
|
68
|
+
client.execute(command).must_equal ClamAV::SuccessResponse.new("stream")
|
69
|
+
end
|
70
|
+
|
71
|
+
it "can recognize an infected file" do
|
72
|
+
command = build_command_for_file('clamavtest.txt')
|
73
|
+
client.execute(command).must_equal ClamAV::VirusResponse.new("stream", "ClamAV-Test-Signature")
|
74
|
+
end
|
75
|
+
|
76
|
+
def build_command_for_file(file)
|
77
|
+
io = File.open(File.join(dir, file))
|
78
|
+
ClamAV::Commands::InstreamCommand.new(io)
|
69
79
|
end
|
70
80
|
end
|
71
81
|
end
|
@@ -19,15 +19,22 @@ describe "ClamAV::Client Integration Tests" do
|
|
19
19
|
describe "Util" do
|
20
20
|
describe "absolute_path" do
|
21
21
|
it "transforms a single file to an array of one element" do
|
22
|
-
|
22
|
+
expected_path = File.absolute_path(__FILE__)
|
23
|
+
actual_path = ClamAV::Util.path_to_files(__FILE__).first
|
24
|
+
assert_equal expected_path, actual_path
|
23
25
|
end
|
24
26
|
|
25
27
|
it "transforms a directory to an array of N element" do
|
26
28
|
files = %w(
|
27
|
-
|
28
|
-
|
29
|
-
)
|
30
|
-
|
29
|
+
clamav-client/test/integration/clamav/client_test.rb
|
30
|
+
clamav-client/test/integration/clamav/util_test.rb
|
31
|
+
).sort
|
32
|
+
actual_files = ClamAV::Util.path_to_files(File.dirname(__FILE__)).sort
|
33
|
+
|
34
|
+
files.each_with_index do |file, index|
|
35
|
+
path = Regexp.new(".*/#{file}")
|
36
|
+
assert path.match(actual_files[index])
|
37
|
+
end
|
31
38
|
end
|
32
39
|
end
|
33
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clamav-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Franck Verrot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -75,6 +75,7 @@ extra_rdoc_files: []
|
|
75
75
|
files:
|
76
76
|
- ".gitignore"
|
77
77
|
- ".travis.yml"
|
78
|
+
- ChangeLog.md
|
78
79
|
- Gemfile
|
79
80
|
- LICENSE.txt
|
80
81
|
- README.md
|
@@ -95,6 +96,7 @@ files:
|
|
95
96
|
- lib/clamav/wrapper.rb
|
96
97
|
- lib/clamav/wrappers/new_line_wrapper.rb
|
97
98
|
- lib/clamav/wrappers/null_termination_wrapper.rb
|
99
|
+
- test/ci-setup.sh
|
98
100
|
- test/fixtures/clamavtest.gz
|
99
101
|
- test/fixtures/clamavtest.txt
|
100
102
|
- test/fixtures/clamavtest.zip
|
@@ -134,6 +136,7 @@ signing_key:
|
|
134
136
|
specification_version: 4
|
135
137
|
summary: ClamAV::Client connects to a Clam Anti-Virus clam daemon and send commands.
|
136
138
|
test_files:
|
139
|
+
- test/ci-setup.sh
|
137
140
|
- test/fixtures/clamavtest.gz
|
138
141
|
- test/fixtures/clamavtest.txt
|
139
142
|
- test/fixtures/clamavtest.zip
|