Skip to content

Commit 63c9cb5

Browse files
gabemonteroRoming22
authored andcommitted
skip more checkov checks based on
- openshift pod security mutations (added separate test for this) - sandbox use of limit ranges for cpu/mem requests/limits - deferral for now on requiring liveness / readiness probes - pedantic host network checks (added separate test for this) - argocd has to manipluate cluster scoped validatingwebhookconfigurations - deferral on network policies for blocking ingress/egress - chains/pac need to access secrets in arbitrary namespaces add openshift scc / pod security check to tests add openshift pod host network checks to tests
1 parent 878596f commit 63c9cb5

File tree

2 files changed

+123
-4
lines changed

2 files changed

+123
-4
lines changed

ci/images/static-checks/content/config/checkov.yaml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,47 @@ quiet: true
1313
skip-check:
1414
# skip Healthcheck instruction error for Docker Images
1515
- CKV_DOCKER_2
16+
# not enforcing liveness/readiness probes at this time; minimally, chains, results, metric exporter do not have
17+
# we have opened https://github.com/tektoncd/results/issues/280 upstream
18+
- CKV_K8S_8
19+
- CKV_K8S_9
20+
# RHTAP utilizes LimitRanges for cpu/mem requests and limits settings (handles 10-13)
21+
- CKV_K8S_10
22+
- CKV_K8S_11
23+
- CKV_K8S_12
24+
- CKV_K8S_13
25+
# image ref related
26+
- CKV_K8S_43 # deployments referenced by checkov are either items like chains which will be replace by openshift-pipelines 1.10 or a fooled by our use of kustomize for image setting
27+
- CKV_K8S_14 # deployments referenced by checkov are either items like chains which will be replace by openshift-pipelines 1.10 or a fooled by our use of kustomize for image setting
28+
- CKV_K8S_15 # with sha specific image refs setting pull policy to always is redundant and negates us of openshift node cache
29+
# need to reivew chains/pac needs to read secrets in a couple of namespaces, not a clusterrolebinding, create webhooks
30+
- CKV2_K8S_5
31+
# there is no use of hostPID, hostIPC, hostNetwork in repo, but scan complains about not setting explicitly to false
32+
# will check in live tests
33+
- CKV_K8S_17
34+
- CKV_K8S_18
35+
- CKV_K8S_19
36+
# openshift scc / security addresses these check by mutating pod under the covers
37+
# with pods getting assigned the restricted scc unless explicitly allowed otherwise
38+
- CKV_K8S_20 # no allowPrivilegeEscalation
39+
- CKV_K8S_22 # read only FS
40+
- CKV_K8S_23 # admission of root containers
41+
- CKV_K8S_25 # we are not adding capabilities, running under restricted-scc
42+
- CKV_K8S_28 # admission of NET RAW capability
43+
- CKV_K8S_29 # apply security context to pod and containers
44+
- CKV_K8S_30 # apply security context to containers
45+
- CKV_K8S_31 # runtime/default seccomp profile
46+
- CKV_K8S_33 # also, no kubernetes-dashboard on openshift
47+
- CKV_K8S_37 # any capabilities
48+
- CKV_K8S_38 # our pods almost always a) need to access api svr, b) do not have privileged SA
49+
- CKV_K8S_40 # high UID number
50+
- CKV_K8S_35 # opened https://github.com/tektoncd/results/issues/432 for secrets via env var
51+
# need to allow argocd to create/delete the validatingadmissionwebhooks for tekton (core part of knative)
52+
- CKV_K8S_155
53+
- CKV_K8S_157
54+
- CKV2_K8S_6 # use NetworkPolicy like what registration-service and integration-service employ are untenable for tekton controllers
1655
skip-fixes: true
17-
soft-fail: true
56+
soft-fail: false
1857
skip-path:
1958
- developer
59+
- ci

operator/test/test.sh

Lines changed: 82 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Optional arguments:
1919
Default value: \$KUBECONFIG
2020
-t, --test TEST
2121
Name of the test to be executed. Can be repeated to run multiple tests.
22-
Must be one of: chains, pipelines, results.
22+
Must be one of: chains, pipelines, results, security.
2323
Default: Run all tests.
2424
-d, --debug
2525
Activate tracing/debug mode.
@@ -62,7 +62,7 @@ parse_args() {
6262
done
6363
DEBUG="${DEBUG:-}"
6464
if [ "${#TEST_LIST[@]}" = "0" ]; then
65-
TEST_LIST=("chains" "pipelines" "results")
65+
TEST_LIST=("chains" "pipelines" "results" "security")
6666
fi
6767
}
6868

@@ -96,6 +96,60 @@ wait_for_pipeline() {
9696
kubectl wait --for=condition=succeeded "$1" -n "$2" --timeout 60s >/dev/null
9797
}
9898

