Add python-check-blanket-nosec hook for bandit#96
Open
mkniewallner wants to merge 1 commit intopre-commit:mainfrom
Open
Add python-check-blanket-nosec hook for bandit#96mkniewallner wants to merge 1 commit intopre-commit:mainfrom
python-check-blanket-nosec hook for bandit#96mkniewallner wants to merge 1 commit intopre-commit:mainfrom
Conversation
asottile
reviewed
Mar 1, 2022
| - id: python-check-blanket-nosec | ||
| name: check blanket nosec | ||
| description: 'Enforce that bandit `nosec` annotations always occur with specific codes. Sample annotations: `# nosec: B101`, `# nosec: B101,B102`' | ||
| entry: '# *nosec(?!: *\w)' |
Member
There was a problem hiding this comment.
is there a reason this is different from the noqa pattern?
Author
There was a problem hiding this comment.
It is to have something similar to bandit regex (https://github.com/PyCQA/bandit/blob/5747e306262d71aca46542f71c6fda116de98b6c/bandit/core/manager.py#L25), though for consistency it may indeed be nice to have something closer to noqa pattern (maybe without (?i), as nosec is case sensitive).
|
I just posted a nearly identical PR before seeing this one. 🤦 Here is the regex I came up with: pygrep-hooks/.pre-commit-hooks.yaml Line 10 in 092e4e0 |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Version 1.7.3 of Python SAST tool bandit added support for disabling individual tests in PyCQA/bandit#597.
It is now possible to disable specific codes like so:
I thought that this could be a nice thing to have in this project.