Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify policy template schema for Kyverno policies #1037

Merged
merged 1 commit into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions generic/kyverno/kyverno-automount-service-account-token.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: kyverno.io/v1
kind: Policy
metadata:
name: restrict-automount-sa-token
namespace: default
spec:
validationFailureAction: Audit
background: true
rules:
- name: validate-automountServiceAccountToken
match:
any:
- resources:
kinds:
- Pod
preconditions:
all:
- key: "{{ request.operation || 'BACKGROUND' }}"
operator: NotEquals
value: DELETE
validate:
message: "Auto-mounting of Service Account tokens is not allowed."
pattern:
spec:
automountServiceAccountToken: "false"
15 changes: 15 additions & 0 deletions generic/kyverno/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: v0.1.9
policyRules:
- name: restrict-automount-sa-token
description:
refs:
- name: Restrict Mounting Service Account Token
url:
- https://kyverno.io/policies/other/restrict_automount_sa_token/restrict_automount_sa_token/
tldr: Don't mount service account token when it is not needed
detailed: If the Service Account Token is not used by a pod, then it should not be
automounted. Service account token provide access to the kubeapi-server which potentially
increases the surface area of attack.
kyvernoPolicyTags:
- "AUTOMOUNT_SERVICE_ACCOUNT"
yaml: kyverno-automount-service-account-token.yaml