Pre-commit hook fails: "unknown test found in profile"; Manual run from same config works.

Aperta
#1,480 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
67/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
security, tooling

Direzione di ricerca

Start by tracing how the Bandit pre-commit hook loads pyproject.toml and handles the skips setting; compare that path with the manual bandit -c pyproject.toml -r . invocation. Reproduce with the provided configuration and Bandit 1.9.1, then check the hook against the expected behavior: it should run successfully with the same config as the manual command.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
Describe the bug

In a project where bandit -c pyproject.toml runs without finding any problems, your pre-commit hook falls over a skips line in the TOML file.

Reproduction steps
% sed -ne '/tool.bandit/,$p' pyproject.toml
[tool.bandit]
exclude_dirs = ['.direnv']
skips = ["B106"]           # do not check for hardcoded passwords anywhere

[tool.bandit.assert_used]
skips = ['*/tests/**.py', '*/integration/**.py']

% bandit -q -c pyproject.toml -r .

% echo Yay, no errors!
Yay, no errors!
% sed -ne '/bandit/,$p' .pre-commit-config.yaml
  - repo: https://github.com/PyCQA/bandit
    rev: 1.7.9
    hooks:
      - id: bandit
        args: ["-c", "pyproject.toml"]  # same invocation as above!

% pre-commit run bandit --all-files
bandit...................................................................Failed
- hook id: bandit
- exit code: 2

[main]	INFO	profile include tests: None
[main]	INFO	profile exclude tests: B106
[main]	INFO	cli include tests: None
[main]	INFO	cli exclude tests: None
[main]	ERROR	Unknown test found in profile: B106
Expected behavior

I'd expect the pre-commit run to be identical to the manual one.

Bandit version

1.9.1 (Default)

Python version

3.14 (Default)

Additional context

Bandit 1.9.4

Lingua principale
Python
Stelle
8.4k
Fork
893
Merge medio
6h 52m
PR unite (30g)
3

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PyCQA/bandit

Tutte le issue di PyCQA/bandit

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.