From 881af5a1868bf2a58940fc8ccfb26d7c97640236 Mon Sep 17 00:00:00 2001 From: Matt Konda Date: Sat, 13 Oct 2018 16:54:58 -0500 Subject: [PATCH] Make Bandit write to a file then read it to avoid problems with warnings. --- lib/glue/tasks/bandit.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/glue/tasks/bandit.rb b/lib/glue/tasks/bandit.rb index a9bec39..8c09baf 100644 --- a/lib/glue/tasks/bandit.rb +++ b/lib/glue/tasks/bandit.rb @@ -18,7 +18,13 @@ def initialize(trigger, tracker) def run rootpath = @trigger.path - @result=runsystem(true, "bandit", "-f", "json", "-r", "#{rootpath}") + context = SecureRandom.uuid + @tmppath = "/tmp/#{context}/" + Dir.mkdir @tmppath + # https://docs.openstack.org/bandit/latest/man/bandit.html?highlight=verbose + runsystem(true, "bandit", "-f", "json", "-o", "#{@tmppath}/bandit.json","-r", "#{rootpath}") + file = File.open("#{@tmppath}/bandit.json", "rb") + @result= file.read end def analyze