demarches-normaliennes/app/services/clamav_service.rb
2017-11-16 12:28:07 +01:00

15 lines
375 B
Ruby

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