2016-04-14 16:50:13 +02:00
|
|
|
class ClamavService
|
2018-03-20 17:47:37 +01:00
|
|
|
def self.safe_file?(file_path)
|
2018-12-18 21:30:02 +01:00
|
|
|
if Rails.env.development?
|
2019-02-05 12:41:31 +01:00
|
|
|
Rails.logger.info("Rails.env = development => fake scan") # FIXME : remove me
|
2018-11-22 00:46:49 +01:00
|
|
|
return true
|
2016-04-20 16:51:57 +02:00
|
|
|
end
|
|
|
|
|
2018-12-18 21:29:31 +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))
|
2019-02-05 12:41:31 +01:00
|
|
|
Rails.logger.info("ClamAV response for #{file_path} : #{response.first.class.name}") # FIXME : remove me
|
2018-12-18 21:30:08 +01:00
|
|
|
response.first.class != ClamAV::VirusResponse
|
2016-04-14 16:50:13 +02:00
|
|
|
end
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|