clamav-client 1.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.
@@ -0,0 +1,32 @@
1
+ # clamav-client - ClamAV client
2
+ # Copyright (C) 2014 Franck Verrot <franck@verrot.fr>
3
+
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ require 'test_helper'
18
+
19
+ describe "ClamAV::Connection" do
20
+ let(:wrapper_mock) { Minitest::Mock.new }
21
+ let(:socket_mock) { Minitest::Mock.new }
22
+
23
+ it "requires a port and a wrapper" do
24
+ assert_raises(ArgumentError) { ClamAV::Connection.new }
25
+ assert_raises(ArgumentError) { ClamAV::Connection.new(port: 'foo') }
26
+ assert_raises(ArgumentError) { ClamAV::Connection.new(wrapper: nil) }
27
+ end
28
+
29
+ it "can be constructed with a port and wrapper class" do
30
+ ClamAV::Connection.new(socket: socket_mock, wrapper: wrapper_mock)
31
+ end
32
+ end
@@ -0,0 +1,38 @@
1
+ # clamav-client - ClamAV client
2
+ # Copyright (C) 2014 Franck Verrot <franck@verrot.fr>
3
+
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ require 'test_helper'
18
+
19
+ describe "NewLineWrapper" do
20
+ let(:wrapper) { ClamAV::Wrappers::NewLineWrapper.new }
21
+
22
+ it "wraps requests" do
23
+ wrapper.wrap_request("foo").must_equal "nfoo\n"
24
+ end
25
+
26
+ it "read responses" do
27
+ # Mock an IO object
28
+ socket_mock = Class.new do
29
+ def getc
30
+ @val ||= "hello\n"
31
+ @val.slice!(0)
32
+ end
33
+ end.new
34
+
35
+ wrapper.read_response(socket_mock).must_equal "hello"
36
+ end
37
+
38
+ end
@@ -0,0 +1,38 @@
1
+ # clamav-client - ClamAV client
2
+ # Copyright (C) 2014 Franck Verrot <franck@verrot.fr>
3
+
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ require 'test_helper'
18
+
19
+ describe "NullTerminationWrapper" do
20
+ let(:wrapper) { ClamAV::Wrappers::NullTerminationWrapper.new }
21
+
22
+ it "wraps requests" do
23
+ wrapper.wrap_request("foo").must_equal "zfoo\0"
24
+ end
25
+
26
+ it "read responses" do
27
+ # Mock an IO object
28
+ socket_mock = Class.new do
29
+ def getc
30
+ @val ||= "hello\0"
31
+ @val.slice!(0)
32
+ end
33
+ end.new
34
+
35
+ wrapper.read_response(socket_mock).must_equal "hello"
36
+ end
37
+
38
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: clamav-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Franck Verrot
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: ClamAV::Client connects to a Clam Anti-Virus clam daemon and send commands.
56
+ email:
57
+ - franck@verrot.fr
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - clamav-client.gemspec
68
+ - lib/clamav/client.rb
69
+ - lib/clamav/commands/command.rb
70
+ - lib/clamav/commands/ping_command.rb
71
+ - lib/clamav/commands/quit_command.rb
72
+ - lib/clamav/commands/scan_command.rb
73
+ - lib/clamav/connection.rb
74
+ - lib/clamav/responses.rb
75
+ - lib/clamav/responses/error_response.rb
76
+ - lib/clamav/responses/success_response.rb
77
+ - lib/clamav/responses/virus_response.rb
78
+ - lib/clamav/util.rb
79
+ - lib/clamav/wrapper.rb
80
+ - lib/clamav/wrappers/new_line_wrapper.rb
81
+ - lib/clamav/wrappers/null_termination_wrapper.rb
82
+ - test/fixtures/clamavtest.gz
83
+ - test/fixtures/clamavtest.txt
84
+ - test/fixtures/clamavtest.zip
85
+ - test/fixtures/innocent.txt
86
+ - test/integration/clamav/client_test.rb
87
+ - test/integration/clamav/util_test.rb
88
+ - test/test_helper.rb
89
+ - test/unit/clamav/client_test.rb
90
+ - test/unit/clamav/commands/ping_command_test.rb
91
+ - test/unit/clamav/commands/scan_command_test.rb
92
+ - test/unit/clamav/connection_test.rb
93
+ - test/unit/clamav/wrappers/new_line_wrapper_test.rb
94
+ - test/unit/clamav/wrappers/null_termination_wrapper_test.rb
95
+ homepage: https://github.com/franckverrot/clamav-client
96
+ licenses:
97
+ - GPLv3
98
+ metadata: {}
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 2.2.0
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: ClamAV::Client connects to a Clam Anti-Virus clam daemon and send commands.
119
+ test_files:
120
+ - test/fixtures/clamavtest.gz
121
+ - test/fixtures/clamavtest.txt
122
+ - test/fixtures/clamavtest.zip
123
+ - test/fixtures/innocent.txt
124
+ - test/integration/clamav/client_test.rb
125
+ - test/integration/clamav/util_test.rb
126
+ - test/test_helper.rb
127
+ - test/unit/clamav/client_test.rb
128
+ - test/unit/clamav/commands/ping_command_test.rb
129
+ - test/unit/clamav/commands/scan_command_test.rb
130
+ - test/unit/clamav/connection_test.rb
131
+ - test/unit/clamav/wrappers/new_line_wrapper_test.rb
132
+ - test/unit/clamav/wrappers/null_termination_wrapper_test.rb