github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/kubernetes/policies/cisbenchmarks/kubelet/kubelet_client_ca_file_argument.rego (about) 1 # METADATA 2 # title: "Ensure that the --client-ca-file argument is set as appropriate" 3 # description: "Enable Kubelet authentication using certificates." 4 # scope: package 5 # schemas: 6 # - input: schema["kubernetes"] 7 # related_resources: 8 # - https://www.cisecurity.org/benchmark/kubernetes 9 # custom: 10 # id: KCV0081 11 # avd_id: AVD-KCV-0081 12 # severity: CRITICAL 13 # short_code: ensure-client-ca-argument-set-appropriate 14 # recommended_action: "If using a Kubelet config file, edit the --client-ca-file argument ito appropriate value" 15 # input: 16 # selector: 17 # - type: kubernetes 18 package builtin.kubernetes.KCV0081 19 20 import data.lib.kubernetes 21 22 types := ["master", "worker"] 23 24 validate_client_ca_set(sp) := {"kubeletClientCaFileArgumentSet": violation} { 25 sp.kind == "NodeInfo" 26 sp.type == types[_] 27 violation := {client_ca | client_ca = sp.info.kubeletClientCaFileArgumentSet.values[_]; client_ca == ""} 28 count(violation) > 0 29 } 30 31 validate_client_ca_set(sp) := {"kubeletClientCaFileArgumentSet": client_ca} { 32 sp.kind == "NodeInfo" 33 sp.type == types[_] 34 count(sp.info.kubeletClientCaFileArgumentSet.values) == 0 35 client_ca = {} 36 } 37 38 deny[res] { 39 output := validate_client_ca_set(input) 40 msg := "Ensure that the --client-ca-file argument is set as appropriate" 41 res := result.new(msg, output) 42 }