Bandit is a static analysis tool for finding common security issues in Python code. It is easy to use and does not require any changes to your source code. Simply run it from the terminal.
Here we have a tutorial on basic functions of bandit PYPI library:
- First we add the package to our project similar to other python libraries:
pip install bandit
- Then to scan a single app, go to the root of your project and write (both Win and MC):
bandit your_app_name.py
- To scan all the files in the root folder of your project:
bandit -r .
- You can save result of bandit test in a JSON or HTML file:
- for JSON:
bandit -r . -f json -o bandit-report.json
- for HTML:
bandit -r . -f html -o bandit-report.html
- If you have folders like test or venv that you want bandit to don't check them, you can use:
bandit -r . -x tests,venv
Notice: The commands work the same on Windows and macOS.
If you have any questions and problems, please leave a comment!
Top comments (0)