github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/kubernetes/policies/cisbenchmarks/apiserver/kubernetes_pki_directory_ownership.rego (about) 1 # METADATA 2 # title: "Ensure that the Kubernetes PKI directory and file file ownership is set to root:root" 3 # description: "Ensure that the Kubernetes PKI directory and file file ownership is set to root:root." 4 # scope: package 5 # schemas: 6 # - input: schema["kubernetes"] 7 # related_resources: 8 # - https://www.cisecurity.org/benchmark/kubernetes 9 # custom: 10 # id: KCV0066 11 # avd_id: AVD-KCV-0066 12 # severity: CRITICAL 13 # short_code: ensure-kubernetes-pki-directory-file-ownership-set-root:root. 14 # recommended_action: "Change the Kubernetes PKI directory and file file /etc/kubernetes/pki/ ownership to root:root" 15 # input: 16 # selector: 17 # - type: kubernetes 18 package builtin.kubernetes.KCV0066 19 20 import data.lib.kubernetes 21 22 validate_pki_directory_ownership(sp) := {"kubePKIDirectoryFileOwnership": violation} { 23 sp.kind == "NodeInfo" 24 sp.type == "master" 25 violation := {ownership | ownership = sp.info.kubePKIDirectoryFileOwnership.values[_]; not ownership == "root:root"} 26 count(violation) > 0 27 } 28 29 deny[res] { 30 output := validate_pki_directory_ownership(input) 31 msg := "Ensure that the Kubernetes PKI directory and file file ownership is set to root:root" 32 res := result.new(msg, output) 33 }