Skip to content

Commit d3dc675

Browse files
authored
bump pre-commit checks and move to trivy (#95)
* bump pre-commit checks and move to trivy * fix trivy * update check * update check * update check * update check
1 parent 9b3ba04 commit d3dc675

File tree

13 files changed

+64
-87
lines changed

13 files changed

+64
-87
lines changed

.github/workflows/pre-commit.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: pre-commit-check
33
on:
44
push:
55
branches:
6+
- main
67
- master
78
- prod
89
- develop

.github/workflows/pullRequest.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
terraform_tflint_deep,
2525
no-commit-to-branch,
2626
terraform_tflint_nocreds,
27-
terraform_tfsec
27+
terraform_trivy
2828
tflint:
2929
runs-on: ubuntu-latest
3030
steps:
@@ -41,7 +41,7 @@ jobs:
4141
filter_mode: added
4242
flags: --module
4343
level: error
44-
tfsec:
44+
trivy:
4545
runs-on: ubuntu-latest
4646
steps:
4747
- uses: actions/checkout@v2

.github/workflows/tfsec.yaml

Lines changed: 0 additions & 26 deletions
This file was deleted.

.github/workflows/trivy.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: trivy
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
trivy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Install prerequisites
14+
run: ./bin/install-ubuntu.sh
15+
- name: Terraform init
16+
run: terraform init --backend=false
17+
- name: Trivy scan
18+
uses: aquasecurity/trivy-action@master
19+
with:
20+
scan-type: 'config'
21+
hide-progress: false
22+
format: 'sarif'
23+
output: 'trivy-results.sarif'
24+
exit-code: '1'
25+
ignore-unfixed: true
26+
severity: 'CRITICAL,HIGH'
27+
28+
- name: Upload Trivy scan results to GitHub Security tab
29+
uses: github/codeql-action/upload-sarif@v2
30+
with:
31+
sarif_file: 'trivy-results.sarif'

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,3 @@
1313

1414
# temp folders
1515
tmp
16-
17-
.terraform.lock.hcl

.pre-commit-config.yaml

Lines changed: 13 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,35 @@
11
exclude: ".terraform"
22
repos:
33
- repo: https://github.com/antonbabenko/pre-commit-terraform
4-
rev: v1.92.1
4+
rev: v1.92.2
55
hooks:
66
- id: terraform_docs
77
always_run: true
88
- id: terraform_fmt
9+
- id: terraform_validate
10+
args:
11+
- --hook-config=--retry-once-with-cleanup=true
12+
exclude: ^examples
913
- id: terraform_tflint
1014
alias: terraform_tflint_nocreds
15+
exclude: ^examples
1116
name: terraform_tflint_nocreds
12-
- id: terraform_tfsec
13-
- repo: local
14-
hooks:
15-
- id: terraform_validate
16-
name: terraform_validate
17-
entry: |
18-
bash -c '
19-
AWS_DEFAULT_REGION=us-east-1
20-
declare -a DIRS
21-
for FILE in "$@"
22-
do
23-
DIRS+=($(dirname "$FILE"))
24-
done
25-
for DIR in $(printf "%s\n" "${DIRS[@]}" | sort -u)
26-
do
27-
cd $(dirname "$FILE")
28-
terraform init --backend=false
29-
terraform validate .
30-
cd ..
31-
done
32-
'
33-
language: system
34-
verbose: true
35-
files: \.tf(vars)?$
36-
exclude: examples
37-
- id: tflock
38-
name: provider_locks
39-
entry: |
40-
bash -c '
41-
AWS_DEFAULT_REGION=us-east-1
42-
declare -a DIRS
43-
for FILE in "$@"
44-
do
45-
DIRS+=($(dirname "$FILE"))
46-
done
47-
for DIR in $(printf "%s\n" "${DIRS[@]}" | sort -u)
48-
do
49-
cd $(dirname "$FILE")
50-
terraform providers lock -platform=windows_amd64 -platform=darwin_amd64 -platform=linux_amd64
51-
cd ..
52-
done
53-
'
54-
language: system
55-
verbose: true
56-
files: \.tf(vars)?$
57-
exclude: examples
17+
- id: terraform_trivy
18+
args:
19+
- --args=--skip-dirs="**/.terraform,examples/*"
20+
- id: terraform_providers_lock
5821
- repo: https://github.com/pre-commit/pre-commit-hooks
5922
rev: v4.6.0
6023
hooks:
24+
- id: check-added-large-files
6125
- id: check-case-conflict
6226
- id: check-json
6327
- id: check-merge-conflict
6428
- id: check-symlinks
6529
- id: check-yaml
6630
args:
6731
- --unsafe
32+
- id: detect-private-key
6833
- id: end-of-file-fixer
6934
- id: mixed-line-ending
7035
args:
@@ -86,4 +51,4 @@ repos:
8651
- --markdown-linebreak-ext=md
8752
exclude: README.md
8853
ci:
89-
skip: [terraform_docs, terraform_fmt, terraform_tflint, terraform_tfsec, tflock]
54+
skip: [terraform_docs, terraform_fmt, terraform_validate, terraform_tflint, terraform_trivy, terraform_providers_lock]

.terraform-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
latest:^1.1
1+
latest:^1.6

.tflint.hcl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ config {
22
module = true
33
}
44

5+
plugin "aws" {
6+
enabled = true
7+
version = "0.30.0"
8+
source = "github.com/terraform-linters/tflint-ruleset-aws"
9+
}
10+
511
rule "terraform_deprecated_interpolation" {
612
enabled = true
713
}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Rhythmic Technologies, Inc.
3+
Copyright (c) 2024 Rhythmic Technologies, Inc.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Template repository for terraform modules. Good for any cloud and any provider.
33

44
[![tflint](https://github.com/rhythmictech/terraform-terraform-template/workflows/tflint/badge.svg?branch=master&event=push)](https://github.com/rhythmictech/terraform-terraform-template/actions?query=workflow%3Atflint+event%3Apush+branch%3Amaster)
5-
[![tfsec](https://github.com/rhythmictech/terraform-terraform-template/workflows/tfsec/badge.svg?branch=master&event=push)](https://github.com/rhythmictech/terraform-terraform-template/actions?query=workflow%3Atfsec+event%3Apush+branch%3Amaster)
5+
[![trivy](https://github.com/rhythmictech/terraform-terraform-template/workflows/trivy/badge.svg?branch=master&event=push)](https://github.com/rhythmictech/terraform-terraform-template/actions?query=workflow%3Atrivy+event%3Apush+branch%3Amaster)
66
[![yamllint](https://github.com/rhythmictech/terraform-terraform-template/workflows/yamllint/badge.svg?branch=master&event=push)](https://github.com/rhythmictech/terraform-terraform-template/actions?query=workflow%3Ayamllint+event%3Apush+branch%3Amaster)
77
[![misspell](https://github.com/rhythmictech/terraform-terraform-template/workflows/misspell/badge.svg?branch=master&event=push)](https://github.com/rhythmictech/terraform-terraform-template/actions?query=workflow%3Amisspell+event%3Apush+branch%3Amaster)
88
[![pre-commit-check](https://github.com/rhythmictech/terraform-terraform-template/workflows/pre-commit-check/badge.svg?branch=master&event=push)](https://github.com/rhythmictech/terraform-terraform-template/actions?query=workflow%3Apre-commit-check+event%3Apush+branch%3Amaster)
@@ -32,7 +32,7 @@ No providers.
3232

3333
| Name | Source | Version |
3434
|------|--------|---------|
35-
| <a name="module_tags"></a> [tags](#module\_tags) | rhythmictech/tags/terraform | ~> 1.1.0 |
35+
| <a name="module_tags"></a> [tags](#module\_tags) | rhythmictech/tags/terraform | ~> 1.1 |
3636

3737
## Resources
3838

0 commit comments

Comments
 (0)