Skip to content

Ingresses: Allow . in Exact and Prefix paths. #13800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
18 changes: 18 additions & 0 deletions internal/ingress/inspector/inspector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
},
},
},
},
Expand Down Expand Up @@ -101,6 +109,14 @@ var (
PathType: &prefix,
Path: "/lala/xp\ntest",
},
{
PathType: &prefix,
Path: "/$lala/test",
},
{
PathType: &prefix,
Path: "#lala/test",
},
{
Path: "notvalidpathname-panics",
},
Expand Down Expand Up @@ -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", "<nil>"),
),
},
Expand Down
8 changes: 4 additions & 4 deletions internal/ingress/inspector/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
)
Expand Down