49
49
// Method must contain valid methods list (PUT, GET, POST, BLA)
50
50
// May contain or not spaces between each verb
51
51
corsMethodsRegex = regexp .MustCompile (`^([A-Za-z]+,?\s?)+$` )
52
- // Expose Headers must contain valid values only (*, X-HEADER12, X-ABC)
52
+ // CORS Headers must contain valid values only (*, X-HEADER12, X-ABC)
53
53
// May contain or not spaces between each Header
54
- corsExposeHeadersRegex = regexp .MustCompile (`^(([A-Za-z0-9\-\_]+|\*),?\s?)+$` )
54
+ corsHeadersRegex = regexp .MustCompile (`^(([A-Za-z0-9\-\_]+|\*),?\s?)+$` )
55
55
)
56
56
57
57
const (
@@ -83,11 +83,11 @@ var corsAnnotation = parser.Annotation{
83
83
Protocol can be any lowercase string, like http, https, or mycustomprotocol.` ,
84
84
},
85
85
corsAllowHeadersAnnotation : {
86
- Validator : parser .ValidateRegex (parser . HeadersVariable , true ),
86
+ Validator : parser .ValidateRegex (corsHeadersRegex , true ),
87
87
Scope : parser .AnnotationScopeIngress ,
88
88
Risk : parser .AnnotationRiskMedium ,
89
89
Documentation : `This annotation controls which headers are accepted.
90
- This is a multi-valued field, separated by ',' and accepts letters, numbers, _ and - ` ,
90
+ This is a multi-valued field, separated by ',' and accepts letters, numbers, _, - and *. ` ,
91
91
},
92
92
corsAllowMethodsAnnotation : {
93
93
Validator : parser .ValidateRegex (corsMethodsRegex , true ),
@@ -103,7 +103,7 @@ var corsAnnotation = parser.Annotation{
103
103
Documentation : `This annotation controls if credentials can be passed during CORS operations.` ,
104
104
},
105
105
corsExposeHeadersAnnotation : {
106
- Validator : parser .ValidateRegex (corsExposeHeadersRegex , true ),
106
+ Validator : parser .ValidateRegex (corsHeadersRegex , true ),
107
107
Scope : parser .AnnotationScopeIngress ,
108
108
Risk : parser .AnnotationRiskMedium ,
109
109
Documentation : `This annotation controls which headers are exposed to response.
@@ -226,7 +226,7 @@ func (c cors) Parse(ing *networking.Ingress) (interface{}, error) {
226
226
}
227
227
228
228
config .CorsAllowHeaders , err = parser .GetStringAnnotation (corsAllowHeadersAnnotation , ing , c .annotationConfig .Annotations )
229
- if err != nil || ! parser . HeadersVariable .MatchString (config .CorsAllowHeaders ) {
229
+ if err != nil || ! corsHeadersRegex .MatchString (config .CorsAllowHeaders ) {
230
230
config .CorsAllowHeaders = defaultCorsHeaders
231
231
}
232
232
@@ -246,7 +246,7 @@ func (c cors) Parse(ing *networking.Ingress) (interface{}, error) {
246
246
}
247
247
248
248
config .CorsExposeHeaders , err = parser .GetStringAnnotation (corsExposeHeadersAnnotation , ing , c .annotationConfig .Annotations )
249
- if err != nil || ! corsExposeHeadersRegex .MatchString (config .CorsExposeHeaders ) {
249
+ if err != nil || ! corsHeadersRegex .MatchString (config .CorsExposeHeaders ) {
250
250
config .CorsExposeHeaders = ""
251
251
}
252
252
0 commit comments