github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/kubernetes/policies/cisbenchmarks/apiserver/always_admit_plugin.rego (about) 1 # METADATA 2 # title: "Ensure that the admission control plugin AlwaysAdmit is not set" 3 # description: "Do not allow all requests." 4 # scope: package 5 # schemas: 6 # - input: schema["kubernetes"] 7 # related_resources: 8 # - https://www.cisecurity.org/benchmark/kubernetes 9 # custom: 10 # id: KCV0011 11 # avd_id: AVD-KCV-0011 12 # severity: LOW 13 # short_code: ensure-admission-control-plugin-always-admit-is-not-set 14 # recommended_action: "Edit the API server pod specification file /etc/kubernetes/manifests/kube-apiserver.yaml on the Control Plane node and either remove the --enable-admission- plugins parameter, or set it to a value that does not include AlwaysAdmit." 15 # input: 16 # selector: 17 # - type: kubernetes 18 package builtin.kubernetes.KCV0011 19 20 import data.lib.kubernetes 21 22 check_flag[container] { 23 container := kubernetes.containers[_] 24 kubernetes.is_apiserver(container) 25 some i 26 output := regex.find_all_string_submatch_n(`--enable-admission-plugins=([^\s]+)`, container.command[i], -1) 27 regex.match("AlwaysAdmit", output[0][1]) 28 } 29 30 deny[res] { 31 output := check_flag[_] 32 msg := "Ensure that the admission control plugin AlwaysAdmit is not set" 33 res := result.new(msg, output) 34 }