clamby 0.0.1 → 1.0.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: 1693cf1781ac3eaead9999bd4aa25a0e0fb64f28
4
- data.tar.gz: 9b93c18f81c7d06c1ade22065ba6e12f48eef4a0
3
+ metadata.gz: 3277f73b27e06cb253308aa6db21d99789346a8f
4
+ data.tar.gz: 01014888335684717c6ccdbd48e5ba1ea9ffca21
5
5
  SHA512:
6
- metadata.gz: 4294bb0849e9da0a7db332305a43844018756c4b4e8f7a704e0a6a633f67d9bc66d04137c91ce6ae808108af41f6479774d789e029171810f6c66192c7103f45
7
- data.tar.gz: 36c019f99df0504b0a812b1a9f4f48443c514d09c51fee9380041ad57868d78c9e187cb22b4a90b417b561dc49dd972f5893cbfeb6d17c8d926f165b8d3a5682
6
+ metadata.gz: 42870280a5cb511d2d9b8518601fbdaaee59c233f3fdba23ce06b65465b21c1f7ec9f5529ec0713267475dcd689a96d94e12419f5d102344d2b786a71db06da9
7
+ data.tar.gz: 5098899d37ea0a8286a7a8f80b51cd6c5c52835ee80db2af15093e60cc26610d23229e97956e0e1ebb1ed8d004138ee859849dc2da519dc0a55ff221a58106c6
data/README.md CHANGED
@@ -4,14 +4,54 @@ This gem depends on the `clamscan` and `freshclam` daemons to be installed alrea
4
4
 
5
5
  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.
6
6
 
7
+ #Usage
8
+
9
+ 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.
10
+
11
+ ```ruby
12
+ before_create :scan_for_viruses
13
+
14
+ private
15
+
16
+ def scan_for_viruses
17
+ path = self.attribute.url
18
+ Clamby.scan(path)
19
+ end
20
+ ```
21
+
22
+ ***Updating Definitions***
23
+
24
+ I have done little testing with updating definitions online. However, there is a method that you can call `Clamby.update` which will execute `freshclam`. It is recommended that you follow the instructions below to ensure that this is done automatically on a daily/weekly basis.
25
+
26
+ ***Viruses Detected***
27
+
28
+ It's good to note that Clamby will not by default delete files which had a virus. Instead, this is left to you to decide what should occur with that file. Below is an example where if a scan came back `false`, the file would be deleted.
29
+
30
+ ```ruby
31
+ before_create :scan_for_viruses
32
+
33
+ private
34
+
35
+ def scan_for_viruses
36
+ path = self.attribute.url
37
+ scan_result = Clamby.scan(path)
38
+ if scan_result
39
+ return true
40
+ else
41
+ File.delete(path)
42
+ return false
43
+ end
44
+ end
45
+ ```
46
+
47
+
7
48
  #Configuration
8
49
 
9
50
  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.
10
51
 
11
- Clamby.configure do |config|
12
- config.check = false
13
- end
14
-
52
+ ```ruby
53
+ Clamby.configure({check: false})
54
+ ```
15
55
 
16
56
  #Dependencies
17
57
 
@@ -23,6 +63,22 @@ Configuration is rather limited right now. You can exclude the check if `clamsca
23
63
 
24
64
  `brew install clamav`
25
65
 
66
+ ***Auto Update****
67
+
68
+ To update the virus database, open a terminal and enter the following command:
69
+
70
+ `sudo freshclam`
71
+
72
+ 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.
73
+
74
+ You need to modify the crontab for the root user.
75
+
76
+ `sudo crontab -e`
77
+
78
+ This opens the root crontab file in a text editor. Add the following line
79
+
80
+ `57 08 * * * sudo freshclam`
81
+
26
82
  #LICENSE
27
83
 
28
84
  Copyright (c) 2014 kobaltz
data/lib/clamby.rb CHANGED
@@ -47,6 +47,10 @@ module Clamby
47
47
  end
48
48
  end
49
49
 
50
+ def self.update
51
+ system("freshclam")
52
+ end
53
+
50
54
  def self.config
51
55
  @config
52
56
  end
@@ -1,3 +1,3 @@
1
1
  module Clamby
2
- VERSION = "0.0.1"
2
+ VERSION = "1.0.1"
3
3
  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: 0.0.1
4
+ version: 1.0.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-09 00:00:00.000000000 Z
11
+ date: 2014-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler