class Hydra::Works::VirusScanner
Attributes
file[R]
Public Class Methods
infected?(file)
click to toggle source
@api public @param file [String]
# File lib/hydra/works/virus_scanner.rb, line 22 def self.infected?(file) new(file).infected? end
new(file)
click to toggle source
# File lib/hydra/works/virus_scanner.rb, line 26 def initialize(file) @file = file end
Public Instance Methods
clam_av_scanner()
click to toggle source
# File lib/hydra/works/virus_scanner.rb, line 42 def clam_av_scanner Deprecation.warn(self, "The ClamAV has been replaced by Clamby " \ "as the supported virus scanner for hydra-works. " \ "ClamAV support will be removed in hydra-works 2.0 ") scan_result = ClamAV.instance.method(:scanfile).call(file) return false if scan_result == 0 warning "A virus was found in #{file}: #{scan_result}" true end
clamby_scanner()
click to toggle source
@return [Boolean]
# File lib/hydra/works/virus_scanner.rb, line 53 def clamby_scanner scan_result = Clamby.virus?(file) warning("A virus was found in #{file}") if scan_result scan_result end
infected?()
click to toggle source
Override this method to use your own virus checking software @return [Boolean]
# File lib/hydra/works/virus_scanner.rb, line 32 def infected? if defined?(Clamby) clamby_scanner elsif defined?(ClamAV) clam_av_scanner else null_scanner end end
null_scanner()
click to toggle source
Always return zero if there's nothing available to check for viruses. This means that we assume all files have no viruses because we can't conclusively say if they have or not.
# File lib/hydra/works/virus_scanner.rb, line 61 def null_scanner warning "Unable to check #{file} for viruses because no virus scanner is defined" false end
Private Instance Methods
warning(msg)
click to toggle source
# File lib/hydra/works/virus_scanner.rb, line 68 def warning(msg) ActiveFedora::Base.logger&.warn(msg) end