Skip to content

Exclude paths in config file ignored if passing specific files to Bandit CLI #499

@dolan-a

Description

@dolan-a

UPDATE: please see my below comment for an updated description of the problem.

Describe the bug
When using the pre-commit hook, my excluded paths listed in .bandit are still processed by bandit.

To Reproduce
Steps to reproduce the behavior:

  1. Create a .bandit config file with exclusions. For example:
    [bandit]
    exclude: ./node_modules/*,./tests/*
  2. Run bandit via command line (bandit -r .), verify exclusions ignored.
  3. Run bandit on all files via pre-commit hook: pre-commit run --all-files bandit
  4. See that excluded files are processed by bandit

Expected behavior
I expect the excluded paths to be ignored.

Bandit version

bandit 1.6.0
  python version = 3.7.3 (default, May 27 2019, 05:16:50) [Clang 10.0.0 (clang-1000.10.44.4)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions