demarches-normaliennes/app/services/clamav_service.rb

21 lines
409 B
Ruby
Raw Normal View History

2016-04-14 16:50:13 +02:00
class ClamavService
def self.safe_file?(file_path)
if Rails.env == 'development'
2018-10-01 13:24:37 +02:00
if CLAMAV[:mock?]
return CLAMAV[:response]
end
end
2017-10-30 17:23:55 +01:00
FileUtils.chmod 0666, file_path
2016-04-14 16:50:13 +02:00
2016-04-15 15:32:15 +02:00
client = ClamAV::Client.new
2017-10-30 17:23:55 +01:00
response = client.execute(ClamAV::Commands::ScanCommand.new(file_path))
2016-04-14 17:29:26 +02:00
2018-10-01 13:24:37 +02:00
if response.first.class == ClamAV::VirusResponse
return false
end
2016-04-15 15:32:15 +02:00
true
2016-04-14 16:50:13 +02:00
end
2017-04-04 15:27:04 +02:00
end