Closed EstevamArantes closed 10 months ago
So you will get the same result if you run:
python pocFile.py
However, if a Python file contains UTF-8 characters, then it must be specified in the header:
# -*- coding: utf-8 -*-
That will fix the case using python
, but unfortunately Bandit still fails.
@ericwb As of Python 3, utf-8 is the default encoding of source code, and doesn't have to be declared even if the source code contains non-ascii characters. However the example above involves a non-utf-8 encoded character.
@EstevamArantes What you have there is the Â
character encoded in latin_1
(aka iso-8859-1
). This encoding must be declared at the beginning of the file.
https://docs.python.org/3/reference/lexical_analysis.html#encoding-declarations
That said, I think this is not a bandit issue and can be closed.
Agree with @mportesdev here. Encoding should be declared in header if not utf-8.
Describe the bug
Bandit fails and crashes (skipping file) when trying to decode/parse character that isn't utf-8.
xxd file that causes bug:
Execute
bandit --debug pocFile.py
Reproduction steps
poc.txt
> pocFile.pybandit --debug pocFile.py
Expected behavior
Bandit executes as usual and doesn't crash.
Bandit version
1.7.4 (Default)
Python version
3.10 (Default)
Additional context
Bandit 1.7.5, just cloned from main today.