Before version 1.24, Kubernetes automatically generated Secret-based tokens for ServiceAccounts. To distinguish between automatically generated tokens and manually created ones, Kubernetes checks for a reference from the ServiceAccount's secrets field. If the Secret is referenced in the secrets field, it is considered an auto-generated legacy token. These legacy Tokens can be of security concern and should be audited.
apiVersion: kyverno.io/v1kind: ClusterPolicymetadata:name: check-serviceaccount-secretsannotations:policies.kyverno.io/title: Check Long-Lived Secrets in ServiceAccountspolicies.kyverno.io/category: Securitypolicies.kyverno.io/severity: mediumkyverno.io/kyverno-version: 1.11.1kyverno.io/kubernetes-version: "1.27"policies.kyverno.io/subject: Secret,ServiceAccountpolicies.kyverno.io/description: Before version 1.24, Kubernetes automatically generated Secret-based tokens for ServiceAccounts. To distinguish between automatically generated tokens and manually created ones, Kubernetes checks for a reference from the ServiceAccount's secrets field. If the Secret is referenced in the secrets field, it is considered an auto-generated legacy token. These legacy Tokens can be of security concern and should be audited.spec:validationFailureAction: Auditbackground: truerules:- name: deny-secretsmatch:any:- resources:kinds:- ServiceAccountvalidate:message: Long-lived API tokens are not allowed.pattern:X(secrets): null
This policy performs some best practices validation on Application fields. Path or chart must be specified but never both. And destination.name or destination.server must be specified but never both.
This policy prevents the use of the default project in an Application.
This policy prevents updates to the project field after an Application is created.