This commit is contained in:
2026-04-08 20:22:14 +07:00
commit 34fbdd1412
96 changed files with 5321 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: restrict-automount-service-account-token
annotations:
policies.kyverno.io/title: "Ограничение автомонтирования ServiceAccount токена"
policies.kyverno.io/category: Security
policies.kyverno.io/severity: medium
policies.kyverno.io/subject: Pod
policies.kyverno.io/description: >-
По умолчанию Kubernetes монтирует токен ServiceAccount в каждый под.
Если приложение не использует Kubernetes API, этот токен — лишняя
поверхность атаки. CIS Benchmark рекомендует отключать автомонтирование
там, где токен не нужен.
spec:
validationFailureAction: Audit
background: true
rules:
- name: check-automount-service-account
match:
resources:
kinds:
- Pod
exclude:
resources:
namespaces:
- kube-system
validate:
message: >-
Под '{{ request.object.metadata.name }}' автоматически монтирует
ServiceAccount токен (automountServiceAccountToken: true по умолчанию).
Если под не обращается к Kubernetes API, добавьте:
spec:
automountServiceAccountToken: false
pattern:
spec:
automountServiceAccountToken: false