From d01b3356c614ded4588387cf0c548f52151652b0 Mon Sep 17 00:00:00 2001 From: Xavier J Date: Thu, 14 Apr 2016 17:29:26 +0200 Subject: [PATCH] Test 2 : io stream clamav analyse --- Rakefile | 4 ++-- app/services/clamav_service.rb | 8 +++++++- app/services/pieces_justificatives_service.rb | 6 ++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Rakefile b/Rakefile index 47d01467e..e9c354f09 100644 --- a/Rakefile +++ b/Rakefile @@ -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 diff --git a/app/services/clamav_service.rb b/app/services/clamav_service.rb index c1391d3f7..634ef9f17 100644 --- a/app/services/clamav_service.rb +++ b/app/services/clamav_service.rb @@ -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 \ No newline at end of file diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb index f7188a55d..6a3eb6db9 100644 --- a/app/services/pieces_justificatives_service.rb +++ b/app/services/pieces_justificatives_service.rb @@ -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})"+"
" end - unless ClamavService.safe_file? piece_justificative.content - end end end errors