`exclude` supports `./tests` but not `tests` (with the default `.` target)

Open
#14 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
github-actions
Domain
ci-cd, security

Research direction

Reproduce the issue with a default target of . and exclude: tests, using a tests/ directory containing Bandit warnings. Trace the action's target and exclude handling; done means the scan omits files under tests/ while exclude: ./tests continues to work.

Written by the indexing model from the issue text.

Description

bug

Describe the bug
It took me way too long to figure out why exclude: tests didn't work. It seems that counter-intuitively tests doesn't work to exclude directories when the default target is ., presumably because Bandit sees the directory as ./tests and doesn't recognize that tests and ./tests refer to the same directory..

To Reproduce
Steps to reproduce the behavior:

  1. Have a tests/ subdirectory of files with some bandit issues.
  2. Specify exclude: tests
  3. Leave default target as .

Expected behavior
Bandit action doesn't report warnings for any files under tests/

Actual behavior
Bandit scans the tests and reports warnings.

Dominant language
No language data
Stars
32
Forks
16
Avg merge
2h 23m
Merged PRs (30d)
4

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from PyCQA/bandit-action

All issues in PyCQA/bandit-action

Similar issues

More DevOps issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.