github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/kubernetes/policies/cisbenchmarks/apiserver/audit_log_maxbackup_test.rego (about) 1 package builtin.kubernetes.KCV0021 2 3 test_audit_log_maxbackup_is_set_30 { 4 r := deny with input as { 5 "apiVersion": "v1", 6 "kind": "Pod", 7 "metadata": { 8 "name": "apiserver", 9 "labels": { 10 "component": "kube-apiserver", 11 "tier": "control-plane", 12 }, 13 }, 14 "spec": {"containers": [{ 15 "command": ["kube-apiserver", "--advertise-address=192.168.49.2", "--audit-log-maxbackup=30"], 16 "image": "busybox", 17 "name": "hello", 18 }]}, 19 } 20 21 count(r) == 0 22 } 23 24 test_audit_log_maxbackup_is_set_10 { 25 r := deny with input as { 26 "apiVersion": "v1", 27 "kind": "Pod", 28 "metadata": { 29 "name": "apiserver", 30 "labels": { 31 "component": "kube-apiserver", 32 "tier": "control-plane", 33 }, 34 }, 35 "spec": {"containers": [{ 36 "command": ["kube-apiserver", "--advertise-address=192.168.49.2", "--audit-log-maxbackup=30", "--secure-port=10"], 37 "image": "busybox", 38 "name": "hello", 39 }]}, 40 } 41 42 count(r) == 0 43 } 44 45 test_audit_log_maxbackup_is_not_set { 46 r := deny with input as { 47 "apiVersion": "v1", 48 "kind": "Pod", 49 "metadata": { 50 "name": "apiserver", 51 "labels": { 52 "component": "kube-apiserver", 53 "tier": "control-plane", 54 }, 55 }, 56 "spec": {"containers": [{ 57 "command": ["kube-apiserver", "--advertise-address=192.168.49.2", "--profiling=true", "--anonymous-auth=false"], 58 "image": "busybox", 59 "name": "hello", 60 }]}, 61 } 62 63 count(r) == 1 64 r[_].msg == "Ensure that the --audit-log-maxbackup argument is set to 10 or as appropriate" 65 }