Skip to content

Commit

Permalink
feat: implement trivy scanning of terraform modules (issues ignored)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkenez committed Jan 14, 2025
1 parent aecaa07 commit 9a65e23
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .lint/trivy/trivy-scan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -euxo pipefail

# list of the folders that we want to parse, only if a README.md exists and no .trivy_ignore
for dir in $(find modules -type d -maxdepth 1) $(find examples -type d -maxdepth 1); do
if [ -f "$dir/README.md" ] && ! [ -e "$dir/.trivy_ignore" ]; then
echo "Scanning terraform module with trivy: $dir"
trivy config --config .lint/trivy/trivy.yaml --ignorefile .trivyignore "$dir"
fi
done
9 changes: 9 additions & 0 deletions .lint/trivy/trivy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
quiet: false
debug: false
format: table
exit-code: 1

misconfiguration:
scanners:
- terraform
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,12 @@ repos:
rev: 0.2.3
hooks:
- id: yamlfmt

- repo: local
hooks:
- id: trivy-scan
name: Trivy Scan
entry: .lint/trivy/trivy-scan.sh
language: script
types: [terraform]
pass_filenames: false
1 change: 1 addition & 0 deletions .trivyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AVD-AWS-0178 #(MEDIUM): VPC does not have VPC Flow Logs enabled.
Empty file added modules/fixtures/.trivy_ignore
Empty file.

0 comments on commit 9a65e23

Please sign in to comment.