ddr-antivirus 1.3.0 → 1.3.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: 86a232e5b90342f2dd51279b2e589e51d7345a23
4
- data.tar.gz: e48ae1a5fe0a895d18784a6ba120a0e7dfa892ba
3
+ metadata.gz: b3ef82b06ad7b12f5c73b2bf8d223baf3b2e3b3d
4
+ data.tar.gz: c764fe1c7b36acf7cb592da9105b0f32b923fa2d
5
5
  SHA512:
6
- metadata.gz: 173c325eb8d7369d7823341593334e229ae5a48047938a680fda9afc21a6151d6e34722864a9acda826fd1f11113526b086bc7dc45acdaf7a410c8a70b4e0ee8
7
- data.tar.gz: 51d17a1ea969fab1d69f86b4bd1f3c870fdcef45d7362f96bebb9387ab95105f2e61e55c79eee1be628a254d5ef15acffd0d894a6a6414bbc7a88e96a52bd3af
6
+ metadata.gz: 77b13b6df4c1f71d28817fbd1a851a3387bd5083b5ba811745aabf9ba67c8f0437bfa6ba34b3b6fcafad44cdb2fcb7e958f34c8d34a71dfeca43c6736e6044b6
7
+ data.tar.gz: 6610ac368e938e6b968bd95aa9bc93b2b6eb9dec5c2fb04b2fc0b01ea278638b7b599275211728849632cdfdaf086691eefed7c88ab90a2c443db8b4eb21078c
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in ddr-antivirus.gemspec
4
3
  gemspec
4
+
5
+ gem "coveralls", require: false
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
1
  # Ddr::Antivirus
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/ddr-antivirus.svg)](http://badge.fury.io/rb/ddr-antivirus)
4
- [![Build Status](https://travis-ci.org/duke-libraries/ddr-antivirus.svg?branch=master)](https://travis-ci.org/duke-libraries/ddr-antivirus)
3
+ Pluggable antivirus service for Ruby applications.
5
4
 
6
- Antivirus scanner for Ruby applications.
5
+ [![Gem Version](https://badge.fury.io/rb/ddr-antivirus.svg)](http://badge.fury.io/rb/ddr-antivirus)
6
+ [![Build Status](https://travis-ci.org/duke-libraries/ddr-antivirus.svg?branch=develop)](https://travis-ci.org/duke-libraries/ddr-antivirus)
7
+ [![Coverage Status](https://coveralls.io/repos/duke-libraries/ddr-antivirus/badge.png?branch=develop)](https://coveralls.io/r/duke-libraries/ddr-antivirus?branch=develop)
8
+ [![Code Climate](https://codeclimate.com/github/duke-libraries/ddr-antivirus/badges/gpa.svg)](https://codeclimate.com/github/duke-libraries/ddr-antivirus)
7
9
 
8
10
  ## Installation
9
11
 
@@ -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 = %q{Antivirus scanning service.}
12
- spec.description = %q{Antivirus scanning service.}
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
 
@@ -41,11 +41,9 @@ module Ddr
41
41
  require "clamav"
42
42
  :clamav
43
43
  rescue LoadError
44
- if system "which -a clamdscan"
45
- :clamd
46
- else
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
- # ClamdScannerAdapter uses an external ClamAV daemon (clamd)
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
 
@@ -5,7 +5,7 @@ module Ddr
5
5
  module Antivirus
6
6
  module Adapters
7
7
  #
8
- # The NullScannerAdapter provides a no-op adapter, primarily for testing and development.
8
+ # A no-op adapter, primarily for testing and development.
9
9
  #
10
10
  class NullScannerAdapter < ScannerAdapter
11
11
 
@@ -2,7 +2,7 @@ module Ddr
2
2
  module Antivirus
3
3
  module Adapters
4
4
  #
5
- # Default scan result implementation
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
- # Subclasses may override to provide description of virus found.
30
+ # the name of virus found.
31
+ # @return [String] the virus name.
27
32
  def virus_found; end
28
33
 
29
- # Subclasses should override
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
- # Subclasses may override to indicate an error condition (not necessarily an exception).
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
- # Subclasses may override
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
- # Abstract class for scanner adapters.
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 - subclasses must implement.
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
@@ -1,5 +1,5 @@
1
1
  module Ddr
2
2
  module Antivirus
3
- VERSION = "1.3.0"
3
+ VERSION = "1.3.1"
4
4
  end
5
5
  end
@@ -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.0
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: 2014-11-14 00:00:00.000000000 Z
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: Antivirus scanning service.
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: Antivirus scanning service.
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