ddr-antivirus 1.3.0 → 1.3.1
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/Gemfile +2 -1
- data/README.md +5 -3
- data/ddr-antivirus.gemspec +2 -2
- data/lib/ddr/antivirus.rb +3 -5
- data/lib/ddr/antivirus/adapters/clamav_scanner_adapter.rb +7 -2
- data/lib/ddr/antivirus/adapters/clamd_scanner_adapter.rb +1 -3
- data/lib/ddr/antivirus/adapters/null_scanner_adapter.rb +1 -1
- data/lib/ddr/antivirus/adapters/scan_result.rb +15 -6
- data/lib/ddr/antivirus/adapters/scanner_adapter.rb +6 -6
- data/lib/ddr/antivirus/version.rb +1 -1
- data/spec/spec_helper.rb +3 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3ef82b06ad7b12f5c73b2bf8d223baf3b2e3b3d
|
4
|
+
data.tar.gz: c764fe1c7b36acf7cb592da9105b0f32b923fa2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77b13b6df4c1f71d28817fbd1a851a3387bd5083b5ba811745aabf9ba67c8f0437bfa6ba34b3b6fcafad44cdb2fcb7e958f34c8d34a71dfeca43c6736e6044b6
|
7
|
+
data.tar.gz: 6610ac368e938e6b968bd95aa9bc93b2b6eb9dec5c2fb04b2fc0b01ea278638b7b599275211728849632cdfdaf086691eefed7c88ab90a2c443db8b4eb21078c
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# Ddr::Antivirus
|
2
2
|
|
3
|
-
|
4
|
-
[](https://travis-ci.org/duke-libraries/ddr-antivirus)
|
3
|
+
Pluggable antivirus service for Ruby applications.
|
5
4
|
|
6
|
-
|
5
|
+
[](http://badge.fury.io/rb/ddr-antivirus)
|
6
|
+
[](https://travis-ci.org/duke-libraries/ddr-antivirus)
|
7
|
+
[](https://coveralls.io/r/duke-libraries/ddr-antivirus?branch=develop)
|
8
|
+
[](https://codeclimate.com/github/duke-libraries/ddr-antivirus)
|
7
9
|
|
8
10
|
## Installation
|
9
11
|
|
data/ddr-antivirus.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Ddr::Antivirus::VERSION
|
9
9
|
spec.authors = ["David Chandek-Stark"]
|
10
10
|
spec.email = ["dchandekstark@gmail.com"]
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
11
|
+
spec.summary = "Pluggable antivirus scanning service."
|
12
|
+
spec.description = "Pluggable antivirus scanning service."
|
13
13
|
spec.homepage = "https://github.com/duke-libraries/ddr-antivirus"
|
14
14
|
spec.license = "BSD-3-Clause"
|
15
15
|
|
data/lib/ddr/antivirus.rb
CHANGED
@@ -41,11 +41,9 @@ module Ddr
|
|
41
41
|
require "clamav"
|
42
42
|
:clamav
|
43
43
|
rescue LoadError
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
:null
|
48
|
-
end
|
44
|
+
require "open3"
|
45
|
+
out, status = Open3.capture2e("which -a clamdscan")
|
46
|
+
status.success? ? :clamd : :null
|
49
47
|
end
|
50
48
|
end
|
51
49
|
|
@@ -6,15 +6,18 @@ require_relative "scan_result"
|
|
6
6
|
module Ddr
|
7
7
|
module Antivirus
|
8
8
|
module Adapters
|
9
|
-
|
9
|
+
#
|
10
|
+
# Scanner adapter for the 'clamav' gem (Ruby libclamav bindings).
|
11
|
+
#
|
10
12
|
class ClamavScannerAdapter < ScannerAdapter
|
11
|
-
|
13
|
+
|
12
14
|
def scan(path)
|
13
15
|
reload!
|
14
16
|
raw = engine.scanfile(path)
|
15
17
|
ClamavScanResult.new(raw, path)
|
16
18
|
end
|
17
19
|
|
20
|
+
# Load or reload the database of virus signatures.
|
18
21
|
def reload!
|
19
22
|
#
|
20
23
|
# ClamAV.instance.reload is supposed to reload the database if changed and return:
|
@@ -54,6 +57,8 @@ module Ddr
|
|
54
57
|
raw == 1
|
55
58
|
end
|
56
59
|
|
60
|
+
# A formatted status message (for consistency with clamdscan output).
|
61
|
+
# @return [String] the result status.
|
57
62
|
def status
|
58
63
|
return "FOUND #{virus_found}" if has_virus?
|
59
64
|
return "ERROR" if error?
|
@@ -5,9 +5,7 @@ module Ddr
|
|
5
5
|
module Antivirus
|
6
6
|
module Adapters
|
7
7
|
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# See https://github.com/soundarapandian/clamd for configuration method and options.
|
8
|
+
# Adapter for clamd client (clamdscan)
|
11
9
|
#
|
12
10
|
class ClamdScannerAdapter < ScannerAdapter
|
13
11
|
|
@@ -2,7 +2,7 @@ module Ddr
|
|
2
2
|
module Antivirus
|
3
3
|
module Adapters
|
4
4
|
#
|
5
|
-
#
|
5
|
+
# The result of a virus scan.
|
6
6
|
#
|
7
7
|
class ScanResult
|
8
8
|
|
@@ -15,32 +15,42 @@ module Ddr
|
|
15
15
|
@version = opts.fetch(:version, default_version)
|
16
16
|
end
|
17
17
|
|
18
|
+
# Default time of virus scan - i.e., now.
|
19
|
+
# @return [Time] the time.
|
18
20
|
def default_time
|
19
21
|
Time.now.utc
|
20
22
|
end
|
21
23
|
|
24
|
+
# Default anti-virus software version information.
|
25
|
+
# @return [String] the version.
|
22
26
|
def default_version
|
23
27
|
"ddr-antivirus #{Ddr::Antivirus::VERSION}"
|
24
28
|
end
|
25
29
|
|
26
|
-
#
|
30
|
+
# the name of virus found.
|
31
|
+
# @return [String] the virus name.
|
27
32
|
def virus_found; end
|
28
33
|
|
29
|
-
#
|
34
|
+
# Was a virus found?
|
35
|
+
# @return [true, false] whether a virus was found.
|
30
36
|
def has_virus?
|
31
37
|
!virus_found.nil?
|
32
38
|
end
|
33
39
|
|
34
|
-
#
|
40
|
+
# Was there an error (reported by the scanner, not necessarily an exception)?
|
41
|
+
# @return [true, false] whether there was an error.
|
35
42
|
def error?
|
36
43
|
false
|
37
44
|
end
|
38
45
|
|
46
|
+
# Was the result OK - i.e., not an error and virus not found.
|
47
|
+
# @return [true, false] whether the result was OK.
|
39
48
|
def ok?
|
40
49
|
!(has_virus? || error?)
|
41
50
|
end
|
42
51
|
|
43
|
-
#
|
52
|
+
# String representation of the result
|
53
|
+
# @return [String] the representation.
|
44
54
|
def to_s
|
45
55
|
"#{raw} (#{version})"
|
46
56
|
end
|
@@ -49,4 +59,3 @@ module Ddr
|
|
49
59
|
end
|
50
60
|
end
|
51
61
|
end
|
52
|
-
|
@@ -2,16 +2,16 @@ module Ddr
|
|
2
2
|
module Antivirus
|
3
3
|
module Adapters
|
4
4
|
#
|
5
|
-
#
|
6
|
-
#
|
5
|
+
# @abstract Subclass and override {#scan} to implement a scanner adapter.
|
6
|
+
#
|
7
7
|
class ScannerAdapter
|
8
8
|
|
9
|
-
# Scan a file path for viruses
|
9
|
+
# Scan a file path for viruses.
|
10
10
|
#
|
11
|
-
# @param [String] file path to scan
|
12
|
-
# @return [Ddr::Antivirus::ScanResult] the result
|
11
|
+
# @param path [String] file path to scan.
|
12
|
+
# @return [Ddr::Antivirus::Adapters::ScanResult] the result of the scan.
|
13
13
|
def scan(path)
|
14
|
-
raise NotImplementedError
|
14
|
+
raise NotImplementedError, "Adapters must implement the `scan' method."
|
15
15
|
end
|
16
16
|
|
17
17
|
# Return the adapter configuration options
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require "coveralls"
|
2
|
+
Coveralls.wear!
|
3
|
+
|
1
4
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
5
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
6
|
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ddr-antivirus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Chandek-Stark
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.0'
|
83
|
-
description:
|
83
|
+
description: Pluggable antivirus scanning service.
|
84
84
|
email:
|
85
85
|
- dchandekstark@gmail.com
|
86
86
|
executables: []
|
@@ -136,7 +136,7 @@ rubyforge_project:
|
|
136
136
|
rubygems_version: 2.2.2
|
137
137
|
signing_key:
|
138
138
|
specification_version: 4
|
139
|
-
summary:
|
139
|
+
summary: Pluggable antivirus scanning service.
|
140
140
|
test_files:
|
141
141
|
- spec/fixtures/blue-devil.png
|
142
142
|
- spec/shared_examples_for_scan_results.rb
|