-
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.
Browse files
Browse the repository at this point in the history
## Summary - Routine Change ### Details - add cfn-guard
- Loading branch information
1 parent
d81602d
commit d4f0c2d
Showing
8 changed files
with
81 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ release_notes | |
.aws-sam | ||
lib/ | ||
*.tsbuildinfo | ||
cfn_guard_output/ |
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 |
---|---|---|
|
@@ -158,3 +158,6 @@ aws-configure: | |
|
||
aws-login: | ||
aws sso login --sso-session sso-session | ||
|
||
cfn-guard: | ||
./scripts/run_cfn_guard.sh |
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
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,35 @@ | ||
#!/usr/bin/env bash | ||
set -eou pipefail | ||
|
||
rm -rf /tmp/ruleset | ||
rm -rf cfn_guard_output | ||
|
||
wget -O /tmp/ruleset.zip https://github.com/aws-cloudformation/aws-guard-rules-registry/releases/download/1.0.2/ruleset-build-v1.0.2.zip >/dev/null 2>&1 | ||
unzip /tmp/ruleset.zip -d /tmp/ruleset/ >/dev/null 2>&1 | ||
|
||
curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/aws-cloudformation/cloudformation-guard/main/install-guard.sh | sh >/dev/null 2>&1 | ||
|
||
mkdir -p cfn_guard_output | ||
|
||
declare -a rulesets=("ncsc" "ncsc-cafv3" "wa-Reliability-Pillar" "wa-Security-Pillar") | ||
for ruleset in "${rulesets[@]}" | ||
do | ||
|
||
while IFS= read -r -d '' file | ||
do | ||
echo "checking SAM template $file with ruleset $ruleset" | ||
mkdir -p "$(dirname cfn_guard_output/"$file")" | ||
|
||
# transform the SAM template to cloudformation and then run through cfn-guard | ||
SAM_OUPUT=$(sam validate -t "$file" --region eu-west-2 --debug 2>&1 | \ | ||
grep -Pazo '(?s)AWSTemplateFormatVersion.*\n\/' | tr -d '\0') | ||
echo "${SAM_OUPUT::-1}" | ~/.guard/bin/cfn-guard validate \ | ||
--rules "/tmp/ruleset/output/$ruleset.guard" \ | ||
--show-summary fail \ | ||
> "cfn_guard_output/${file}_${ruleset}.txt" | ||
|
||
done < <(find ./SAMtemplates -name '*.y*ml' -print0) | ||
|
||
done | ||
|
||
rm -rf /tmp/ruleset |