Test 2 : io stream clamav analyse

This commit is contained in:
Xavier J 2016-04-14 17:29:26 +02:00
parent 1a3c19f48c
commit d01b3356c6
3 changed files with 13 additions and 5 deletions

View file

@ -13,8 +13,8 @@ task :deploy do
end
task :deploy_test do
domains = %w(test_sgmap)
branch = 'master'
domains = %w(192.168.0.116)
branch = 'clamav'
domains.each do |domain|
sh "mina deploy domain=#{domain} branch=#{branch}"
end

View file

@ -1,6 +1,12 @@
class ClamavService
def self.safe_file? path
def self.safe_io_data? io_data
client = ClamAV::Client.new
io = StringIO.new(io_data)
response = client.execute(ClamAV::Commands::InstreamCommand.new(io))
puts response
end
end

View file

@ -5,6 +5,10 @@ class PiecesJustificativesService
dossier.types_de_piece_justificative.each do |type_de_pieces_justificatives|
unless params["piece_justificative_#{type_de_pieces_justificatives.id}"].nil?
unless ClamavService.safe_io_data? params["piece_justificative_#{type_de_pieces_justificatives.id}"].content
end
piece_justificative = PieceJustificative.new(content: params["piece_justificative_#{type_de_pieces_justificatives.id}"],
dossier: dossier,
type_de_piece_justificative: type_de_pieces_justificatives,
@ -14,9 +18,7 @@ class PiecesJustificativesService
errors << piece_justificative.errors.messages[:content][0]+" (#{piece_justificative.libelle})"+"<br>"
end
unless ClamavService.safe_file? piece_justificative.content
end
end
end
errors