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 +4 -4
- data/README.md +60 -4
- data/lib/clamby.rb +4 -0
- data/lib/clamby/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3277f73b27e06cb253308aa6db21d99789346a8f
|
4
|
+
data.tar.gz: 01014888335684717c6ccdbd48e5ba1ea9ffca21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
12
|
-
|
13
|
-
|
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
data/lib/clamby/version.rb
CHANGED
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:
|
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-
|
11
|
+
date: 2014-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|