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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9fd8ce4dbb727390a6c41672ce701ef9ede81a4
4
- data.tar.gz: 69585a26d1f9f8de1f279b15a0980226c687f0b9
3
+ metadata.gz: bc2d255f725e2d898512f707dfe9c6c3d064771d
4
+ data.tar.gz: 7d64e8cbb7ecf414827211f863e07b43eb2a65ac
5
5
  SHA512:
6
- metadata.gz: 4492b45533ef3e967f818746a43742e9a525d333a91bf88c413c98d88bc6ac1fced3f0d98b89009369f68d1284df90f786ab7fada2f19d414afa5c91c8d9233a
7
- data.tar.gz: a5176fddef6a09a0e4c3d801818064984ce368563bf94ccc141b26cdd93e0a69232a6a43a248b49c8858a4fa6def05b0f684b75423279069df9bc27dff744d8c
6
+ metadata.gz: 83da29cd8e1bf8361ee4e37796dbcd687ab4eaf8cb12cf16eca3c5a77201de41d228ddc0985737e94947e7a02c7e463cae91d307028c99be518690366abae1a0
7
+ data.tar.gz: 970f9ac1d977842b31a2d819a85e34aef0f7b7942a666694753fc33353e590039ee40abc61a2f834b5d4add02e2fa71f9048e9b4a1a794d32c8f4c577c787daf
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .DS_Store/
data/.travis.yml ADDED
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+ before_install:
3
+ - gem install bundler -v '>= 1.5.3'
4
+ - gem install rake
5
+ - gem install rspec
6
+ rvm:
7
+ - 1.9.3
8
+ - 2.0.0
9
+ - 2.1.1
10
+ install:
11
+ - sudo apt-get install clamav
12
+ - sudo freshclam
13
+
14
+ gemfile:
15
+ - Gemfile
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ #v1.10
2
+ - Changed `scan()` to `safe?()`
3
+ - Added virus?()
4
+ - Added/Changed `rspec` to accomodate new/changed functionality
5
+
1
6
  #v1.0.5
2
7
  - Made default virus detection not throw a warning
3
8
  - If scanning a file that doesn't exist, `scan(path)` will return nil.
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.scan(path)
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.scan(path)
56
+ scan_result = Clamby.safe?(path)
42
57
  if scan_result
43
58
  return true
44
59
  else
data/Rakefile CHANGED
@@ -1 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
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.scan(path)
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]
@@ -1,3 +1,3 @@
1
1
  module Clamby
2
- VERSION = "1.0.5"
2
+ VERSION = "1.1.0"
3
3
  end
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.scan(good_path)).to be true
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.scan(bad_path)).to be nil
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.scan('eicar.com')}.to raise_exception(Exceptions::VirusDetected)
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.scan('eicar.com')).to be false
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.5
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/.travis.yml
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/.travis.yml
105
+ - spec/.DS_Store
105
106
  - spec/clamby_spec.rb
106
107
  - spec/spec_helper.rb
data/spec/.travis.yml DELETED
@@ -1,2 +0,0 @@
1
- rvm:
2
- - 1.9.3