clamav-client 3.1.0 → 3.2.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 +5 -5
- data/.circleci/config.yml +44 -0
- data/ChangeLog.md +8 -2
- data/README.md +5 -1
- data/clamav-client.gemspec +2 -2
- data/lib/clamav/client.rb +19 -0
- data/start.sh +6 -0
- data/test/Dockerfile +16 -0
- data/test/integration/clamav/client_test.rb +41 -1
- metadata +11 -11
- data/.travis.yml +0 -11
- data/test/ci-setup.sh +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9faaee84d1654a9496db2e440016f43d48ac89bced72a9b52fcce5c31740ce6a
|
4
|
+
data.tar.gz: 3aeda255bb63e3c1472f3f9f40924b6d0ba1fd27aa13b545e7c3ad530af55ade
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a75c056a1546df14e3ef2d74f4c7d8ad4f6a31aa573f5da24ff5042bb783cf398ddd8918ab3e946310084eec094dc8bf4aae11b46817f0b1c3780b65875f2a0
|
7
|
+
data.tar.gz: d50abc42b02b48e654ada918bcfba393c5f8d881365a0e2f92b256a3c8b50fea8a20e5c05c081910f41fba83ed4bcc0d05397edde8bff84bcbd03f55a76f20d4
|
@@ -0,0 +1,44 @@
|
|
1
|
+
version: 2
|
2
|
+
|
3
|
+
shared: &shared
|
4
|
+
working_directory: ~/repo
|
5
|
+
docker:
|
6
|
+
- image: docker:18.09.2
|
7
|
+
steps:
|
8
|
+
- checkout
|
9
|
+
- setup_remote_docker
|
10
|
+
- run:
|
11
|
+
name: build image
|
12
|
+
command: |
|
13
|
+
docker build -f test/Dockerfile --build-arg RUBY_VERSION -t franckverrot/clamav-client .
|
14
|
+
- run:
|
15
|
+
name: run tests
|
16
|
+
command: |
|
17
|
+
docker run franckverrot/clamav-client rake
|
18
|
+
|
19
|
+
jobs:
|
20
|
+
"2.4":
|
21
|
+
<<: *shared
|
22
|
+
environment:
|
23
|
+
RUBY_VERSION=2.4-stretch
|
24
|
+
"2.5":
|
25
|
+
<<: *shared
|
26
|
+
environment:
|
27
|
+
RUBY_VERSION=2.5-stretch
|
28
|
+
"2.6":
|
29
|
+
<<: *shared
|
30
|
+
environment:
|
31
|
+
RUBY_VERSION=2.6-stretch
|
32
|
+
"2.7":
|
33
|
+
<<: *shared
|
34
|
+
environment:
|
35
|
+
RUBY_VERSION=2.7-slim
|
36
|
+
|
37
|
+
workflows:
|
38
|
+
version: 2
|
39
|
+
build:
|
40
|
+
jobs:
|
41
|
+
- "2.4"
|
42
|
+
- "2.5"
|
43
|
+
- "2.6"
|
44
|
+
- "2.7"
|
data/ChangeLog.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
-
# Unreleased
|
1
|
+
# Unreleased
|
2
2
|
|
3
|
-
# 3.0
|
3
|
+
# 3.2.0
|
4
|
+
|
5
|
+
* Add `ClamAV::Client#ping` as a short-hand for executing a ping
|
6
|
+
* Add `ClamAV::Client#safe?` as a way to check both streams and files
|
7
|
+
* Add support for Ruby 2.7
|
8
|
+
|
9
|
+
# 3.1.0
|
4
10
|
|
5
11
|
* Drop support for old Rubies (prior to 2.2)
|
6
12
|
* Drop fixtures from the gem
|
data/README.md
CHANGED
@@ -45,7 +45,7 @@ Under RedHat/CentOS the UNIX Socket, located at `/var/run/clamav/clamd.sock`
|
|
45
45
|
|
46
46
|
## Requirements
|
47
47
|
|
48
|
-
* Ruby >=
|
48
|
+
* Ruby >= 2.4
|
49
49
|
* clamd
|
50
50
|
|
51
51
|
## Usage
|
@@ -190,6 +190,10 @@ client = ClamAV::Client.new(connection)
|
|
190
190
|
|
191
191
|
Sets the host and port of the ClamAV daemon.
|
192
192
|
|
193
|
+
## Licensing
|
194
|
+
|
195
|
+
GPLv3. COMMERCIAL license available upon request.
|
196
|
+
|
193
197
|
## Contributing
|
194
198
|
|
195
199
|
1. Fork it ( https://github.com/franckverrot/clamav-client/fork )
|
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 = "3.
|
6
|
+
spec.version = "3.2.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.}
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
|
-
spec.add_development_dependency "bundler"
|
19
|
+
spec.add_development_dependency "bundler"
|
20
20
|
spec.add_development_dependency "rake"
|
21
21
|
spec.add_development_dependency "pry"
|
22
22
|
spec.add_development_dependency "minitest"
|
data/lib/clamav/client.rb
CHANGED
@@ -49,5 +49,24 @@ module ClamAV
|
|
49
49
|
::UNIXSocket.new(unix_socket || '/var/run/clamav/clamd.ctl')
|
50
50
|
end
|
51
51
|
end
|
52
|
+
|
53
|
+
def ping
|
54
|
+
execute Commands::PingCommand.new
|
55
|
+
end
|
56
|
+
|
57
|
+
def safe?(target)
|
58
|
+
return instream(target).virus_name.nil? if target.is_a?(StringIO)
|
59
|
+
scan(target).all? { |file| file.virus_name.nil? }
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def instream(io)
|
65
|
+
execute Commands::InstreamCommand.new(io)
|
66
|
+
end
|
67
|
+
|
68
|
+
def scan(file_path)
|
69
|
+
execute Commands::ScanCommand.new(file_path)
|
70
|
+
end
|
52
71
|
end
|
53
72
|
end
|
data/start.sh
ADDED
data/test/Dockerfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
ARG RUBY_VERSION
|
2
|
+
FROM ruby:${RUBY_VERSION}
|
3
|
+
LABEL maintainer="franck@verrot.fr"
|
4
|
+
|
5
|
+
WORKDIR /clamav-client
|
6
|
+
ADD Gemfile /clamav-client
|
7
|
+
ADD clamav-client.gemspec /clamav-client
|
8
|
+
|
9
|
+
RUN apt-get update -qq && \
|
10
|
+
apt-get install -y clamav-daemon clamav-freshclam clamav-unofficial-sigs && \
|
11
|
+
freshclam && \
|
12
|
+
bundle
|
13
|
+
|
14
|
+
ENTRYPOINT ["./start.sh"]
|
15
|
+
|
16
|
+
ADD . /clamav-client
|
@@ -37,13 +37,17 @@ describe "ClamAV::Client Integration Tests" do
|
|
37
37
|
assert client.execute(ping_command)
|
38
38
|
assert client.execute(ping_command)
|
39
39
|
end
|
40
|
+
|
41
|
+
it "can be used as #ping" do
|
42
|
+
assert_equal client.execute(ping_command), client.ping
|
43
|
+
end
|
40
44
|
end
|
41
45
|
|
42
46
|
describe "scan" do
|
43
47
|
let(:base_path) { File.expand_path('../../../../', __FILE__) }
|
48
|
+
let(:dir) { File.join(base_path, 'test/fixtures') }
|
44
49
|
|
45
50
|
it "can be started" do
|
46
|
-
dir = File.join(base_path, 'test/fixtures')
|
47
51
|
results = client.execute(ClamAV::Commands::ScanCommand.new(dir))
|
48
52
|
|
49
53
|
expected_results = {
|
@@ -58,6 +62,10 @@ describe "ClamAV::Client Integration Tests" do
|
|
58
62
|
assert_equal expected_result, result.class
|
59
63
|
end
|
60
64
|
end
|
65
|
+
|
66
|
+
it "can be used as #scan" do
|
67
|
+
assert_equal client.execute(ClamAV::Commands::ScanCommand.new(dir)), client.send(:scan, dir)
|
68
|
+
end
|
61
69
|
end
|
62
70
|
|
63
71
|
describe "instream" do
|
@@ -73,10 +81,42 @@ describe "ClamAV::Client Integration Tests" do
|
|
73
81
|
client.execute(command).must_equal ClamAV::VirusResponse.new("stream", "ClamAV-Test-Signature")
|
74
82
|
end
|
75
83
|
|
84
|
+
it "can be used as #instream" do
|
85
|
+
io = File.open(File.join(dir, 'innocent.txt'))
|
86
|
+
assert_equal client.execute(ClamAV::Commands::InstreamCommand.new(io)), client.send(:instream, io)
|
87
|
+
end
|
88
|
+
|
76
89
|
def build_command_for_file(file)
|
77
90
|
io = File.open(File.join(dir, file))
|
78
91
|
ClamAV::Commands::InstreamCommand.new(io)
|
79
92
|
end
|
80
93
|
end
|
94
|
+
|
95
|
+
describe 'safe?' do
|
96
|
+
let(:dir) { File.expand_path('../../../../test/fixtures', __FILE__) }
|
97
|
+
|
98
|
+
it 'returns true if the given io is safe' do
|
99
|
+
io = build_io_obj('innocent.txt')
|
100
|
+
assert client.safe?(io)
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'returns false if the given io is infected' do
|
104
|
+
io = build_io_obj('clamavtest.txt')
|
105
|
+
refute client.safe?(io)
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'returns false if there is any infected file in the given files' do
|
109
|
+
refute client.safe?(dir)
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'returns true if all the give file is safe' do
|
113
|
+
assert client.safe?("#{dir}/innocent.txt")
|
114
|
+
end
|
115
|
+
|
116
|
+
def build_io_obj(file)
|
117
|
+
content = File.read(File.join(dir, file))
|
118
|
+
io = StringIO.new(content)
|
119
|
+
end
|
120
|
+
end
|
81
121
|
end
|
82
122
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clamav-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.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:
|
11
|
+
date: 2020-02-14 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
|
@@ -73,8 +73,8 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- ".circleci/config.yml"
|
76
77
|
- ".gitignore"
|
77
|
-
- ".travis.yml"
|
78
78
|
- ChangeLog.md
|
79
79
|
- Gemfile
|
80
80
|
- LICENSE.txt
|
@@ -96,7 +96,8 @@ files:
|
|
96
96
|
- lib/clamav/wrapper.rb
|
97
97
|
- lib/clamav/wrappers/new_line_wrapper.rb
|
98
98
|
- lib/clamav/wrappers/null_termination_wrapper.rb
|
99
|
-
-
|
99
|
+
- start.sh
|
100
|
+
- test/Dockerfile
|
100
101
|
- test/integration/clamav/client_test.rb
|
101
102
|
- test/integration/clamav/util_test.rb
|
102
103
|
- test/test_helper.rb
|
@@ -126,13 +127,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
127
|
- !ruby/object:Gem::Version
|
127
128
|
version: '0'
|
128
129
|
requirements: []
|
129
|
-
|
130
|
-
rubygems_version: 2.6.4
|
130
|
+
rubygems_version: 3.0.2
|
131
131
|
signing_key:
|
132
132
|
specification_version: 4
|
133
133
|
summary: ClamAV::Client connects to a Clam Anti-Virus clam daemon and send commands.
|
134
134
|
test_files:
|
135
|
-
- test/
|
135
|
+
- test/Dockerfile
|
136
136
|
- test/integration/clamav/client_test.rb
|
137
137
|
- test/integration/clamav/util_test.rb
|
138
138
|
- test/test_helper.rb
|
data/.travis.yml
DELETED