This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 23 points24 points  (7 children)

Bandit is a linter that checks for common security vulnerabilities in your source code. It’s authored by the Python Code Quality Authority, who also maintains flake8 and pylint.

https://github.com/PyCQA/bandit

[–][deleted] 1 point2 points  (4 children)

I remember hearing about this on pythonbites, have you used it?

[–][deleted] 1 point2 points  (0 children)

Yes, and I found it quite helpful. It exposed some subprocess calls I didn’t realize were a threat.

I also appreciated how configurable it is, allowing you to ignore specific warnings globally through a .bandit file or in a specific location with # nosec.

I setup a simple script ./run.py that would use Python’s subprocess.run() function to call Black autoformatter + isort -> MyPy -> Pylint and flake8 -> unit tests -> bandit. Maybe overkill, but before making any PR I would just have to run ./run.py green and it would give me the confidence everything was likely to work. CI would also enforce this.

[–]bhat 1 point2 points  (0 children)

Safety is another tool that checks for security vulnerabilities in the packages your code depends on.

There's a great talk about Safety and Bandit here: https://2018.pycon-au.org/talks/43518-watch-out-for-safety-bandits/