-
Notifications
You must be signed in to change notification settings - Fork 0
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 - run cfn_guard --------- Co-authored-by: Adam Brown <adam.brown41@nhs.net> Co-authored-by: Kris Szlapa <kris.szlapa1@nhs.net>
- Loading branch information
1 parent
cb3bbeb
commit 5a01330
Showing
10 changed files
with
125 additions
and
24 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
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 |
---|---|---|
|
@@ -190,3 +190,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
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,32 @@ | ||
#!/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")" | ||
|
||
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 |