-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_checkov.sh
47 lines (42 loc) · 1.08 KB
/
run_checkov.sh
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
#!/bin/sh
################################################################################
# Download all Kubernetes resources and run checkov against them
################################################################################
# kubectl api-resources --verbs=list --namespaced -o name | xargs -n1 -I{} bash -c "kubectl get {} --all-namespaces -oyaml && echo ---"
RESOURCES="clusterroles
clusterrolebindings
cronjobs
daemonsets
deployments
endpoints
horizontalpodautoscalers
ingresses
jobs
limitranges
networkpolicies
poddisruptionbudgets
pods
podsecuritypolicies
replicasets
replicationcontrollers
resourcequotas
roles
rolebindings
serviceaccounts
services
statefulsets"
for resource in $RESOURCES;
do
kubectl get $resource --all-namespaces -oyaml > /data/runtime.${resource}.yaml
done
if [ -f /etc/checkov/apikey ]; then
apikey=$(cat /etc/checkov/apikey)
if [ -f /etc/checkov/repoid ]; then
repoid=$(cat /etc/checkov/repoid)
else
repoid="runtime/unknown"
fi
checkov -s -d /data --bc-api-key "$apikey" --repo-id "$repoid" --branch runtime
else
checkov -s -d /data
fi