Skip to content
Open
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
75 changes: 75 additions & 0 deletions api/v1alpha1/envoyproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type EnvoyProxy struct {
}

// EnvoyProxySpec defines the desired state of EnvoyProxy.
// +kubebuilder:validation:XValidation:rule="!has(self.luaValidation) || !has(self.lua)",message="only one of luaValidation or lua may be set"
// +kubebuilder:validation:XValidation:message="mergeGateways and mergeBackends cannot both be enabled",rule="!(has(self.mergeGateways) && self.mergeGateways && has(self.mergeBackends))"
type EnvoyProxySpec struct {
// Provider defines the desired resource provider and provider-specific configuration.
Expand Down Expand Up @@ -200,9 +201,19 @@ type EnvoyProxySpec struct {

// LuaValidation determines strictness of the Lua script validation for Lua EnvoyExtensionPolicies
// Default: Strict
//
// Deprecated: Use Lua.ValidationType instead. This field will be removed in a future release.
// +optional
LuaValidation *LuaValidation `json:"luaValidation,omitempty"`

// Lua configures how Lua scripts from EnvoyExtensionPolicy resources are
// validated in the gateway controller. It selects the validation mode and, for the Strict
// mode, defines the filesystem paths and environment variables the scripts are permitted to
// access during validation.
//
// +optional
Lua *LuaValidationConfig `json:"lua,omitempty"`

// DynamicModules defines the set of dynamic modules that are allowed to be
// used by EnvoyExtensionPolicy resources and dynamic module load balancer
// policies. Each entry registers a module by a logical name and specifies
Expand Down Expand Up @@ -269,6 +280,66 @@ const (
LuaValidationDisabled LuaValidation = "Disabled"
)

// LuaValidationConfig configures how Lua scripts from EnvoyExtensionPolicy resources are validated
// in the gateway controller.
//
// +union
// +kubebuilder:validation:XValidation:rule="!has(self.strictValidation) || !has(self.validationType) || self.validationType == 'Strict'",message="strictValidation can only be set when validationType is Strict"
type LuaValidationConfig struct {
// ValidationType determines the strictness of the Lua script validation.
// Default: Strict
//
// +unionDiscriminator
// +kubebuilder:default=Strict
// +optional
ValidationType *LuaValidation `json:"validationType,omitempty"`

// StrictValidation configures the security sandbox that the Strict validation mode executes Lua
// scripts in, defining the filesystem paths and environment variables the scripts are permitted
// to access during validation.
//
// It has no effect for the InsecureSyntax or Disabled modes, which do not execute the security
// sandbox.
//
// +optional
StrictValidation *StrictValidation `json:"strictValidation,omitempty"`
}

// StrictValidation defines the configuration that Strict Lua validation runs with.
//
// This configuration only applies to the Strict validation mode; it has no effect on the
// InsecureSyntax and Disabled modes.
type StrictValidation struct {
// AllowedPaths is the list of filesystem path prefixes that Lua scripts are permitted to
// access during validation (via io.open, io.input, io.output, io.lines, os.remove, os.rename).
// A path is allowed when it equals an entry or is contained within an entry's subtree
// (e.g. "/tmp" allows "/tmp/file.txt"). Paths are normalized (separators collapsed, made
// absolute) before matching, and any "." or ".." traversal segment is always rejected.
// When empty, all filesystem access is denied. Blank or whitespace-only entries are rejected,
// as they would otherwise match every path and disable the sandbox. The filesystem root ("/")
// is likewise rejected, as it would allow access to the entire filesystem and defeat the sandbox.
//
// +kubebuilder:validation:MaxItems=64
// +kubebuilder:validation:items:MinLength=1
// +kubebuilder:validation:items:MaxLength=4096
// +kubebuilder:validation:XValidation:rule="self.all(p, p.trim() != '')",message="allowedPaths entries must not be blank or whitespace-only"
// +kubebuilder:validation:XValidation:rule="self.all(p, !p.matches('^/+$'))",message="allowedPaths entries must not be the filesystem root"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

FYI: added this new validation as well

// +optional
AllowedPaths []string `json:"allowedPaths,omitempty"`

@zirain zirain Jun 14, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the configuration looks a little redundant.

luaValidationAllowlist:
  allowedPaths:

what about using following?

luaValidation:
  allowedPaths:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Problem is there is an existing luaValidation API used for configuring the mode/level. It is a string enum type so can't have child params. How about:

luaStrictValidationAllowlist:
  paths:
  envVars:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Problem is there is an existing luaValidation API used for configuring the mode/level. It is a string enum type so can't have child params. How about:

luaStrictValidationAllowlist:
  paths:
  envVars:

I'm mostly concerts with the Allow in the naming, which might be a blocker if we want to add blacklist for the validation instead of whitelist.

@rudrakhp rudrakhp Jun 15, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Got it how about:

luaStrictValidation:
  allowedPaths:
  allowedEnvVars:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sounds good to me.


// AllowedEnvVars is the list of environment variable names that Lua scripts are permitted to
// access during validation (via os.getenv, os.setenv). Matching is exact and case-sensitive.
// When empty, access to all environment variables is denied. Blank or whitespace-only entries
// are rejected.
//
// +kubebuilder:validation:MaxItems=64
// +kubebuilder:validation:items:MinLength=1
// +kubebuilder:validation:items:MaxLength=256
// +kubebuilder:validation:XValidation:rule="self.all(e, e.trim() != '')",message="allowedEnvVars entries must not be blank or whitespace-only"
// +optional
AllowedEnvVars []string `json:"allowedEnvVars,omitempty"`
}

// RoutingType defines the type of routing of this Envoy proxy.
type RoutingType string

Expand Down Expand Up @@ -700,6 +771,8 @@ type EnvoyProxyConditionType string

const (
EnvoyProxyConditionAccepted EnvoyProxyConditionType = "Accepted"

EnvoyProxyConditionWarning EnvoyProxyConditionType = "Warning"
)

type EnvoyProxyConditionReason string
Expand All @@ -708,6 +781,8 @@ const (
EnvoyProxyReasonAccepted EnvoyProxyConditionReason = "Accepted"

EnvoyProxyReasonInvalidParameters EnvoyProxyConditionReason = "InvalidParameters"

EnvoyProxyReasonDeprecatedField EnvoyProxyConditionReason = "DeprecatedField"
)

// +kubebuilder:object:root=true
Expand Down
55 changes: 55 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 @@ -772,10 +772,82 @@ spec:
and the log level is the value. If unspecified, defaults to "default: warn".
type: object
type: object
lua:
description: |-
Lua configures how Lua scripts from EnvoyExtensionPolicy resources are
validated in the gateway controller. It selects the validation mode and, for the Strict
mode, defines the filesystem paths and environment variables the scripts are permitted to
access during validation.
properties:
strictValidation:
description: |-
StrictValidation configures the security sandbox that the Strict validation mode executes Lua
scripts in, defining the filesystem paths and environment variables the scripts are permitted
to access during validation.

It has no effect for the InsecureSyntax or Disabled modes, which do not execute the security
sandbox.
properties:
allowedEnvVars:
description: |-
AllowedEnvVars is the list of environment variable names that Lua scripts are permitted to
access during validation (via os.getenv, os.setenv). Matching is exact and case-sensitive.
When empty, access to all environment variables is denied. Blank or whitespace-only entries
are rejected.
items:
maxLength: 256
minLength: 1
type: string
maxItems: 64
type: array
x-kubernetes-validations:
- message: allowedEnvVars entries must not be blank or whitespace-only
rule: self.all(e, e.trim() != '')
allowedPaths:
description: |-
AllowedPaths is the list of filesystem path prefixes that Lua scripts are permitted to
access during validation (via io.open, io.input, io.output, io.lines, os.remove, os.rename).
A path is allowed when it equals an entry or is contained within an entry's subtree
(e.g. "/tmp" allows "/tmp/file.txt"). Paths are normalized (separators collapsed, made
absolute) before matching, and any "." or ".." traversal segment is always rejected.
When empty, all filesystem access is denied. Blank or whitespace-only entries are rejected,
as they would otherwise match every path and disable the sandbox. The filesystem root ("/")
is likewise rejected, as it would allow access to the entire filesystem and defeat the sandbox.
items:
maxLength: 4096
minLength: 1
type: string
maxItems: 64
type: array
x-kubernetes-validations:
- message: allowedPaths entries must not be blank or whitespace-only
rule: self.all(p, p.trim() != '')
- message: allowedPaths entries must not be the filesystem
root
rule: self.all(p, !p.matches('^/+$'))
type: object
validationType:
default: Strict
description: |-
ValidationType determines the strictness of the Lua script validation.
Default: Strict
enum:
- Strict
- InsecureSyntax
- Disabled
type: string
type: object
x-kubernetes-validations:
- message: strictValidation can only be set when validationType is
Strict
rule: '!has(self.strictValidation) || !has(self.validationType)
|| self.validationType == ''Strict'''
luaValidation:
description: |-
LuaValidation determines strictness of the Lua script validation for Lua EnvoyExtensionPolicies
Default: Strict

Deprecated: Use Lua.ValidationType instead. This field will be removed in a future release.
enum:
- Strict
- InsecureSyntax
Expand Down Expand Up @@ -18254,6 +18326,8 @@ spec:
type: object
type: object
x-kubernetes-validations:
- message: only one of luaValidation or lua may be set
rule: '!has(self.luaValidation) || !has(self.lua)'
- message: mergeGateways and mergeBackends cannot both be enabled
rule: '!(has(self.mergeGateways) && self.mergeGateways && has(self.mergeBackends))'
status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -771,10 +771,82 @@ spec:
and the log level is the value. If unspecified, defaults to "default: warn".
type: object
type: object
lua:
description: |-
Lua configures how Lua scripts from EnvoyExtensionPolicy resources are
validated in the gateway controller. It selects the validation mode and, for the Strict
mode, defines the filesystem paths and environment variables the scripts are permitted to
access during validation.
properties:
strictValidation:
description: |-
StrictValidation configures the security sandbox that the Strict validation mode executes Lua
scripts in, defining the filesystem paths and environment variables the scripts are permitted
to access during validation.

It has no effect for the InsecureSyntax or Disabled modes, which do not execute the security
sandbox.
properties:
allowedEnvVars:
description: |-
AllowedEnvVars is the list of environment variable names that Lua scripts are permitted to
access during validation (via os.getenv, os.setenv). Matching is exact and case-sensitive.
When empty, access to all environment variables is denied. Blank or whitespace-only entries
are rejected.
items:
maxLength: 256
minLength: 1
type: string
maxItems: 64
type: array
x-kubernetes-validations:
- message: allowedEnvVars entries must not be blank or whitespace-only
rule: self.all(e, e.trim() != '')
allowedPaths:
description: |-
AllowedPaths is the list of filesystem path prefixes that Lua scripts are permitted to
access during validation (via io.open, io.input, io.output, io.lines, os.remove, os.rename).
A path is allowed when it equals an entry or is contained within an entry's subtree
(e.g. "/tmp" allows "/tmp/file.txt"). Paths are normalized (separators collapsed, made
absolute) before matching, and any "." or ".." traversal segment is always rejected.
When empty, all filesystem access is denied. Blank or whitespace-only entries are rejected,
as they would otherwise match every path and disable the sandbox. The filesystem root ("/")
is likewise rejected, as it would allow access to the entire filesystem and defeat the sandbox.
items:
maxLength: 4096
minLength: 1
type: string
maxItems: 64
type: array
x-kubernetes-validations:
- message: allowedPaths entries must not be blank or whitespace-only
rule: self.all(p, p.trim() != '')
- message: allowedPaths entries must not be the filesystem
root
rule: self.all(p, !p.matches('^/+$'))
type: object
validationType:
default: Strict
description: |-
ValidationType determines the strictness of the Lua script validation.
Default: Strict
enum:
- Strict
- InsecureSyntax
- Disabled
type: string
type: object
x-kubernetes-validations:
- message: strictValidation can only be set when validationType is
Strict
rule: '!has(self.strictValidation) || !has(self.validationType)
|| self.validationType == ''Strict'''
luaValidation:
description: |-
LuaValidation determines strictness of the Lua script validation for Lua EnvoyExtensionPolicies
Default: Strict

Deprecated: Use Lua.ValidationType instead. This field will be removed in a future release.
enum:
- Strict
- InsecureSyntax
Expand Down Expand Up @@ -18253,6 +18325,8 @@ spec:
type: object
type: object
x-kubernetes-validations:
- message: only one of luaValidation or lua may be set
rule: '!has(self.luaValidation) || !has(self.lua)'
- message: mergeGateways and mergeBackends cannot both be enabled
rule: '!(has(self.mergeGateways) && self.mergeGateways && has(self.mergeBackends))'
status:
Expand Down
Loading