99+
check_pod_security() {
100+
sccs="$(kubectl get pod -o name -n "$1" | xargs -l -r kubectl get -o jsonpath='{.metadata.annotations.openshift\.io/scc}' -n "$1")"
101+
if [[ "$sccs" =~ "restricted-v2" ]]; then
102+
prune="$(echo "$sccs" | sed 's/restricted-v2//g')"
103+
# if anything besides restricted-v2 is in there, we want to investigate
104+
if [ -z "$prune" ]; then
105+
echo " - OK pod security for $1"
106+
else
107+
echo "Failed, scc's are "
108+
echo "$sccs"
109+
echo "[ERROR] Unexpected $1 pod security context constraints" >&2
110+
exit 1
111+
fi
112+
else
113+
# if none of the pods are restricted-v2, we want to investigate
114+
echo "Failed, scc's are "
115+
echo "$sccs"
116+
echo "[ERROR] Unexpected $1 pod security context constraints" >&2
117+
exit 1
118+
fi
119+
120+
}
121+
122+
check_host_network() {
123+
# got to '|| true' or the script exits with the rc 1 that grep returns if nothing found
124+
hostipc="$(kubectl get pods -o yaml -n "$1" | grep "hostIPC" || true )"
125+
if [ -z "$hostipc" ]; then
126+
echo " - OK hostIPC settings for $1"
127+
else
128+
echo "Failed, hostIPC's are "
129+
echo "$hostipc"
130+
echo "[ERROR] Unexpected $1 hostIPC settings" >&2
131+
exit 1
132+
fi
133+
hostpid="$(kubectl get pods -o yaml -n "$1" | grep "hostPID" || true )"
134+
if [ -z "$hostpid" ]; then
135+
echo " - OK hostPID settings for $1"
136+
else
137+
echo "Failed, hostPID's are "
138+
echo "$hostipc"
139+
echo "[ERROR] Unexpected $1 hostPID settings" >&2
140+
exit 1
141+
fi
142+
hostnetwork="$(kubectl get pods -o yaml -n "$1" | grep "hostNetwork" || true )"
143+
if [ -z "$hostnetwork" ]; then
144+
echo " - OK hostNetwork settings for $1"
145+
else
146+
echo "Failed, hostNetwork's are "
147+
echo "$hostnetwork"
148+
echo "[ERROR] Unexpected $1 hostNetwork settings" >&2
149+
exit 1
150+
fi
151+
}
152+
99153
test_chains() {
100154
kubectl apply -k "$SCRIPT_DIR/manifests/test/tekton-chains" -n "$NAMESPACE" >/dev/null
101155

@@ -160,6 +214,7 @@ test_chains() {
160214
echo "[ERROR] Public key is not accessible" >&2
161215
exit 1
162216
fi
217+
163218
echo
164219
}
165220

@@ -178,9 +233,32 @@ test_pipelines() {
178233
kubectl create -n "$NAMESPACE" -f - | cut -d" " -f1
179234
)
180235
wait_for_pipeline "$pipeline_name" "$NAMESPACE"
236+
181237
echo "OK"
182238
}
183239

240+
test_security() {
241+
echo " - Check security: "
242+
echo " - Check Pod Security openshift-pipelines: "
243+
check_pod_security "openshift-pipelines"
244+
echo " - Check Pod Host Network openshift-pipelines: "
245+
check_host_network "openshift-pipelines"
246+
247+
echo " - Check Pod Security pipelines-as-code: "
248+
check_pod_security "pipelines-as-code"
249+
echo " - Check Pod Host Network pipelines-as-code: "
250+
check_host_network "pipelines-as-code"
251+
252+
echo " - Check Pod Security tekton-results: "
253+
check_pod_security "tekton-results"
254+
echo " - Check Pod Host Network tekton-results: "
255+
check_host_network "tekton-results"
256+
echo " - Check Pod Security tekton-chains: "
257+
check_pod_security "tekton-chains"
258+
echo " - Check Pod Host Network tekton-chains: "
259+
check_host_network "tekton-chains"
260+
}
261+
184262
test_results() {
185263
test_pipelines
186264
echo -n " - Results in database:"
@@ -250,6 +328,7 @@ test_results() {
250328
sleep 10
251329
fetch_results_using_rest "records"
252330
fetch_results_using_rest "logs"
331+
253332
echo
254333
}
255334

@@ -259,7 +338,7 @@ main() {
259338
setup_test
260339
for case in "${TEST_LIST[@]}"; do
261340
case $case in
262-
chains | pipelines | results)
341+
chains | pipelines | results | security)
263342
echo "[$case]"
264343
test_"$case"
265344
echo

0 commit comments

Comments
 (0)