Skip tests folder on pre-commit
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.3k
- Forks
- 836
- Avg merge
- 5d 3h
- Merged PRs (30d)
- 1
Description
Describe the bug
running bandit --configfile bandit.yaml -r . test folders are correctly ignored according to the settings present in bandit.yaml, however this configuration with the pre-commit is ignored.
Reproduction steps
bandit.yaml:
exclude_dirs:
- '/tests'
- '/venv'
.pre-commit-config.yaml:
repos:
- repo: https://github.com/PyCQA/bandit
rev: 1.7.4
hooks:
- id: bandit
args: ["--configfile", "bandit.yaml", "-r", "."]
stages: [commit]
Expected behavior
It is expected that with pre-commit the folders indicated in exclude_dirs will also be ignored.
Bandit version
1.7.4 (Default)
Python version
3.7
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the command from the issue with bandit.yaml and .pre-commit-config.yaml, comparing direct Bandit execution with the pre-commit hook. Trace how the hook handles --configfile, -r, and the configured exclude_dirs; done means test folders are skipped through pre-commit as they are in the direct command.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100