mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-30 19:35:06 +00:00
744 deny all requests
This commit is contained in:
parent
83ecd95945
commit
93fa54bf79
5 changed files with 31 additions and 18 deletions
|
@ -209,13 +209,17 @@ spec:
|
|||
anyPattern:
|
||||
AnyValue: {}
|
||||
deny:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
required:
|
||||
- key # can be of any type
|
||||
- operator # typed
|
||||
- value # can be of any type
|
||||
properties:
|
||||
allRequests:
|
||||
type: boolean
|
||||
conditions:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
required:
|
||||
- key # can be of any type
|
||||
- operator # typed
|
||||
- value # can be of any type
|
||||
generate:
|
||||
type: object
|
||||
required:
|
||||
|
|
|
@ -209,13 +209,17 @@ spec:
|
|||
anyPattern:
|
||||
AnyValue: {}
|
||||
deny:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
required:
|
||||
- key # can be of any type
|
||||
- operator # typed
|
||||
- value # can be of any type
|
||||
properties:
|
||||
allRequests:
|
||||
type: boolean
|
||||
conditions:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
required:
|
||||
- key # can be of any type
|
||||
- operator # typed
|
||||
- value # can be of any type
|
||||
generate:
|
||||
type: object
|
||||
required:
|
||||
|
|
|
@ -211,7 +211,12 @@ type Validation struct {
|
|||
Message string `json:"message,omitempty"`
|
||||
Pattern interface{} `json:"pattern,omitempty"`
|
||||
AnyPattern []interface{} `json:"anyPattern,omitempty"`
|
||||
Deny []Condition `json:"deny,omitempty"`
|
||||
Deny *Deny `json:"deny,omitempty"`
|
||||
}
|
||||
|
||||
type Deny struct {
|
||||
AllRequests bool `json:"allRequests,omitempty"`
|
||||
Conditions []Condition `json:"conditions,omitempty"`
|
||||
}
|
||||
|
||||
// Generation describes which resources will be created when other resource is created
|
||||
|
|
|
@ -110,8 +110,8 @@ func validateResource(log logr.Logger, ctx context.EvalInterface, policy kyverno
|
|||
}
|
||||
|
||||
if rule.Validation.Deny != nil {
|
||||
denyConditionsCopy := copyConditions(rule.Validation.Deny)
|
||||
if !variables.EvaluateConditions(log, ctx, denyConditionsCopy) {
|
||||
denyConditionsCopy := copyConditions(rule.Validation.Deny.Conditions)
|
||||
if rule.Validation.Deny.AllRequests || !variables.EvaluateConditions(log, ctx, denyConditionsCopy) {
|
||||
ruleResp := response.RuleResponse{
|
||||
Name: rule.Name,
|
||||
Type: utils.Validation.String(),
|
||||
|
|
|
@ -49,7 +49,7 @@ func (v *Validate) Validate() (string, error) {
|
|||
// validateOverlayPattern checks one of pattern/anyPattern must exist
|
||||
func (v *Validate) validateOverlayPattern() error {
|
||||
rule := v.rule
|
||||
if rule.Pattern == nil && len(rule.AnyPattern) == 0 && len(rule.Deny) == 0 {
|
||||
if rule.Pattern == nil && len(rule.AnyPattern) == 0 && rule.Deny == nil {
|
||||
return fmt.Errorf("a pattern or anyPattern or deny must be specified")
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue