Skip to content

Commit

Permalink
Merge pull request #1046 from Silvest89/add-linter-workflow
Browse files Browse the repository at this point in the history
feat: add linter workflow
  • Loading branch information
mysticaltech authored Oct 22, 2023
2 parents 8739c6b + 3e2d1ba commit 9bf0caf
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/lint_pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Lint

on:
pull_request:

jobs:
tfsec:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
name: Scan terraform files with tfsec
steps:
- name: Clone repo
uses: actions/checkout@v4

- name: tfsec
uses: aquasecurity/tfsec-pr-commenter-action@v1.3.1
with:
github_token: ${{ github.token }}
# tfsec does not support terraform 1.5+ (import) blocks,
tfsec_args: --ignore-hcl-errors
# In addition to the Aqua one, run reviewdog Tfsec as well
# as it provides more context and can pickup security issues
# in underlying modules (more similar to locally running tfsec)
- name: Run tfsec with reviewdog output on the PR
uses: reviewdog/action-tfsec@master
with:
github_token: ${{ secrets.github_token }}
# level: info # Get more output from reviewdog
# reporter: github-pr-review # Change reviewdog reporter
filter_mode: nofilter # Check all files, not just the diff
fail_on_error: true # Fail action if errors are found
tfsec_flags: --ignore-hcl-errors
validate:
runs-on: ubuntu-latest
name: Validate terraform configuration
steps:
- name: Checkout
uses: actions/checkout@v4

- name: terraform validate
uses: dflook/terraform-validate@v1
fmt-check:
runs-on: ubuntu-latest
name: Check formatting of terraform files
steps:
- name: Checkout
uses: actions/checkout@v4

- name: terraform fmt
uses: dflook/terraform-fmt-check@v1
trivy:
name: Trivy security scanning
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@master
with:
scan-type: 'config'
hide-progress: false
format: 'sarif'
output: 'trivy-results.sarif'
exit-code: '1'
ignore-unfixed: true
severity: 'CRITICAL,HIGH'

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'

0 comments on commit 9bf0caf

Please sign in to comment.