Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Bandit write to a file then read it to avoid problems with warni… #139

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/glue/tasks/bandit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}/"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use tmpdir for multi-platform support? Also, might be nice to allow the user to override the location.
Also, are all users allows to write there?

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
Expand Down