clamby 1.0.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +15 -0
- data/CHANGELOG.md +5 -0
- data/README.md +17 -2
- data/Rakefile +5 -0
- data/lib/clamby.rb +22 -2
- data/lib/clamby/version.rb +1 -1
- data/spec/.DS_Store +0 -0
- data/spec/clamby_spec.rb +8 -4
- metadata +4 -3
- data/spec/.travis.yml +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc2d255f725e2d898512f707dfe9c6c3d064771d
|
4
|
+
data.tar.gz: 7d64e8cbb7ecf414827211f863e07b43eb2a65ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83da29cd8e1bf8361ee4e37796dbcd687ab4eaf8cb12cf16eca3c5a77201de41d228ddc0985737e94947e7a02c7e463cae91d307028c99be518690366abae1a0
|
7
|
+
data.tar.gz: 970f9ac1d977842b31a2d819a85e34aef0f7b7942a666694753fc33353e590039ee40abc61a2f834b5d4add02e2fa71f9048e9b4a1a794d32c8f4c577c787daf
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
![Clamby Logo](https://raw.github.com/kobaltz/clamby/master/clamby_logo.png)
|
2
2
|
|
3
3
|
[![GemVersion](https://badge.fury.io/rb/clamby.png)](https://badge.fury.io/rb/clamby.png)
|
4
|
+
[![Build Status](https://travis-ci.org/kobaltz/clamby.png?branch=master)](https://travis-ci.org/kobaltz/clamby)
|
5
|
+
|
4
6
|
|
5
7
|
This gem depends on the `clamscan` and `freshclam` daemons to be installed already.
|
6
8
|
|
@@ -10,6 +12,19 @@ If you have a file upload on your site and you do not scan the files for viruses
|
|
10
12
|
|
11
13
|
Be sure to check the CHANGELOG as recent changes may affect functionality.
|
12
14
|
|
15
|
+
Just add `gem 'clamby'` to your `Gemfile` and run `bundle install`.
|
16
|
+
|
17
|
+
You can use two methods to scan a file for a virus:
|
18
|
+
|
19
|
+
If you use `safe?` to scan a file, it will return true if no viruses were found, false if a virus was found, and nil if there was a problem finding the file or if there was a problem using `clamscan`
|
20
|
+
|
21
|
+
`safe?(path_to_file)`
|
22
|
+
|
23
|
+
If you use `virus?` to scan a file, it will return true if a virus was found, false if no virus was found, and nil if there was a problem finding the file or if there was a problem using `clamscan`
|
24
|
+
|
25
|
+
|
26
|
+
`virus?(path_to_file)`
|
27
|
+
|
13
28
|
In your model with the uploader, you can add the scanner to a before method to scan the file. When a file is scanned, a successful scan will return `true`. An unsuccessful scan will return `false`. A scan may be unsuccessful for a number of reasons; `clamscan` could not be found, `clamscan` returned a virus, or the file which you were trying to scan could not be found.
|
14
29
|
|
15
30
|
```ruby
|
@@ -19,7 +34,7 @@ In your model with the uploader, you can add the scanner to a before method to s
|
|
19
34
|
|
20
35
|
def scan_for_viruses
|
21
36
|
path = self.attribute.url
|
22
|
-
Clamby.
|
37
|
+
Clamby.safe?(path)
|
23
38
|
end
|
24
39
|
```
|
25
40
|
|
@@ -38,7 +53,7 @@ It's good to note that Clamby will not by default delete files which had a virus
|
|
38
53
|
|
39
54
|
def scan_for_viruses
|
40
55
|
path = self.attribute.url
|
41
|
-
scan_result = Clamby.
|
56
|
+
scan_result = Clamby.safe?(path)
|
42
57
|
if scan_result
|
43
58
|
return true
|
44
59
|
else
|
data/Rakefile
CHANGED
data/lib/clamby.rb
CHANGED
@@ -15,7 +15,7 @@ module Clamby
|
|
15
15
|
opts.each {|k,v| @config[k.to_sym] = v if @valid_config_keys.include? k.to_sym}
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.
|
18
|
+
def self.safe?(path)
|
19
19
|
if self.scanner_exists?
|
20
20
|
if file_exists?(path)
|
21
21
|
scanner = system("clamscan #{path} --no-summary")
|
@@ -37,7 +37,27 @@ module Clamby
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
|
40
|
+
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
|
60
|
+
end
|
41
61
|
|
42
62
|
def self.scanner_exists?
|
43
63
|
if @config[:check]
|
data/lib/clamby/version.rb
CHANGED
data/spec/.DS_Store
ADDED
Binary file
|
data/spec/clamby_spec.rb
CHANGED
@@ -20,19 +20,23 @@ describe Clamby do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should scan file as safe" do
|
23
|
-
expect(Clamby.
|
23
|
+
expect(Clamby.safe?(good_path)).to be true
|
24
|
+
expect(Clamby.virus?(good_path)).to be false
|
24
25
|
end
|
25
26
|
|
26
27
|
it "should scan file and return nil" do
|
27
|
-
expect(Clamby.
|
28
|
+
expect(Clamby.safe?(bad_path)).to be nil
|
29
|
+
expect(Clamby.virus?(bad_path)).to be nil
|
28
30
|
end
|
29
31
|
|
30
32
|
it "should scan file as dangerous" do
|
31
33
|
`wget http://www.eicar.org/download/eicar.com`
|
32
34
|
Clamby.configure({:error_file_virus => true})
|
33
|
-
expect{Clamby.
|
35
|
+
expect{Clamby.safe?('eicar.com')}.to raise_exception(Exceptions::VirusDetected)
|
36
|
+
expect{Clamby.virus?('eicar.com')}.to raise_exception(Exceptions::VirusDetected)
|
34
37
|
Clamby.configure({:error_file_virus => false})
|
35
|
-
expect(Clamby.
|
38
|
+
expect(Clamby.safe?('eicar.com')).to be false
|
39
|
+
expect(Clamby.virus?('eicar.com')).to be true
|
36
40
|
File.delete('eicar.com')
|
37
41
|
end
|
38
42
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clamby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kobaltz
|
@@ -63,6 +63,7 @@ extra_rdoc_files: []
|
|
63
63
|
files:
|
64
64
|
- ".gitignore"
|
65
65
|
- ".rspec"
|
66
|
+
- ".travis.yml"
|
66
67
|
- CHANGELOG.md
|
67
68
|
- Gemfile
|
68
69
|
- LICENSE.txt
|
@@ -73,7 +74,7 @@ files:
|
|
73
74
|
- lib/clamby.rb
|
74
75
|
- lib/clamby/exception.rb
|
75
76
|
- lib/clamby/version.rb
|
76
|
-
- spec/.
|
77
|
+
- spec/.DS_Store
|
77
78
|
- spec/clamby_spec.rb
|
78
79
|
- spec/spec_helper.rb
|
79
80
|
homepage: ''
|
@@ -101,6 +102,6 @@ signing_key:
|
|
101
102
|
specification_version: 4
|
102
103
|
summary: Scan file uploads with ClamAV
|
103
104
|
test_files:
|
104
|
-
- spec/.
|
105
|
+
- spec/.DS_Store
|
105
106
|
- spec/clamby_spec.rb
|
106
107
|
- spec/spec_helper.rb
|
data/spec/.travis.yml
DELETED