Sha256: 48f2b13bb1e338e59f6a53971df114392bca5832055cb89544309d45cfa0f6f6
Contents?: true
Size: 866 Bytes
Versions: 16
Compression:
Stored size: 866 Bytes
Contents
module Sufia module GenericFile module VirusCheck extend ActiveSupport::Concern included do validate :detect_viruses end # Default behavior is to raise a validation error and halt the save if a virus is found def detect_viruses return unless content.changed? path = if content.content.respond_to?(:path) content.content.path else Tempfile.open('') do |t| t.binmode t.write(content.content) t.close t.path end end Sufia::GenericFile::Actions.virus_check(path) true rescue Sufia::VirusFoundError => virus logger.warn(virus.message) errors.add(:content, virus.message) false end end end end
Version data entries
16 entries across 16 versions & 2 rubygems