clamby 1.6.2 → 1.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +2 -2
- data/README.md +28 -4
- data/clamby.gemspec +2 -1
- data/lib/clamby.rb +1 -0
- data/lib/clamby/command.rb +9 -3
- data/lib/clamby/version.rb +1 -1
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea8e0af4d5353040a1d77f2d083e9273116d176b35466a252469c6229fcdd615
|
4
|
+
data.tar.gz: 7e16db099c92c3d0f5936b18656b648ed79379d84eddca7ab7b1ebff029e0f9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b0cbbfb2ac384a60e7f22805a4b3d519dad097a6a4d5420f5bf5204f5b6f086ab6aae4844deb9ea8fa09f4846370b8be5fa65ce66f7884c6f4d198dadf1780e
|
7
|
+
data.tar.gz: 583abcfd57e5e73ee0875a57af769c1c6acf86c81c2f4de736e7158d71652431c24aaf12eb8b92fecefb589d3a70e34decb0ce0f39a7fdae2748c3979b536d54
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -17,14 +17,14 @@ Just add `gem 'clamby'` to your `Gemfile` and run `bundle install`.
|
|
17
17
|
|
18
18
|
You can use two methods to scan a file for a virus:
|
19
19
|
|
20
|
-
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
|
+
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`
|
21
21
|
|
22
|
-
`safe?(path_to_file)`
|
22
|
+
`Clamby.safe?(path_to_file)`
|
23
23
|
|
24
|
-
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
|
+
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`
|
25
25
|
|
26
26
|
|
27
|
-
`virus?(path_to_file)`
|
27
|
+
`Clamby.virus?(path_to_file)`
|
28
28
|
|
29
29
|
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.
|
30
30
|
|
@@ -64,6 +64,25 @@ It's good to note that Clamby will not by default delete files which had a virus
|
|
64
64
|
end
|
65
65
|
```
|
66
66
|
|
67
|
+
## with ActiveStorage
|
68
|
+
|
69
|
+
With ActiveStorage, you don't have access to the file through normal methods, so you'll have to access the file through the `attachment_changes`.
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
class User < ApplicationRecord
|
73
|
+
has_one_attached :avatar
|
74
|
+
before_save :scan_for_viruses
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def scan_for_viruses
|
79
|
+
return unless self.attachment_changes['avatar']
|
80
|
+
|
81
|
+
path = self.attachment_changes['avatar'].attachable.tempfile.path
|
82
|
+
Clamby.safe?(path)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
```
|
67
86
|
|
68
87
|
# Configuration
|
69
88
|
|
@@ -161,6 +180,11 @@ This opens the root crontab file in a text editor. Add the following line
|
|
161
180
|
|
162
181
|
`57 08 * * * sudo freshclam`
|
163
182
|
|
183
|
+
# Contributors
|
184
|
+
|
185
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
186
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
187
|
+
|
164
188
|
# LICENSE
|
165
189
|
|
166
190
|
Copyright (c) 2016 kobaltz
|
data/clamby.gemspec
CHANGED
@@ -18,7 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler"
|
21
|
+
spec.add_development_dependency "bundler"
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "byebug"
|
24
25
|
end
|
data/lib/clamby.rb
CHANGED
data/lib/clamby/command.rb
CHANGED
@@ -23,6 +23,10 @@ module Clamby
|
|
23
23
|
args << '--stream' if Clamby.config[:stream]
|
24
24
|
end
|
25
25
|
|
26
|
+
puts "use db : #{Clamby.config[:datadir]}"
|
27
|
+
args << "-d #{Clamby.config[:datadir]}" if Clamby.config[:datadir]
|
28
|
+
puts args.join(' ')
|
29
|
+
|
26
30
|
new.run scan_executable, *args
|
27
31
|
|
28
32
|
# $CHILD_STATUS maybe nil if the execution itself (not the client process)
|
@@ -35,7 +39,7 @@ module Clamby
|
|
35
39
|
if Clamby.config[:error_clamscan_client_error] && Clamby.config[:daemonize]
|
36
40
|
raise Clamby::ClamscanClientError.new("Clamscan client error")
|
37
41
|
end
|
38
|
-
|
42
|
+
|
39
43
|
# returns true to maintain legacy behavior
|
40
44
|
return true
|
41
45
|
else
|
@@ -47,7 +51,9 @@ module Clamby
|
|
47
51
|
|
48
52
|
# Update the virus definitions.
|
49
53
|
def self.freshclam
|
50
|
-
|
54
|
+
args = []
|
55
|
+
args << "--datadir=#{Clamby.config[:datadir]}" if Clamby.config[:datadir]
|
56
|
+
new.run 'freshclam', *args
|
51
57
|
end
|
52
58
|
|
53
59
|
# Show the ClamAV version. Also acts as a quick check if ClamAV functions.
|
@@ -68,7 +74,7 @@ module Clamby
|
|
68
74
|
self.command = args | default_args
|
69
75
|
self.command = command.sort.unshift(executable_full)
|
70
76
|
|
71
|
-
system(
|
77
|
+
system(self.command.join(' '), system_options)
|
72
78
|
end
|
73
79
|
|
74
80
|
private
|
data/lib/clamby/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clamby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kobaltz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: Clamby allows users to scan files uploaded with Paperclip or Carrierwave.
|
56
70
|
If a file has a virus, then you can delete this file and discard it without causing
|
57
71
|
harm to other users.
|
@@ -101,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
115
|
- !ruby/object:Gem::Version
|
102
116
|
version: '0'
|
103
117
|
requirements: []
|
104
|
-
rubygems_version: 3.0.
|
118
|
+
rubygems_version: 3.0.8
|
105
119
|
signing_key:
|
106
120
|
specification_version: 4
|
107
121
|
summary: Scan file uploads with ClamAV
|