2016-04-14 16:50:13 +02:00
|
|
|
class ClamavService
|
2016-04-15 15:32:15 +02:00
|
|
|
def self.safe_file? path_file
|
2016-04-20 16:51:57 +02:00
|
|
|
if Rails.env == 'development'
|
|
|
|
return CLAMAV[:response] if CLAMAV[:mock?]
|
|
|
|
end
|
|
|
|
|
2016-04-15 15:32:15 +02:00
|
|
|
FileUtils.chmod 0666, path_file
|
2016-04-14 16:50:13 +02:00
|
|
|
|
2016-04-15 15:32:15 +02:00
|
|
|
client = ClamAV::Client.new
|
2016-04-14 17:43:27 +02:00
|
|
|
response = client.execute(ClamAV::Commands::ScanCommand.new(path_file))
|
2016-04-14 17:29:26 +02:00
|
|
|
|
2016-04-15 15:32:15 +02:00
|
|
|
return false if response.first.class == ClamAV::VirusResponse
|
|
|
|
true
|
2016-04-14 16:50:13 +02:00
|
|
|
end
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|