0

I'm using the following package: https://github.com/PyCQA/bandit to perform some static analysis on runtime. Currently I do the following:

subprocess.Popen(['bandit', '-r', full_path], stdout=subprocess.PIPE)

But I'm trying to move away from using subprocess.Popen, is it possible to natively call bandit in python? Something like

from bandit import ...
run_bandit(directory, recursive=True)
Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
Stupid.Fat.Cat
  • 10,755
  • 23
  • 83
  • 144
  • 1
    take a look at what the cli does and try to mimic the parts you need from that (https://github.com/PyCQA/bandit/blob/master/bandit/cli/main.py) – acushner Jul 01 '20 at 01:16
  • 1
    It looks like you should be able to run bandit.cli.main.main() in Python, but I haven't tested it. I think you would have to fake the command line arguments in sys.argv. – Dennis Sparrow Jul 01 '20 at 01:25

0 Answers0