Open costaparas opened 1 year ago
The warning text "WARNING nosec encountered (X), but no failed test on line Y" incorrectly appears in some cases. It may also appear more than once for the same line number and test under specific circumstances.
Consider this base code:
import shlex import subprocess proc = subprocess.Popen(args=shlex.split("ffmpeg -i file.mp3"))
Since there are 2 function calls on this line of code, there are 2 calls to run_tests in bandit/core/issue.py.
run_tests
bandit/core/issue.py
If we include a nosec comment specifying the correct test to ignore (i.e. B603):
nosec
B603
import shlex import subprocess proc = subprocess.Popen(args=shlex.split("ffmpeg -i file.mp3")) # nosec: B603
the following warning text displays:
WARNING nosec encountered (B603), but no failed test on line 3
If we include a nosec comment specifying something else (e.g. B602):
B602
import shlex import subprocess proc = subprocess.Popen(args=shlex.split("ffmpeg -i file.mp3")) # nosec: B602
WARNING nosec encountered (B602), but no failed test on line 3 WARNING nosec encountered (B602), but no failed test on line 3
1.7.5 (Default)
3.10
No response
possible duplicate of #942 ?
Partially, yes. But #942 does not explicitly mention the case where you may get duplicate warning text. They are closely related issues.
Describe the bug
The warning text "WARNING nosec encountered (X), but no failed test on line Y" incorrectly appears in some cases. It may also appear more than once for the same line number and test under specific circumstances.
Reproduction steps
Consider this base code:
Since there are 2 function calls on this line of code, there are 2 calls to
run_tests
inbandit/core/issue.py
.If we include a
nosec
comment specifying the correct test to ignore (i.e.B603
):the following warning text displays:
If we include a
nosec
comment specifying something else (e.g.B602
):the following warning text displays:
Expected behavior
Bandit version
1.7.5 (Default)
Python version
3.10
Additional context
No response