Skip to content
Closed
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
10 changes: 10 additions & 0 deletions api/v1alpha1/envoyextensionypolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ type EnvoyExtensionPolicy struct {
type EnvoyExtensionPolicySpec struct {
PolicyTargetReferences `json:",inline"`

// MergeType determines how this configuration is merged with existing EnvoyExtensionPolicy
// configurations targeting a parent resource. When set, this configuration will be merged
// into a parent EnvoyExtensionPolicy (i.e. the one targeting a Gateway or Listener).
// This field cannot be set when targeting a parent resource (Gateway).
// If unset, no merging occurs, and only the most specific configuration takes effect.
//
// +kubebuilder:validation:XValidation:rule="self != 'Replace'",message="Replace is not a valid MergeType for EnvoyExtensionPolicy"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject mergeType on Gateway-targeted policies

The spec comment added for MergeType says it "cannot be set when targeting a parent resource (Gateway)", but the only validation here is self != 'Replace', so Gateway-targeted EnvoyExtensionPolicy objects with mergeType: StrategicMerge/JSONMerge are still admitted. At runtime those policies are processed by processEnvoyExtensionPolicyForGateway without any MergeType guard (so merge intent is effectively ignored), which creates a silent misconfiguration path for users. Please add a CEL/runtime validation that forbids mergeType when any target ref resolves to kind: Gateway.

Useful? React with 👍 / 👎.

// +optional
MergeType *MergeType `json:"mergeType,omitempty"`

// Wasm is a list of Wasm extensions to be loaded by the Gateway.
// Order matters, as the extensions will be loaded in the order they are
// defined in this list.
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1659,6 +1659,17 @@ spec:
|| (self.type == 'ValueRef' && !has(self.inline) && has(self.valueRef))
maxItems: 16
type: array
mergeType:
description: |-
MergeType determines how this configuration is merged with existing EnvoyExtensionPolicy
configurations targeting a parent resource. When set, this configuration will be merged
into a parent EnvoyExtensionPolicy (i.e. the one targeting a Gateway or Listener).
This field cannot be set when targeting a parent resource (Gateway).
If unset, no merging occurs, and only the most specific configuration takes effect.
type: string
x-kubernetes-validations:
- message: Replace is not a valid MergeType for EnvoyExtensionPolicy
rule: self != 'Replace'
targetRef:
description: |-
TargetRef is the name of the resource this policy is being attached to.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1658,6 +1658,17 @@ spec:
|| (self.type == 'ValueRef' && !has(self.inline) && has(self.valueRef))
maxItems: 16
type: array
mergeType:
description: |-
MergeType determines how this configuration is merged with existing EnvoyExtensionPolicy
configurations targeting a parent resource. When set, this configuration will be merged
into a parent EnvoyExtensionPolicy (i.e. the one targeting a Gateway or Listener).
This field cannot be set when targeting a parent resource (Gateway).
If unset, no merging occurs, and only the most specific configuration takes effect.
type: string
x-kubernetes-validations:
- message: Replace is not a valid MergeType for EnvoyExtensionPolicy
rule: self != 'Replace'
targetRef:
description: |-
TargetRef is the name of the resource this policy is being attached to.
Expand Down
Loading
Loading