Skip to content

Commit bafa0f8

Browse files
authored
Add Pre-Commit Hook (#256)
- Add a pip-audit pre-commit hook - Use the `pass_filenames: false` so user has to specify args - Add section with example usage to README.md Test: - Run with bandersnatch pre-commit pointed @ https://github.com/cooperlees/pip-audit ```shell cooper-mbp:bandersnatch cooper$ ~/venvs/bs/bin/pre-commit run -a [INFO] Initializing environment for [email protected]:cooperlees/pip-audit.git. [INFO] Installing environment for [email protected]:cooperlees/pip-audit.git. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... ... pip-audit................................................................Passed ```
1 parent b418f64 commit bafa0f8

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

.pre-commit-hooks.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
- id: pip-audit
2+
name: pip-audit
3+
description: "Audits Python environments and dependency trees for known vulnerabilities"
4+
entry: pip-audit
5+
pass_filenames: false
6+
language: python

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,20 @@ and purposes, `pip-audit -r INPUT` is functionally equivalent to
303303
`pip install -r INPUT`, with a small amount of **non-security isolation** to
304304
avoid conflicts with any of your local environments.
305305

306+
## pre-commit support
307+
308+
pip-audit has [pre-commit](https://pre-commit.com/) support. Please specify your
309+
arguments in your pre-commit config. An example config using requirements file can be:
310+
311+
```yaml
312+
- repo: https://github.com/trailofbits/pip-audit
313+
rev: v2.1.2
314+
hooks:
315+
- id: pip-audit
316+
args: ["-r", "requirements.txt"]
317+
```
318+
- Any valid CLI arguments documented above can be passed.
319+
306320
## Licensing
307321
308322
`pip-audit` is licensed under the Apache 2.0 License.

0 commit comments

Comments
 (0)