class Ratonvirus::Scanner::Clamby
Constants
- CLAMBY_DEFAULT_CONFIG
Public Class Methods
configure(config = {})
click to toggle source
# File lib/ratonvirus/scanner/clamby.rb, line 23 def configure(config = {}) ::Clamby.configure(config) end
executable?()
click to toggle source
Avoid multiple calls to the clamscan utility to check whether the system is executable.
# File lib/ratonvirus/scanner/clamby.rb, line 33 def executable? # Clamby should return `nil` when clamscan is not available. !!::Clamby::Command.clamscan_version end
reset()
click to toggle source
# File lib/ratonvirus/scanner/clamby.rb, line 27 def reset configure(CLAMBY_DEFAULT_CONFIG.dup) end
Public Instance Methods
setup()
click to toggle source
Allow users to configure Clamby
the way they want to.
Calls superclass method
# File lib/ratonvirus/scanner/clamby.rb, line 40 def setup self.class.configure(config[:clamby] || {}) super end
Protected Instance Methods
run_scan(path)
click to toggle source
# File lib/ratonvirus/scanner/clamby.rb, line 48 def run_scan(path) # In case the file is not present at all, scanning should always pass # because nil is not a virus. return if path.nil? begin errors << :antivirus_virus_detected if ::Clamby.virus?(path) rescue ::Clamby::ClamscanClientError # This can happen e.g. if the clamdscan utility does not have access # to read the file path. For debugging, try to run the clamdscan # utility manually for the same file: # clamdscan /path/to/file.pdf # # Also, make sure that the file uploads store directory is readable # by the clamdscan utility. E.g. /path/to/app/public/uploads/tmp. # # Another possible reason is that in case there are too many # concurrent virus checks ongoing, it may also trigger this error. errors << :antivirus_client_error rescue ::Clamby::FileNotFound # This should be pretty rare since the scanner should not be even # called when the file is not available. As the storage backend may # be configured, this may still happen with some storage backends. errors << :antivirus_file_not_found end end