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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f0765081b986a543225746b34463d67904e78d24
4
- data.tar.gz: 02d2787cb4e94a0551a368571429b3ea603b2e73
2
+ SHA256:
3
+ metadata.gz: 9faaee84d1654a9496db2e440016f43d48ac89bced72a9b52fcce5c31740ce6a
4
+ data.tar.gz: 3aeda255bb63e3c1472f3f9f40924b6d0ba1fd27aa13b545e7c3ad530af55ade
5
5
  SHA512:
6
- metadata.gz: 7f0fd0c5d6328d0335990864a2bfa8a7431134b864d6348ccb01d0f7576c0fd64256f0b72e7dd6bbfd766b29cf69a12f948335d1df82f646395a7a20aa879931
7
- data.tar.gz: 1898edd1566913d9a2702a5372adbf8c870d5e20be424c81e362a8708de1280a67132272b871fb0315826bd648d9ec1a57865c9443be384fe7707f4f903324ac
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"
@@ -1,6 +1,12 @@
1
- # Unreleased (3.1.0)
1
+ # Unreleased
2
2
 
3
- # 3.0.1
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 >= 1.9.2
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 )
@@ -3,7 +3,7 @@ $:<< 'lib'
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "clamav-client"
6
- spec.version = "3.1.0"
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", "~> 1.5"
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"
@@ -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
@@ -0,0 +1,6 @@
1
+ #!/bin/bash
2
+ set -ex
3
+
4
+ service clamav-daemon start
5
+
6
+ exec "$@"
@@ -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.1.0
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: 2016-05-13 00:00:00.000000000 Z
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: '1.5'
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: '1.5'
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
- - test/ci-setup.sh
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
- rubyforge_project:
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/ci-setup.sh
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
@@ -1,11 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.3.1
4
- - 2.2.5
5
- - ruby-head
6
- - jruby-head
7
- - rbx
8
- before_install: "sudo ./test/ci-setup.sh"
9
- env:
10
- - CLAMD_UNIX_SOCKET=/var/run/clamav/clamd.ctl
11
- script: rake
@@ -1,7 +0,0 @@
1
- # Update Ubuntu and install ClamAV
2
- apt-get update
3
- apt-get install clamav-daemon clamav-freshclam clamav-unofficial-sigs
4
-
5
- # Update the signature database and start the daemon
6
- freshclam
7
- service clamav-daemon start