demarches-normaliennes/app/services/clamav_service.rb
2019-02-05 12:50:27 +01:00

15 lines
509 B
Ruby

class ClamavService
def self.safe_file?(file_path)
if Rails.env.development?
Rails.logger.info("Rails.env = development => fake scan") # FIXME : remove me
return true
end
FileUtils.chmod(0666, file_path)
client = ClamAV::Client.new
response = client.execute(ClamAV::Commands::ScanCommand.new(file_path))
Rails.logger.info("ClamAV response for #{file_path} : #{response.first.class.name}") # FIXME : remove me
response.first.class != ClamAV::VirusResponse
end
end