PyCQA / PyCQA/bandit

Unclear FAQ entry regarding "Under Which Version of Python Should I Install Bandit?"

Open
#1,375 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
8.3k
Forks
836
Avg merge
5d 3h
Merged PRs (30d)
1

Description

While I appreciate that there is a FAQ entry about this topic, the entry is unfortunately a bit vague.

While there are some recommendations

If your project is only compatible with Python 3.9, you should install Bandit to run under Python 3.9. If your project is only compatible with Python 3.10, then use 3.10 respectively. If your project supports both, you could run Bandit with both versions but you don’t have to.

And

Bandit uses the ast module from Python’s standard library in order to analyze your Python code. The ast module is only able to parse Python code that is valid in the version of the interpreter from which it is imported. In other words, if you try to use Python 2.7’s ast module to parse code written for 3.5 that uses, for example, yield from with asyncio, then you’ll have syntax errors that will prevent Bandit from working properly. Alternatively, if you are relying on 2.7’s octal notation of 0777 then you’ll have a syntax error if you run Bandit on 3.x.

I am still puzzled whether for library which is compatible e.g. with Python 3.8 - Python 3.12, whether we need to run bandit on all versions, or whether running bandit on Python 3.12 is enough - given, there are no syntax errors as mentioned in the FAQ.

Would the latest version of Bandit, which does not support Python3.8 as of the python_requires in the build config, still detect all vulnerabilities in a library written for Python 3.8?

I would not want to use an older version of bandit, as then we might miss checks added with later versions.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the FAQ entry quoted in the issue and check the build configuration's python_requires value. Clarify whether Bandit must run across every supported Python version, whether the latest Bandit can analyze Python 3.8 code, and how users should choose a version; done means the FAQ answers these cases without ambiguity.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.