Test 2 : io stream clamav analyse
This commit is contained in:
parent
1a3c19f48c
commit
d01b3356c6
3 changed files with 13 additions and 5 deletions
4
Rakefile
4
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
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue