demarches-normaliennes/app/services/clamav_service.rb
2017-06-13 10:35:33 +02:00

15 lines
375 B
Ruby

class ClamavService
def self.safe_file? path_file
if Rails.env == 'development'
return CLAMAV[:response] if CLAMAV[:mock?]
end
FileUtils.chmod 0666, path_file
client = ClamAV::Client.new
response = client.execute(ClamAV::Commands::ScanCommand.new(path_file))
return false if response.first.class == ClamAV::VirusResponse
true
end
end