@@ -107,6 +107,8 @@ func validateTargetRef(ref v1alpha2.LocalPolicyTargetReference, policyNs string)
107
107
return nil
108
108
}
109
109
110
+ // validateSettings performs validation on fields in the spec that are vulnerable to code injection.
111
+ // For all other fields, we rely on the CRD validation.
110
112
func (v * Validator ) validateSettings (spec ngfAPI.ClientSettingsPolicySpec ) error {
111
113
var allErrs field.ErrorList
112
114
fieldPath := field .NewPath ("spec" )
@@ -146,18 +148,6 @@ func (v *Validator) validateClientBody(body ngfAPI.ClientBody, fieldPath *field.
146
148
func (v * Validator ) validateClientKeepAlive (keepAlive ngfAPI.ClientKeepAlive , fieldPath * field.Path ) field.ErrorList {
147
149
var allErrs field.ErrorList
148
150
149
- if keepAlive .Requests != nil {
150
- requests := * keepAlive .Requests
151
- if requests < 0 {
152
- path := fieldPath .Child ("requests" )
153
-
154
- allErrs = append (
155
- allErrs ,
156
- field .Invalid (path , * keepAlive .Requests , "requests is invalid: must be positive" ),
157
- )
158
- }
159
- }
160
-
161
151
if keepAlive .Time != nil {
162
152
if err := v .genericValidator .ValidateNginxDuration (string (* keepAlive .Time )); err != nil {
163
153
path := fieldPath .Child ("time" )
@@ -190,19 +180,6 @@ func (v *Validator) validateClientKeepAlive(keepAlive ngfAPI.ClientKeepAlive, fi
190
180
)
191
181
}
192
182
}
193
-
194
- if keepAlive .Timeout .Header != nil && keepAlive .Timeout .Server == nil {
195
- path := fieldPath .Child ("timeout" )
196
-
197
- allErrs = append (
198
- allErrs ,
199
- field .Invalid (
200
- path ,
201
- nil ,
202
- "server timeout must be set if header timeout is set" ,
203
- ),
204
- )
205
- }
206
183
}
207
184
208
185
return allErrs
0 commit comments