fix: TFSec outputs the same results multiple times (#237)

This commit is contained in:
Maksym Vlasov 2021-10-14 14:35:19 +03:00 committed by GitHub
commit 71f7c347c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View file

@ -79,6 +79,7 @@
- id: terraform_tfsec - id: terraform_tfsec
name: Terraform validate with tfsec name: Terraform validate with tfsec
description: Static analysis of Terraform templates to spot potential security issues. description: Static analysis of Terraform templates to spot potential security issues.
require_serial: true
entry: terraform_tfsec.sh entry: terraform_tfsec.sh
language: script language: script

View file

@ -6,13 +6,13 @@ main() {
parse_cmdline_ "$@" parse_cmdline_ "$@"
# propagate $FILES to custom function # propagate $FILES to custom function
tfsec_ "$ARGS" "$FILES" tfsec_ "$ARGS" "${FILES[*]}"
} }
tfsec_() { tfsec_() {
# consume modified files passed from pre-commit so that # consume modified files passed from pre-commit so that
# tfsec runs against only those relevant directories # tfsec runs against only those relevant directories
for file_with_path in $FILES; do for file_with_path in ${FILES[*]}; do
file_with_path="${file_with_path// /__REPLACED__SPACE__}" file_with_path="${file_with_path// /__REPLACED__SPACE__}"
paths[index]=$(dirname "$file_with_path") paths[index]=$(dirname "$file_with_path")