-
-
Notifications
You must be signed in to change notification settings - Fork 616
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
Interpret wildcards in the file exclusion list #450
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also update the README which states:
-x EXCLUDED_PATHS, --exclude EXCLUDED_PATHS
comma-separated list of paths to exclude from scan
(note that these are in addition to the excluded paths
provided in the config file)
exclude_dirs - sections of the path, that if matched, will be excluded from scanning
exclude: comma separated list of excluded paths
And also the man page for the CLI.
This allows to specify wildcards in the excluded files list, which in turns makes it possible to use Bandit in projects where test files are not in a separate repository, but have just a name prefixed with test_ (as is common with Pytest).
@ericwb Thanks, what do you think about it now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@ericwb Are u planning a release soon? Cuz I need this feature quite badly as my tests are in the same folders as my sources. |
@thilp when using I find this rather unintuitive, was it intended? |
Fix #345.
Hello,
This PR changes
_is_file_included
so that it also usesfnmatch
on theexcluded_path_strings
argument, allowing that list to contain wildcards.Rationale:
My projects use Codacy, which in turn relies on Bandit. However, they also have test files mixed with source files, the only difference being that their name is prefixed with
test_
. The result is that Bandit (and therefore Codacy) is unusable on these projects, because they report hundreds of irrelevant “Use ofassert
detected”. I figured it would be easier (and safer) to add this feature than deactivate Bandit altogether.I'm very new to the project so I may have made errors. Please point them out! I would really like to see this feature integrated soon in this nice tool.