https://github.com/mxab/pre-commit-trivy
https://github.com/mxab/pre-commit-trivy
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mxab/pre-commit-trivy
- Owner: mxab
- License: mit
- Created: 2022-11-19T07:42:39.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-04-03T09:14:09.000Z (over 1 year ago)
- Last Synced: 2025-04-03T10:24:12.690Z (over 1 year ago)
- Size: 15.6 KB
- Stars: 22
- Watchers: 2
- Forks: 12
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pre-commit-trivy
Add this to your [pre-commit](https://pre-commit.com/) `.pre-commit-config.yaml` config.
You can use [trivy fs flags](https://trivy.dev/docs/v0.68/guide/target/filesystem/) to configure Trivy filesytem scans.
Insert the required flags in the `args` field.
You can also use the `trivyconfig-docker` to scan for misconfigurations [trivy config](https://trivy.dev/docs/v0.68/guide/scanner/misconfiguration/)
## trivyfs-docker
pre-commit will use the `aquasec/trivy:0.68.2` docker image and run it inside a docker container.
```yaml
repos:
- repo: https://github.com/mxab/pre-commit-trivy.git
rev: v0.17.0
hooks:
- id: trivyfs-docker
args:
- --skip-dirs
- ./tests
- . # last arg indicates the path/file to scan
- id: trivyconfig-docker
args:
- --skip-dirs
- ./tests
- . # last arg indicates the path/file to scan
```
### Cache
The hook will create a cache directory `.pre-commit-trivy-cache` in your repo. Add it to the `.gitignore`.
```
echo ".pre-commit-trivy-cache" >> .gitignore
```
## Example
You can find a sample use case here https://github.com/mxab/trivy-pre-commit-demo