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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bc2d255f725e2d898512f707dfe9c6c3d064771d
4
- data.tar.gz: 7d64e8cbb7ecf414827211f863e07b43eb2a65ac
3
+ metadata.gz: 3e9d5666b0aa8c0173ee6cc55ce51ffb7a651080
4
+ data.tar.gz: 4fe92a7a06170042068c2f632b1736877c84b261
5
5
  SHA512:
6
- metadata.gz: 83da29cd8e1bf8361ee4e37796dbcd687ab4eaf8cb12cf16eca3c5a77201de41d228ddc0985737e94947e7a02c7e463cae91d307028c99be518690366abae1a0
7
- data.tar.gz: 970f9ac1d977842b31a2d819a85e34aef0f7b7942a666694753fc33353e590039ee40abc61a2f834b5d4add02e2fa71f9048e9b4a1a794d32c8f4c577c787daf
6
+ metadata.gz: 969f3a0091ac774b8e1f9f52926e7ff59533c8aa68ba0574290e9640d927433228a5d27c13b672ecb4edb35b0252799c52fb63cc08647b20866a99933b49b48e
7
+ data.tar.gz: 0f4cae4fcda52a48c438b0a7ac8720df80fd0add365861f6f7f1ca5d7b2c9ef91fdc17dca78edd5291ba7bf6a5c069ab7a5dea3fe3b840d3193553943887309f
@@ -1,6 +1,6 @@
1
1
  #v1.10
2
2
  - Changed `scan()` to `safe?()`
3
- - Added virus?()
3
+ - Added `virus?()`
4
4
  - Added/Changed `rspec` to accomodate new/changed functionality
5
5
 
6
6
  #v1.0.5
@@ -53,4 +53,4 @@ Clamby.configure({
53
53
  :error_file_virus => false
54
54
  })
55
55
 
56
- ```
56
+ ```
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 `clamscan` and `freshclam` daemons to be installed already.
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.
@@ -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
- if self.scanner_exists?
20
- if file_exists?(path)
21
- scanner = system("clamscan #{path} --no-summary")
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
- if self.scanner_exists?
42
- if file_exists?(path)
43
- scanner = system("clamscan #{path} --no-summary")
44
- if scanner
45
- return false
46
- elsif not scanner
47
- if @config[:error_file_virus]
48
- raise Exceptions::VirusDetected.new("VIRUS DETECTED on #{Time.now}: #{path}")
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
- if @config[:check]
64
- scanner = system('clamscan -V')
65
- if not scanner
66
- if @config[:error_clamscan_missing]
67
- raise Exceptions::ClamscanMissing.new("Clamscan application not found. Check your installation and path.")
68
- else
69
- puts "CLAMSCAN NOT FOUND"
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 File.file?(path)
82
- return true
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
- if @config[:error_file_missing]
85
- raise Exceptions::FileNotFound.new("File not found: #{path}")
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
@@ -1,3 +1,3 @@
1
1
  module Clamby
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -30,7 +30,14 @@ describe Clamby do
30
30
  end
31
31
 
32
32
  it "should scan file as dangerous" do
33
- `wget http://www.eicar.org/download/eicar.com`
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.0
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: 2014-03-11 00:00:00.000000000 Z
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.2.2
100
+ rubygems_version: 2.4.5
101
101
  signing_key:
102
102
  specification_version: 4
103
103
  summary: Scan file uploads with ClamAV