Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclusion filter not working correctly with relative paths #975

Open
kenahoo opened this issue Dec 14, 2022 · 0 comments · May be fixed by #1028
Open

Exclusion filter not working correctly with relative paths #975

kenahoo opened this issue Dec 14, 2022 · 0 comments · May be fixed by #1028
Labels
bug Something isn't working

Comments

@kenahoo
Copy link

kenahoo commented Dec 14, 2022

Describe the bug

An exclusion filter like -x ./.tox seems to work as desired, but -x .tox doesn't exclude the same directory. I couldn't find any docs on what the exact syntax of exclusion filters should be, so I'd assume both are supported.

Reproduction steps

  1. Have a large .tox folder at the root level of a project

  2. Run bandit -x ./.tox -ll -f json -o bandit.json -r . and observe that 94 (or some other small number) of things will be scanned

% bandit -x ./.tox -ll -f json -o bandit.json -r .
[main]	INFO	profile include tests: None
[main]	INFO	profile exclude tests: None
[main]	INFO	cli include tests: None
[main]	INFO	cli exclude tests: None
94 [0.. 50.. ]
[json]	INFO	JSON output written to file: bandit.json
  1. Run bandit -x .tox -ll -f json -o bandit.json -r . and observe that 19282 (or some other large number) of things will be scanned
% bandit -x .tox -ll -f json -o bandit.json -r . 
[main]	INFO	profile include tests: None
[main]	INFO	profile exclude tests: None
[main]	INFO	cli include tests: None
[main]	INFO	cli exclude tests: None
19282 [0.. 50.. ^C

Expected behavior

The two exclusion filters should be equivalent.

Bandit version

1.7.4 (Default)

Python version

3.9

Additional context

The danger of this bug is that files/directories might be unintentionally included/excluded, rendering reports inaccurate.

@kenahoo kenahoo added the bug Something isn't working label Dec 14, 2022
b-kamphorst added a commit to b-kamphorst/bandit that referenced this issue May 11, 2023
b-kamphorst added a commit to b-kamphorst/bandit that referenced this issue May 11, 2023
b-kamphorst added a commit to b-kamphorst/bandit that referenced this issue May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant