Does bandit support scanning Jupyter Notebook .ipynb file? #990
|
Does bandit support scanning Jupyter Notebook .ipynb file? |
Replies: 2 comments
|
Yes. For example: bandit /path/to/notebook.ipynb or
[tool.bandit]
include = ["*.ipynb"]
bandit -r . -c pyproject.toml Ref: yaml config |
|
Changing my answer to yes: run |
No is the answer.I have experimented with this, and even though technically it does "scan" the files, and reports lines of code scanned - it does not in fact interpret the (escaped) python code contained and so does not report any issues where it should.I tried this by pasting some examples of known errors from this repo in both a python file, and an iPython notebook file, the python file gave results as expected, while the notebook did not.I believe to support this would require bandit knowing about how to extract code cells from a notebook file, un-escaping them and then parsing the contents of that (while preserving the source line numbers) into the AST, so it can actually process t…