-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck.mk
More file actions
173 lines (149 loc) · 4.88 KB
/
check.mk
File metadata and controls
173 lines (149 loc) · 4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
.PHONY: lint test shellcheck cfn-lint cdk-synth cfn-guard-sam-templates cfn-guard-cloudformation cfn-guard-cdk cfn-guard-terraform zizmor
lint:
echo "Not implemented"
exit 1
test:
echo "Not implemented"
exit 1
shellcheck:
@if find .github/scripts -maxdepth 1 -type f -name "*.sh" | grep -q .; then \
shellcheck .github/scripts/*.sh; \
fi
@if find scripts -maxdepth 1 -type f -name "*.sh" | grep -q .; then \
shellcheck scripts/*.sh; \
fi
cfn-lint:
@if find cloudformation -type f \( -name "*.yaml" -o -name "*.yml" \) 2>/dev/null | grep -q .; then \
cfn-lint -I "cloudformation/**/*.y*ml" 2>&1 | awk '/Run scan/ { print } /^[EW][0-9]/ { print; getline; print; found=1 } END { exit found }'; \
fi
@if find SAMtemplates -type f \( -name "*.yaml" -o -name "*.yml" \) 2>/dev/null | grep -q .; then \
cfn-lint -I "SAMtemplates/**/*.y*ml" 2>&1 | awk '/Run scan/ { print } /^[EW][0-9]/ { print; getline; print; found=1 } END { exit found }'; \
fi
cdk-synth:
echo "Not implemented"
exit 1
cfn-guard-sam-templates:
@bash -eu -o pipefail -c '\
rulesets=("ncsc" "ncsc-cafv3" "wa-Reliability-Pillar" "wa-Security-Pillar"); \
mkdir -p .cfn_guard_out; \
for ruleset in "$${rulesets[@]}"; do \
while IFS= read -r -d "" file; do \
SAM_OUTPUT=$$(sam validate -t "$$file" --region eu-west-2 --debug 2>&1 | grep -Pazo "(?s)AWSTemplateFormatVersion.*\\n/" | tr -d "\\0"); \
output_file=".cfn_guard_out/$${file}_$${ruleset}.txt"; \
mkdir -p "$$(dirname "$$output_file")"; \
echo "$${SAM_OUTPUT::-1}" | /home/vscode/.guard/bin/cfn-guard validate --rules "/usr/local/share/eps/cfnguard_rulesets/output/$$ruleset.guard" --show-summary fail > "$$output_file"; \
done < <(find ./SAMtemplates -type f \( -name "*.yaml" -o -name "*.yml" \) -print0); \
done\
'
cfn-guard-cloudformation:
@bash -eu -o pipefail -c '\
rulesets=("ncsc" "ncsc-cafv3" "wa-Reliability-Pillar" "wa-Security-Pillar"); \
mkdir -p .cfn_guard_out; \
for ruleset in "$${rulesets[@]}"; do \
/home/vscode/.guard/bin/cfn-guard validate \
--data cloudformation \
--rules "/usr/local/share/eps/cfnguard_rulesets/output/$$ruleset.guard" \
--show-summary fail \
> ".cfn_guard_out/cloudformation_$$ruleset.txt"; \
done\
'
cfn-guard-cdk:
@bash -eu -o pipefail -c '\
rulesets=("ncsc" "ncsc-cafv3" "wa-Reliability-Pillar" "wa-Security-Pillar"); \
mkdir -p .cfn_guard_out; \
for ruleset in "$${rulesets[@]}"; do \
/home/vscode/.guard/bin/cfn-guard validate \
--data cdk.out \
--rules "/usr/local/share/eps/cfnguard_rulesets/output/$$ruleset.guard" \
--show-summary fail \
> ".cfn_guard_out/cdk_$$ruleset.txt"; \
done\
'
cfn-guard-terraform:
@bash -eu -o pipefail -c '\
rulesets=("ncsc" "ncsc-cafv3" "wa-Reliability-Pillar" "wa-Security-Pillar"); \
mkdir -p .cfn_guard_out; \
for ruleset in "$${rulesets[@]}"; do \
/home/vscode/.guard/bin/cfn-guard validate \
--data terraform_plans \
--rules "/usr/local/share/eps/cfnguard_rulesets/output/$$ruleset.guard" \
--show-summary fail \
> ".cfn_guard_out/terraform_$$ruleset.txt"; \
done\
'
actionlint:
actionlint
secret-scan:
@if [ -f .gitallowed ]; then \
git-secrets --scan-history .; \
else \
gitleaks -v git; \
fi
guard-%:
@ if [ "${${*}}" = "" ]; then \
echo "Environment variable $* not set"; \
exit 1; \
fi
zizmor:
zizmor --min-severity medium .
syft-generate-sbom:
mkdir -p .sbom
syft \
--exclude './.github/**' \
--output cyclonedx-json=.sbom/sbom.cdx.json \
dir:./
syft-generate-sbom-dev-dependencies:
mkdir -p .sbom
SYFT_JAVASCRIPT_INCLUDE_DEV_DEPENDENCIES=true \
syft \
--exclude './.github/**' \
--output cyclonedx-json=.sbom/sbom.dev.cdx.json \
dir:./
grype-scan: syft-generate-sbom
grype \
--fail-on high \
.sbom/sbom.cdx.json
grype-scan-dev-dependencies: syft-generate-sbom-dev-dependencies
grype \
--fail-on high \
.sbom/sbom.dev.cdx.json
grype-scan-json: syft-generate-sbom
grype \
--fail-on high \
.sbom/sbom.cdx.json \
--output json=".sbom/grype_analysis.json"
grype-scan-json-dev-dependencies: syft-generate-sbom-dev-dependencies
grype \
--fail-on high \
.sbom/sbom.dev.cdx.json \
--output json=".sbom/grype_analysis.dev.json"
grype-scan-local:
grype \
--fail-on high \
--quiet \
.
grype-scan-docker-image: guard-DOCKER_IMAGE
grype "${DOCKER_IMAGE}" \
--scope all-layers \
--sort-by severity \
--fail-on high
grant-scan: syft-generate-sbom
grant check \
--dry-run \
.sbom/sbom.cdx.json
grant-scan-dev-dependencies: syft-generate-sbom-dev-dependencies
grant check \
--dry-run \
.sbom/sbom.dev.cdx.json
grant-scan-json: syft-generate-sbom
grant check .sbom/sbom.cdx.json \
--output json \
--quiet \
--dry-run \
--output-file ".sbom/grant_analysis.json"
grant-scan-json-dev-dependencies: syft-generate-sbom-dev-dependencies
grant check .sbom/sbom.dev.cdx.json \
--output json \
--quiet \
--dry-run \
--output-file ".sbom/grant_analysis.dev.json"