Skip to content

Commit 06f3820

Browse files
jmfiolaJacob Fiola
andauthored
Adding nightly and PR trivy scans (#11)
* initial commit * test pr scan functionality * update action path * test vuln fix behavior * test create issue * update fmt, re-add vuln fix * test issue create * print trivy report to log * trivy report consolidation * test failure once more * test again * fix the vuln * update github issue step to only be for schedules on main * trivy report file condition update * allow for legacy metadata service use * use shared action repo * test for issue creation from shared actions repo * re-add to .trivyignore file, test complete --------- Co-authored-by: Jacob Fiola <[email protected]>
1 parent 2bc9429 commit 06f3820

File tree

5 files changed

+52
-0
lines changed

5 files changed

+52
-0
lines changed

.github/workflows/fmt:check.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ jobs:
2323
terraform_version: "1.8.2"
2424
- name: Terraform fmt
2525
run: task fmt:check
26+

.github/workflows/scan:trivy.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Trivy Terraform Scan
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
schedule:
7+
- cron: '0 3 * * *' # Nightly at 03:00 UTC
8+
workflow_dispatch:
9+
10+
jobs:
11+
trivy:
12+
runs-on: ubuntu-latest
13+
14+
permissions:
15+
contents: read
16+
issues: write
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Trivy scan
22+
uses: corelight/shared-actions/trivy-terraform-scan@main

Taskfile.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ tasks:
1111
desc: Check if the input is formatted
1212
cmds:
1313
- terraform fmt -recursive -check -diff .
14+
15+
trivy:scan:
16+
desc: Scan Terraform files with Trivy
17+
cmds:
18+
- trivy fs --config scripts/trivy/trivy.yml .

scripts/trivy/.trivyignore.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
misconfigurations:
2+
- id: AVD-AWS-0104
3+
statement: public egress traffic is allowed to the internet
4+
- id: AVD-AWS-0130
5+
statement: allow for legacy metadata service use

scripts/trivy/trivy.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
scan:
2+
security-checks:
3+
- secret
4+
- config
5+
6+
ignorefile: scripts/trivy/.trivyignore.yml
7+
8+
severity:
9+
- HIGH
10+
- CRITICAL
11+
12+
misconfiguration:
13+
scanners:
14+
- terraform
15+
config:
16+
terraform:
17+
file_patterns:
18+
- "**/*.tf"
19+
ignore_unfixed: true

0 commit comments

Comments
 (0)