clamby 1.1.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -2
- data/README.md +4 -2
- data/lib/clamby.rb +34 -61
- data/lib/clamby/version.rb +1 -1
- data/spec/clamby_spec.rb +9 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e9d5666b0aa8c0173ee6cc55ce51ffb7a651080
|
4
|
+
data.tar.gz: 4fe92a7a06170042068c2f632b1736877c84b261
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 969f3a0091ac774b8e1f9f52926e7ff59533c8aa68ba0574290e9640d927433228a5d27c13b672ecb4edb35b0252799c52fb63cc08647b20866a99933b49b48e
|
7
|
+
data.tar.gz: 0f4cae4fcda52a48c438b0a7ac8720df80fd0add365861f6f7f1ca5d7b2c9ef91fdc17dca78edd5291ba7bf6a5c069ab7a5dea3fe3b840d3193553943887309f
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
[![Build Status](https://travis-ci.org/kobaltz/clamby.png?branch=master)](https://travis-ci.org/kobaltz/clamby)
|
5
5
|
|
6
6
|
|
7
|
-
This gem depends on the
|
7
|
+
This gem depends on the [clamscan](http://www.clamav.net/) and `freshclam` daemons to be installed already.
|
8
8
|
|
9
9
|
If you have a file upload on your site and you do not scan the files for viruses then you not only compromise your software, but also the users of the software and their files. This gem's function is to simply scan a given file.
|
10
10
|
|
@@ -95,7 +95,7 @@ To update the virus database, open a terminal and enter the following command:
|
|
95
95
|
|
96
96
|
`sudo freshclam`
|
97
97
|
|
98
|
-
To automate this update you can set up a cron job. I'll show how to update the virus database every day at 8:57 PM.
|
98
|
+
To automate this update you can set up a cron job. I'll show how to update the virus database every day at 8:57 PM.
|
99
99
|
|
100
100
|
You need to modify the crontab for the root user.
|
101
101
|
|
@@ -116,3 +116,5 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
116
116
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
117
117
|
|
118
118
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
119
|
+
|
120
|
+
ClamAV is licensed under [GNU GPL](http://www.gnu.org/licenses/gpl.html). The ClamAV software is NOT distributed nor modified with this gem.
|
data/lib/clamby.rb
CHANGED
@@ -4,6 +4,7 @@ module Clamby
|
|
4
4
|
|
5
5
|
@config = {
|
6
6
|
:check => true,
|
7
|
+
:daemonize => false,
|
7
8
|
:error_clamscan_missing => true,
|
8
9
|
:error_file_missing => true,
|
9
10
|
:error_file_virus => false
|
@@ -16,77 +17,41 @@ module Clamby
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def self.safe?(path)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
if scanner
|
23
|
-
return true
|
24
|
-
elsif not scanner
|
25
|
-
if @config[:error_file_virus]
|
26
|
-
raise Exceptions::VirusDetected.new("VIRUS DETECTED on #{Time.now}: #{path}")
|
27
|
-
else
|
28
|
-
puts "VIRUS DETECTED on #{Time.now}: #{path}"
|
29
|
-
return false
|
30
|
-
end
|
31
|
-
end
|
32
|
-
else
|
33
|
-
return nil
|
34
|
-
end
|
35
|
-
else
|
36
|
-
return nil
|
37
|
-
end
|
20
|
+
value = virus?(path)
|
21
|
+
return nil if value.nil?
|
22
|
+
! value
|
38
23
|
end
|
39
24
|
|
40
25
|
def self.virus?(path)
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
else
|
50
|
-
puts "VIRUS DETECTED on #{Time.now}: #{path}"
|
51
|
-
return true
|
52
|
-
end
|
53
|
-
end
|
54
|
-
else
|
55
|
-
return nil
|
56
|
-
end
|
57
|
-
else
|
58
|
-
return nil
|
59
|
-
end
|
26
|
+
return nil unless scanner_exists?
|
27
|
+
return nil unless file_exists?(path)
|
28
|
+
scanner = system("#{clamd_executable_name} #{path} --no-summary")
|
29
|
+
|
30
|
+
return false if scanner
|
31
|
+
return true unless @config[:error_file_virus]
|
32
|
+
|
33
|
+
raise Exceptions::VirusDetected.new("VIRUS DETECTED on #{Time.now}: #{path}")
|
60
34
|
end
|
61
35
|
|
62
36
|
def self.scanner_exists?
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
return false
|
71
|
-
end
|
72
|
-
else
|
73
|
-
return true
|
74
|
-
end
|
75
|
-
else
|
76
|
-
return true
|
77
|
-
end
|
37
|
+
return true unless @config[:check]
|
38
|
+
scanner = system('#{clamd_executable_name} -V')
|
39
|
+
|
40
|
+
return true if scanner
|
41
|
+
return false unless @config[:error_clamdscan_missing]
|
42
|
+
|
43
|
+
raise Exceptions::clamdscanMissing.new("#{clamd_executable_name} application not found. Check your installation and path.")
|
78
44
|
end
|
79
45
|
|
80
46
|
def self.file_exists?(path)
|
81
|
-
if
|
82
|
-
|
47
|
+
return false if path.nil?
|
48
|
+
return true if File.file?(path)
|
49
|
+
|
50
|
+
if @config[:error_file_missing]
|
51
|
+
raise Exceptions::FileNotFound.new("File not found: #{path}")
|
83
52
|
else
|
84
|
-
|
85
|
-
|
86
|
-
else
|
87
|
-
puts "FILE NOT FOUND on #{Time.now}: #{path}"
|
88
|
-
return false
|
89
|
-
end
|
53
|
+
puts "FILE NOT FOUND on #{Time.now}: #{path}"
|
54
|
+
return false
|
90
55
|
end
|
91
56
|
end
|
92
57
|
|
@@ -97,4 +62,12 @@ module Clamby
|
|
97
62
|
def self.config
|
98
63
|
@config
|
99
64
|
end
|
65
|
+
|
66
|
+
def self.clamd_executable_name(daemonize: false)
|
67
|
+
daemonize? ? "clamdscan" : "clamscan"
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.daemonize?
|
71
|
+
!! @config[:daemonize]
|
72
|
+
end
|
100
73
|
end
|
data/lib/clamby/version.rb
CHANGED
data/spec/clamby_spec.rb
CHANGED
@@ -30,7 +30,14 @@ describe Clamby do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should scan file as dangerous" do
|
33
|
-
|
33
|
+
`which wget`
|
34
|
+
|
35
|
+
if $?.success?
|
36
|
+
`wget http://www.eicar.org/download/eicar.com`
|
37
|
+
else
|
38
|
+
`curl http://www.eicar.org/download/eicar.com > eicar.com`
|
39
|
+
end
|
40
|
+
`chmod 644 eicar.com`
|
34
41
|
Clamby.configure({:error_file_virus => true})
|
35
42
|
expect{Clamby.safe?('eicar.com')}.to raise_exception(Exceptions::VirusDetected)
|
36
43
|
expect{Clamby.virus?('eicar.com')}.to raise_exception(Exceptions::VirusDetected)
|
@@ -39,4 +46,4 @@ describe Clamby do
|
|
39
46
|
expect(Clamby.virus?('eicar.com')).to be true
|
40
47
|
File.delete('eicar.com')
|
41
48
|
end
|
42
|
-
end
|
49
|
+
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.1
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kobaltz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
97
|
version: '0'
|
98
98
|
requirements: []
|
99
99
|
rubyforge_project:
|
100
|
-
rubygems_version: 2.
|
100
|
+
rubygems_version: 2.4.5
|
101
101
|
signing_key:
|
102
102
|
specification_version: 4
|
103
103
|
summary: Scan file uploads with ClamAV
|