forked from Bahmni/bahmni-infra
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BAH-1566 | add. terrascan to pre-commit hook
Co-authored-by: Umair Fayaz <[email protected]>
- Loading branch information
1 parent
ca1a8d3
commit e8bc2cd
Showing
4 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
rules: | ||
skip-rules: | ||
- AC_AWS_0480 # Skips validation of detailed monitoring for EC2 Instances |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
# Terrascan scan and save output to scan_results | ||
scan_results="$(terrascan scan --config-path terrascan/terrascan-config.yaml --iac-type terraform)" | ||
|
||
# Get scan summary from scan_results | ||
scan_summary=$(echo "$scan_results" | sed -n -e '/Scan Summary -/,$p') | ||
|
||
#Extract values from scan_summary | ||
low_level_violations=$(grep "Low" <<< "$scan_summary" | grep -o -E "[0-9]+") | ||
medium_level_violations=$(grep "Medium" <<< "$scan_summary" | grep -o -E "[0-9]+") | ||
high_level_violations=$(grep "High" <<< "$scan_summary" | grep -o -E "[0-9]+") | ||
|
||
#Show Scan Output | ||
echo "$scan_results" | ||
|
||
#Check for violations | ||
if [[ $high_level_violations -gt 0 ]] | ||
then | ||
echo "High Level Voilations Found" | ||
exit 1 | ||
fi | ||
echo "No Violations found" | ||
exit 0 |