github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/kubernetes/policies/cisbenchmarks/kubelet/proxy_kube_config_file_ownership.rego (about) 1 # METADATA 2 # title: "if proxy kubeconfig file exists ensure ownership is set to root:root" 3 # description: "If kube-proxy is running, ensure that the file ownership of its kubeconfig file 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: KCV0072 11 # avd_id: AVD-KCV-0072 12 # severity: HIGH 13 # short_code: ensure-proxy-kubeconfig-ownership-set-root:root-if-exist 14 # recommended_action: "Change the proxy kubeconfig file <path><filename> ownership to root:root if exist" 15 # input: 16 # selector: 17 # - type: kubernetes 18 package builtin.kubernetes.KCV0072 19 20 import data.lib.kubernetes 21 22 types := ["master", "worker"] 23 24 validate_kube_config_file_ownership(sp) := {"kubeconfigFileExistsOwnership": violation} { 25 sp.kind == "NodeInfo" 26 sp.type == types[_] 27 count(sp.info.kubeconfigFileExistsOwnership) > 0 28 violation := {ownership | ownership = sp.info.kubeconfigFileExistsOwnership.values[_]; ownership != "root:root"} 29 count(violation) > 0 30 } 31 32 deny[res] { 33 output := validate_kube_config_file_ownership(input) 34 msg := "Ensure proxy kubeconfig file ownership is set to root:root if exists" 35 res := result.new(msg, output) 36 }