|
| 1 | +.PHONY: lint test shellcheck cfn-lint cdk-synth cfn-guard-sam-templates cfn-guard-cloudformation cfn-guard-cdk cfn-guard-terraform |
| 2 | +lint: |
| 3 | + echo "Not implemented" |
| 4 | + exit 1 |
| 5 | + |
| 6 | +test: |
| 7 | + echo "Not implemented" |
| 8 | + exit 1 |
| 9 | + |
| 10 | +shellcheck: |
| 11 | + @if find .github/scripts -maxdepth 1 -type f -name "*.sh" | grep -q .; then \ |
| 12 | + shellcheck .github/scripts/*.sh; \ |
| 13 | + fi |
| 14 | + @if find scripts -maxdepth 1 -type f -name "*.sh" | grep -q .; then \ |
| 15 | + shellcheck scripts/*.sh; \ |
| 16 | + fi |
| 17 | + |
| 18 | +cfn-lint: |
| 19 | + cfn-lint -I "cloudformation/**/*.y*ml" 2>&1 | awk '/Run scan/ { print } /^[EW][0-9]/ { print; getline; print }' |
| 20 | + cfn-lint -I "SAMtemplates/**/*.y*ml" 2>&1 | awk '/Run scan/ { print } /^[EW][0-9]/ { print; getline; print }' |
| 21 | + |
| 22 | +cdk-synth: |
| 23 | + echo "Not implemented" |
| 24 | + exit 1 |
| 25 | + |
| 26 | +cfn-guard-sam-templates: |
| 27 | + @bash -eu -o pipefail -c '\ |
| 28 | + rulesets=("ncsc" "ncsc-cafv3" "wa-Reliability-Pillar" "wa-Security-Pillar"); \ |
| 29 | + mkdir -p .cfn_guard_out; \ |
| 30 | + for ruleset in "$${rulesets[@]}"; do \ |
| 31 | + while IFS= read -r -d "" file; do \ |
| 32 | + SAM_OUTPUT=$$(sam validate -t "$$file" --region eu-west-2 --debug 2>&1 | grep -Pazo "(?s)AWSTemplateFormatVersion.*\\n/" | tr -d "\\0"); \ |
| 33 | + output_file=".cfn_guard_out/$${file}_$${ruleset}.txt"; \ |
| 34 | + mkdir -p "$$(dirname "$$output_file")"; \ |
| 35 | + echo "$${SAM_OUTPUT::-1}" | ~/.guard/bin/cfn-guard validate --rules "/usr/local/share/eps/cfnguard_rulesets/output/$$ruleset.guard" --show-summary fail > "$$output_file"; \ |
| 36 | + done < <(find ./SAMtemplates -type f \( -name "*.yaml" -o -name "*.yml" \) -print0); \ |
| 37 | + done\ |
| 38 | + ' |
| 39 | + |
| 40 | +cfn-guard-cloudformation: |
| 41 | + @bash -eu -o pipefail -c '\ |
| 42 | + rulesets=("ncsc" "ncsc-cafv3" "wa-Reliability-Pillar" "wa-Security-Pillar"); \ |
| 43 | + mkdir -p .cfn_guard_out; \ |
| 44 | + for ruleset in "$${rulesets[@]}"; do \ |
| 45 | + ~/.guard/bin/cfn-guard validate \ |
| 46 | + --data cloudformation \ |
| 47 | + --rules "/tmp/ruleset/output/$$ruleset.guard" \ |
| 48 | + --show-summary fail \ |
| 49 | + > ".cfn_guard_out/cloudformation_$$ruleset.txt"; \ |
| 50 | + done\ |
| 51 | + ' |
| 52 | + |
| 53 | +cfn-guard-cdk: |
| 54 | + @bash -eu -o pipefail -c '\ |
| 55 | + rulesets=("ncsc" "ncsc-cafv3" "wa-Reliability-Pillar" "wa-Security-Pillar"); \ |
| 56 | + mkdir -p .cfn_guard_out; \ |
| 57 | + for ruleset in "$${rulesets[@]}"; do \ |
| 58 | + ~/.guard/bin/cfn-guard validate \ |
| 59 | + --data cdk.out \ |
| 60 | + --rules "/tmp/ruleset/output/$$ruleset.guard" \ |
| 61 | + --show-summary fail \ |
| 62 | + > ".cfn_guard_out/cdk_$$ruleset.txt"; \ |
| 63 | + done\ |
| 64 | + ' |
| 65 | + |
| 66 | +cfn-guard-terraform: |
| 67 | + @bash -eu -o pipefail -c '\ |
| 68 | + rulesets=("ncsc" "ncsc-cafv3" "wa-Reliability-Pillar" "wa-Security-Pillar"); \ |
| 69 | + mkdir -p .cfn_guard_out; \ |
| 70 | + for ruleset in "$${rulesets[@]}"; do \ |
| 71 | + ~/.guard/bin/cfn-guard validate \ |
| 72 | + --data terraform_plans \ |
| 73 | + --rules "/tmp/ruleset/output/$$ruleset.guard" \ |
| 74 | + --show-summary fail \ |
| 75 | + > ".cfn_guard_out/terraform_$$ruleset.txt"; \ |
| 76 | + done\ |
| 77 | + ' |
0 commit comments