-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
86 additions
and
38 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
tetrate/tis0102/restrict-invalid-method-authorization-policy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
annotations: | ||
policies.kyverno.io/category: Security | ||
policies.kyverno.io/description: | | ||
This policy ensures that in AuthorizationPolicy resources, the spec.rules[].to[].operation.method[] field contains only valid HTTP methods or properly formatted gRPC method names in the form /package.service/method. | ||
policies.kyverno.io/severity: medium | ||
policies.kyverno.io/title: Validate Authorization Policy Methods | ||
name: validate-authorization-policy-methods | ||
spec: | ||
background: true | ||
rules: | ||
- match: | ||
any: | ||
- resources: | ||
kinds: | ||
- AuthorizationPolicy | ||
name: validate-methods | ||
validate: | ||
foreach: | ||
- elementScope: rules | ||
foreach: | ||
- elementScope: to | ||
foreach: | ||
- deny: | ||
conditions: | ||
all: | ||
- key: '{{ element }}' | ||
operator: AnyNotIn | ||
value: | ||
- GET | ||
- POST | ||
- PUT | ||
- DELETE | ||
- PATCH | ||
- HEAD | ||
- OPTIONS | ||
- CONNECT | ||
- TRACE | ||
- key: '{{ regex_match(''^/[a-zA-Z0-9.]+/[a-zA-Z0-9]+$'', element) }}' | ||
operator: Equals | ||
value: false | ||
list: to.operation.methods || [] | ||
list: rules.to | ||
list: request.object.spec.rules | ||
message: Methods must be either valid HTTP methods (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, CONNECT, TRACE) or valid gRPC methods in the form /package.service/method | ||
validationFailureAction: Enforce |
38 changes: 38 additions & 0 deletions
38
tetrate/tis0102/restrict-invalid-method-virtualservice.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
annotations: | ||
policies.kyverno.io/category: Security | ||
policies.kyverno.io/description: Ensures that HTTP methods specified in VirtualService resources are from an allowed set | ||
policies.kyverno.io/severity: medium | ||
policies.kyverno.io/title: Validate VirtualService HTTP Methods | ||
name: validate-vs-http-methods | ||
spec: | ||
background: true | ||
rules: | ||
- match: | ||
any: | ||
- resources: | ||
kinds: | ||
- VirtualService | ||
name: validate-http-methods | ||
validate: | ||
foreach: | ||
- deny: | ||
conditions: | ||
all: | ||
- key: '{{ element }}' | ||
operator: NotIn | ||
value: | ||
- GET | ||
- HEAD | ||
- POST | ||
- PUT | ||
- DELETE | ||
- CONNECT | ||
- OPTIONS | ||
- TRACE | ||
- PATCH | ||
list: request.object.spec.http[*].match[*].method.type | ||
message: 'The HTTP method must be one of: GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE, PATCH' | ||
validationFailureAction: Enforce |