-
Notifications
You must be signed in to change notification settings - Fork 220
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
ClusterPolicy for enforcing securityStandard Istio Authorization Policies #582
Labels
sample
Sample policy
Comments
This passes all tests. apiVersion: kyverno.io/v2beta1
kind: ClusterPolicy
metadata:
name: istio-authorization-policy
annotations:
pod-policies.kyverno.io/autogen-controllers: none
spec:
background: false
validationFailureAction: Enforce
rules:
- name: one-require-from
match:
any:
- resources:
kinds:
- security.istio.io/v1beta1/AuthorizationPolicy
validate:
message: The from field is required.
pattern:
spec:
rules:
- from: "*"
- name: two-require-to
match:
any:
- resources:
kinds:
- security.istio.io/v1beta1/AuthorizationPolicy
validate:
message: The to field is required.
pattern:
spec:
rules:
- to: "*"
- name: three-require-port-in-to
match:
any:
- resources:
kinds:
- security.istio.io/v1beta1/AuthorizationPolicy
validate:
message: The to field must have the port field defined.
pattern:
spec:
rules:
- to:
- operation:
ports: "*"
- name: four-from-source-only-requestprincipals-and-principals
match:
any:
- resources:
kinds:
- security.istio.io/v1beta1/AuthorizationPolicy
validate:
message: The from field in source may only have requestPrincipals and principals fields defined.
deny:
conditions:
all:
- key: "{{ request.object.spec.rules[].from[].source.keys(@)[] }}"
operator: AnyNotIn
value:
- principals
- requestPrincipals
- name: five-no-wildcards
match:
any:
- resources:
kinds:
- security.istio.io/v1beta1/AuthorizationPolicy
validate:
message: Wildcards may not be used.
deny:
conditions:
all:
- key: "{{ to_string(request.object.spec) | contains(@, '*') }}"
operator: Equals
value: true |
Any feedback, @nischay30 ? |
Hi @chipzoller , Policies looks good and I have tested it. Thanks |
Thank you for the confirmation. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem Statement
A ClusterPolicy to deny any bad IstioAuthorization Policies in the Kubernetes Cluster.
Solution Description
Cluster Policy should meet the below criteria:
from
blockto
blockport
defined in theto
blockrequestPrincipals
andprincipals
in thesource
block.*
should never be allowed as a value to any of the field in the AuthorizationPolicyExample "Good" Resource
Example "Bad" Resource
Other Comments
No response
Slack discussion
No response
Troubleshooting
The text was updated successfully, but these errors were encountered: