Skip to content

Commit b674521

Browse files
ci(infra): run tfsec + checkov on Terraform plan in CI
Add IaC security scanning gate that runs tfsec and checkov against all Terraform changes on pull requests and pushes to main. - .github/workflows/terraform-scan.yml: CI workflow with two parallel jobs running tfsec and checkov against infrastructure/terraform/ directory - infrastructure/terraform/.tfsec.yml: tfsec config enforcing HIGH minimum severity Closes #166
1 parent 0043dab commit b674521

2 files changed

Lines changed: 78 additions & 0 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Terraform Security Scan
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
paths:
7+
- 'infrastructure/terraform/**'
8+
push:
9+
branches: [main]
10+
paths:
11+
- 'infrastructure/terraform/**'
12+
workflow_dispatch:
13+
14+
# Cancel any previous in-progress run for the same ref so superseded
15+
# commits on a PR don't waste runner minutes.
16+
concurrency:
17+
group: terraform-scan-${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
permissions:
21+
contents: read
22+
23+
env:
24+
TF_WORKING_DIR: infrastructure/terraform
25+
26+
jobs:
27+
# -------------------------------------------------------------------------
28+
# tfsec – static analysis of Terraform templates for security
29+
# misconfigurations. Reads .tfsec.yml from the working directory to
30+
# determine minimum severity (HIGH / CRITICAL).
31+
# -------------------------------------------------------------------------
32+
tfsec:
33+
name: tfsec
34+
runs-on: ubuntu-latest
35+
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v4
39+
40+
- name: Run tfsec
41+
uses: aquasecurity/tfsec-action@v1.0.3
42+
with:
43+
working_directory: ${{ env.TF_WORKING_DIR }}
44+
# soft_fail: false causes the step to exit with code 1 (and fail the
45+
# job) when any finding at or above the configured severity exists.
46+
soft_fail: false
47+
format: table
48+
49+
# -------------------------------------------------------------------------
50+
# checkov – comprehensive policy-as-code scanner covering CIS benchmarks,
51+
# HIPAA, GDPR, and hundreds of built-in Terraform / K8s rules.
52+
# -------------------------------------------------------------------------
53+
checkov:
54+
name: checkov
55+
runs-on: ubuntu-latest
56+
57+
steps:
58+
- name: Checkout
59+
uses: actions/checkout@v4
60+
61+
- name: Run checkov
62+
uses: bridgecrewio/checkov-action@v12
63+
with:
64+
directory: ${{ env.TF_WORKING_DIR }}
65+
framework: terraform
66+
# soft_fail: false causes the step to exit with code 1 when
67+
# checkov finds any FAILED evaluation (skipped / passed checks
68+
# do not affect the exit code).
69+
soft_fail: false
70+
# Use CLI output for a human-readable scan summary in the action log.
71+
output_format: cli
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# tfsec configuration for VertexChain Terraform infrastructure
2+
# Used by CI (terraform-scan.yml) to gate on HIGH/CRITICAL findings.
3+
#
4+
# For the full list of options see:
5+
# https://aquasecurity.github.io/tfsec/latest/guides/configuration/config/
6+
7+
minimum_severity: HIGH

0 commit comments

Comments
 (0)