clamby 1.0.2 → 1.0.3

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: bcf4bae22a96d13a305f1ed6ea672a9e32ae76be
4
- data.tar.gz: 955cb04265ba74a26c0d329db079db68755e4af6
3
+ metadata.gz: de1411f20e529bdebaaa6f32b34863c06abc38f0
4
+ data.tar.gz: d6e542a17e3dcec0939d5fd94017b9892613b581
5
5
  SHA512:
6
- metadata.gz: 1bec2c40aaecbb5e439d5ab9e92c25d8c70c99447e3b2ca37b9bd5b69db999dc2c6941b378a288daa0c29187642eefc1d7637d11ddd1fef443edc94e3564bd85
7
- data.tar.gz: c3d2ca5c777919b6f5f4956818d1bf6efa1954c4d76509aa8bbdc9168ef1ed467772dca5c27746ec189543e53d2b9793c624df7b5cc29d29af0dbc4538f3eac6
6
+ metadata.gz: 64d0b0e23f7a8dd5fd42c839e6f1854d73e55fbb72d4a7d22a31ed5db1a63ce3f95d760e7dcc506a49238a51acebae7ba54de65a4b9cce18378922bf45aeaf84
7
+ data.tar.gz: 58a13ecdbd9068dd7052b4ba1f806592234c2c751b6e8e93702d4a7b851980fc5f5e515f30c563b3508d1185e68d0e310eaf57f8925f0993de4bcce787a9dce6
data/README.md CHANGED
@@ -50,8 +50,15 @@ It's good to note that Clamby will not by default delete files which had a virus
50
50
 
51
51
  Configuration is rather limited right now. You can exclude the check if `clamscan` exists which will save a bunch of time for scanning your files. However, for development purposes, your machine may not have `clamscan` installed and you may wonder why it's not working properly. This is just to give you a reminder to install `clamscan` on your development machine and production machine. You can add the following to a config file, `clamby_setup.rb` to your initializers directory.
52
52
 
53
+ There has been added additional functionality where you can override exceptions. If you set the exceptions below to false, then there will not be a hard exception generated. Instead, it will post to your log that an error had occured. By default each one of these configuration options are set to true. You may want to set these to false in your production environment.
54
+
53
55
  ```ruby
54
- Clamby.configure({check: false})
56
+ Clamby.configure({
57
+ :check => false,
58
+ :error_clamscan_missing => false,
59
+ :error_file_missing => false,
60
+ :error_file_virus => false
61
+ })
55
62
  ```
56
63
 
57
64
  #Dependencies
@@ -1,8 +1,13 @@
1
1
  require "clamby/version"
2
-
2
+ require "clamby/exception"
3
3
  module Clamby
4
4
 
5
- @config = {:check => true}
5
+ @config = {
6
+ :check => true,
7
+ :error_clamscan_missing => true,
8
+ :error_file_missing => true,
9
+ :error_file_virus => true
10
+ }
6
11
 
7
12
  @valid_config_keys = @config.keys
8
13
 
@@ -17,8 +22,12 @@ module Clamby
17
22
  if scanner
18
23
  return true
19
24
  elsif not scanner
20
- puts "VIRUS DETECTED on #{Time.now}: #{path}"
21
- return false
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
22
31
  end
23
32
  end
24
33
  end
@@ -28,23 +37,31 @@ module Clamby
28
37
  if @config[:check]
29
38
  scanner = system('clamscan')
30
39
  if not scanner
31
- puts "CLAMSCAN NOT FOUND"
32
- return false
40
+ if @config[:error_clamscan_missing]
41
+ raise Exceptions::ClamscanMissing.new("Clamscan application not found. Check your installation and path.")
42
+ else
43
+ puts "CLAMSCAN NOT FOUND"
44
+ return false
45
+ end
33
46
  else
34
47
  return true
35
48
  end
36
- else
37
- return true
38
- end
49
+ else
50
+ return true
51
+ end
39
52
  end
40
53
 
41
54
  def self.file_exists?(path)
42
55
  if File.file?(path)
43
56
  return true
44
- else
45
- puts "FILE NOT FOUND on #{Time.now}: #{path}"
46
- return false
47
- end
57
+ else
58
+ if @config[:error_file_missing]
59
+ raise Exceptions::FileNotFound.new("File not found: #{path}")
60
+ else
61
+ puts "FILE NOT FOUND on #{Time.now}: #{path}"
62
+ return false
63
+ end
64
+ end
48
65
  end
49
66
 
50
67
  def self.update
@@ -0,0 +1,6 @@
1
+ module Exceptions
2
+ class Error < StandardError; end
3
+ class VirusDetected < Error; end
4
+ class ClamscanMissing < Error; end
5
+ class FileNotFound < Error; end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module Clamby
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  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.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - kobaltz
@@ -55,6 +55,7 @@ files:
55
55
  - Rakefile
56
56
  - clamby.gemspec
57
57
  - lib/clamby.rb
58
+ - lib/clamby/exception.rb
58
59
  - lib/clamby/version.rb
59
60
  homepage: ''
60
61
  licenses: