Class: Hyrax::VirusScanner

Inherits:
Object
  • Object
show all
Defined in:
app/models/hyrax/virus_scanner.rb

Overview

The default virus scanner ported from Hyrax::Works.

If ClamAV is present, it will be used to check for the presence of a virus. If ClamAV is not installed or otherwise not available to your application, Hyrax::Works does no virus checking add assumes files have no viruses.

Examples:

to use a virus checker other than Hyrax::VirusScanner:

class MyScanner < Hyrax::Works::VirusScanner
  def infected?
    my_result = Scanner.check_for_viruses(file)
    [return true or false]
  end
end

# Then set Hyrax::Works to use your scanner either in a config file or initializer:
Hyrax.config.virus_scanner = MyScanner

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ VirusScanner

Returns a new instance of VirusScanner.



32
33
34
# File 'app/models/hyrax/virus_scanner.rb', line 32

def initialize(file)
  @file = file
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



23
24
25
# File 'app/models/hyrax/virus_scanner.rb', line 23

def file
  @file
end

Class Method Details

.infected?(file) ⇒ Boolean

Parameters:

  • file (String)

Returns:

  • (Boolean)


28
29
30
# File 'app/models/hyrax/virus_scanner.rb', line 28

def self.infected?(file)
  new(file).infected?
end

Instance Method Details

#infected?Boolean

Note:

Override this method to use your own virus checking software

Returns:

  • (Boolean)


40
41
42
43
44
45
46
47
48
# File 'app/models/hyrax/virus_scanner.rb', line 40

def infected?
  if defined?(Clamby)
    clamby_scanner
  elsif defined?(ClamAV)
    clam_av_scanner
  else
    null_scanner
  end
end