From 71f7c347c99b30a7275d3f3dddc5364b28394f6c Mon Sep 17 00:00:00 2001 From: Maksym Vlasov Date: Thu, 14 Oct 2021 14:35:19 +0300 Subject: [PATCH] fix: TFSec outputs the same results multiple times (#237) --- .pre-commit-hooks.yaml | 1 + terraform_tfsec.sh | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 746a676..492b559 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -79,6 +79,7 @@ - id: terraform_tfsec name: Terraform validate with tfsec description: Static analysis of Terraform templates to spot potential security issues. + require_serial: true entry: terraform_tfsec.sh language: script diff --git a/terraform_tfsec.sh b/terraform_tfsec.sh index 6c6ee25..c742f32 100755 --- a/terraform_tfsec.sh +++ b/terraform_tfsec.sh @@ -6,13 +6,13 @@ main() { parse_cmdline_ "$@" # propagate $FILES to custom function - tfsec_ "$ARGS" "$FILES" + tfsec_ "$ARGS" "${FILES[*]}" } tfsec_() { # consume modified files passed from pre-commit so that # 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__}" paths[index]=$(dirname "$file_with_path")