diff --git a/internal/ingress/inspector/inspector_test.go b/internal/ingress/inspector/inspector_test.go index 4798ba8783..cf19aba7ff 100644 --- a/internal/ingress/inspector/inspector_test.go +++ b/internal/ingress/inspector/inspector_test.go @@ -44,10 +44,18 @@ var ( PathType: &prefix, Path: "/xpto/ab0/x_ss-9", }, + { + PathType: &prefix, + Path: "/.well-known/acme-challenge/", + }, { PathType: &exact, Path: "/bla/", }, + { + PathType: &exact, + Path: "/.well-known/acme-challenge/", + }, }, }, }, @@ -101,6 +109,14 @@ var ( PathType: &prefix, Path: "/lala/xp\ntest", }, + { + PathType: &prefix, + Path: "/$lala/test", + }, + { + PathType: &prefix, + Path: "#lala/test", + }, { Path: "notvalidpathname-panics", }, @@ -177,6 +193,8 @@ func TestValidatePathType(t *testing.T) { aErr("xpto/lala", "Exact"), aErr("/foo/bar/[a-z]{3}", "Prefix"), aErr("/lala/xp\ntest", "Prefix"), + aErr("/$lala/test", "Prefix"), + aErr("#lala/test", "Prefix"), aErr("notvalidpathname-panics", ""), ), }, diff --git a/internal/ingress/inspector/rules.go b/internal/ingress/inspector/rules.go index 8388efdd5b..fc9e49d571 100644 --- a/internal/ingress/inspector/rules.go +++ b/internal/ingress/inspector/rules.go @@ -28,13 +28,13 @@ var ( invalidSecretsDir = regexp.MustCompile(`/var/run/secrets`) invalidByLuaDirective = regexp.MustCompile(`.*_by_lua.*`) - // validPathType enforces alphanumeric, -, _ and / characters. - // The field (?i) turns this regex case insensitive + // validPathType enforces alphanumeric, -, _ , . and / characters. + // The field (?i) turns this regex case-insensitive // The remaining regex says that the string must start with a "/" (^/) - // the group [[:alnum:]\_\-\/]* says that any amount of characters (A-Za-z0-9), _, - and / + // the group [[:alnum:]\_\-\/\.]* says that any amount of characters (A-Za-z0-9), _, - , . and / // are accepted until the end of the line // Nothing else is accepted. - validPathType = regexp.MustCompile(`(?i)^/[[:alnum:]\_\-/]*$`) + validPathType = regexp.MustCompile(`(?i)^/[[:alnum:]._\-/]*$`) invalidRegex = []regexp.Regexp{} )