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
|
end
|
||||||
|
|
||||||
task :deploy_test do
|
task :deploy_test do
|
||||||
domains = %w(test_sgmap)
|
domains = %w(192.168.0.116)
|
||||||
branch = 'master'
|
branch = 'clamav'
|
||||||
domains.each do |domain|
|
domains.each do |domain|
|
||||||
sh "mina deploy domain=#{domain} branch=#{branch}"
|
sh "mina deploy domain=#{domain} branch=#{branch}"
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
class ClamavService
|
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
|
||||||
end
|
end
|
|
@ -5,6 +5,10 @@ class PiecesJustificativesService
|
||||||
dossier.types_de_piece_justificative.each do |type_de_pieces_justificatives|
|
dossier.types_de_piece_justificative.each do |type_de_pieces_justificatives|
|
||||||
unless params["piece_justificative_#{type_de_pieces_justificatives.id}"].nil?
|
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}"],
|
piece_justificative = PieceJustificative.new(content: params["piece_justificative_#{type_de_pieces_justificatives.id}"],
|
||||||
dossier: dossier,
|
dossier: dossier,
|
||||||
type_de_piece_justificative: type_de_pieces_justificatives,
|
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>"
|
errors << piece_justificative.errors.messages[:content][0]+" (#{piece_justificative.libelle})"+"<br>"
|
||||||
end
|
end
|
||||||
|
|
||||||
unless ClamavService.safe_file? piece_justificative.content
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
errors
|
errors
|
||||||
|
|
Loading…
Reference in a new issue