This commit is contained in:
Kurochan 2025-03-07 06:15:10 +00:00 committed by GitHub
commit f04a5ce70b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package ingress
import (
"fmt"
"net"
"net/http"
"net/url"
"regexp"
"strconv"
@ -260,7 +261,7 @@ func validateIngress(ingress []config.UnvalidatedIngressRule, defaults OriginReq
if err != nil {
return Ingress{}, errors.Wrap(err, "invalid HTTP status code")
}
if statusCode < 100 || statusCode > 999 {
if http.StatusText(statusCode) == "" {
return Ingress{}, fmt.Errorf("invalid HTTP status code: %d", statusCode)
}
srv := newStatusCode(statusCode)

View File

@ -247,10 +247,18 @@ ingress:
wantErr: true,
},
{
name: "Invalid HTTP status code",
name: "Invalid HTTP status code(8080)",
args: args{rawYAML: `
ingress:
- service: http_status:8080
`},
wantErr: true,
},
{
name: "Invalid HTTP status code(666)",
args: args{rawYAML: `
ingress:
- service: http_status:666
`},
wantErr: true,
},