diff --git a/cfg/rke-cis-1.24/master.yaml b/cfg/rke-cis-1.24/master.yaml index c08d6e57b..6d14c613e 100644 --- a/cfg/rke-cis-1.24/master.yaml +++ b/cfg/rke-cis-1.24/master.yaml @@ -272,7 +272,26 @@ groups: - id: 1.1.19 text: "Ensure that the Kubernetes PKI directory and file ownership is set to root:root (Automated)" - audit: "check_files_owner_in_dir.sh /node/etc/kubernetes/ssl" + audit: | + #!/bin/bash + if [[ $(stat -c %U:%G "/node/etc/kubernetes/ssl") != "root:root" ]]; then + echo "false" + exit 1 + fi + for f in "/node/etc/kubernetes/ssl"/*; do + if [[ $(basename "$f" .pem) == "kube-etcd-"* ]]; then + if [[ $(stat -c %U:%G "$f") != "root:root" && $(stat -c %U:%G "$f") != "etcd:etcd" ]]; then + echo "false" + exit 1 + fi + else + if [[ $(stat -c %U:%G "$f") != "root:root" ]]; then + echo "false" + exit 1 + fi + fi + done + echo "true" tests: test_items: - flag: "true"