PyCQA / PyCQA/bandit

Excluded paths from the .ini file ignored if -x flag is set

Open
#753 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the bug

Bandit 1.7.1 no longer appends CLI-provided excluded paths to those provided in the .ini file, but rather substitutes the excluded paths list, which contradicts the doc: note that these are in addition to the excluded paths provided in the config file

Reproduction steps
  1. Create .ini file with a couple of excluded paths
[bandit]
exclude = src/lib
recursive = true
targets = src
  1. Run bandit with both ini file and -x flags provided: bandit --ini .config -x 'test'
Expected behavior

Bandit will exclude both ini-provided and cli-provided paths

Bandit version

1.7.0 (Default)

Python version

3.9 (Default)

Additional context

I'm setting bandit version to 1.7.0 as 1.7.1 is not available in the GitHub dropdown (though it is available at PyPi at https://pypi.org/project/bandit/1.7.1/)

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

Reproduce the issue with the shown .ini file and bandit --ini .config -x 'test'. Trace the CLI option and configuration loading paths to find where the excluded-path list is replaced, then verify that the completed change preserves both the .ini and -x paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.