Sha256: 3e9d8769964b928bcbde4c09dd77ff11eeebbf62faf51193eea5ab12d70e44ac

Contents?: true

Size: 779 Bytes

Versions: 7

Compression:

Stored size: 779 Bytes

Contents

# This is a simple wrapper for an underlying scanner; Without it, we'll
# always going to be running actual anti-virus
class AntiVirusScanner
  NO_VIRUS_FOUND_RETURN_VALUE = 0 unless defined?(NO_VIRUS_FOUND_RETURN_VALUE)

  class VirusDetected < RuntimeError
    def initialize(pid, file_path)
      super("A virus was found for PID=#{pid.inspect} (#{file_path.inspect})")
    end
  end
  attr_reader :object
  def initialize(object_with_pid)
    @object = object_with_pid
  end

  def call(file_path)
    if scanner_instance.call(file_path) == NO_VIRUS_FOUND_RETURN_VALUE
      return true
    else
      raise VirusDetected.new(object.pid, file_path)
    end
  end

  include Morphine
  register :scanner_instance do
    Rails.configuration.default_antivirus_instance
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
curate-0.3.2 app/services/anti_virus_scanner.rb
curate-0.3.1 app/services/anti_virus_scanner.rb
curate-0.2.0 app/services/anti_virus_scanner.rb
curate-0.1.3 app/services/anti_virus_scanner.rb
curate-0.1.2 app/services/anti_virus_scanner.rb
curate-0.1.1 app/services/anti_virus_scanner.rb
curate-0.1.0 app/services/anti_virus_scanner.rb