Skip to content

Commit 89850e4

Browse files
Ingresses: Allow . in Exact and Prefix paths. (#13800)
Co-authored-by: Pascal Zimmermann <[email protected]>
1 parent ebf1c87 commit 89850e4

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

internal/ingress/inspector/inspector_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,18 @@ var (
4444
PathType: &prefix,
4545
Path: "/xpto/ab0/x_ss-9",
4646
},
47+
{
48+
PathType: &prefix,
49+
Path: "/.well-known/acme-challenge/",
50+
},
4751
{
4852
PathType: &exact,
4953
Path: "/bla/",
5054
},
55+
{
56+
PathType: &exact,
57+
Path: "/.well-known/acme-challenge/",
58+
},
5159
},
5260
},
5361
},
@@ -101,6 +109,14 @@ var (
101109
PathType: &prefix,
102110
Path: "/lala/xp\ntest",
103111
},
112+
{
113+
PathType: &prefix,
114+
Path: "/$lala/test",
115+
},
116+
{
117+
PathType: &prefix,
118+
Path: "#lala/test",
119+
},
104120
{
105121
Path: "notvalidpathname-panics",
106122
},
@@ -177,6 +193,8 @@ func TestValidatePathType(t *testing.T) {
177193
aErr("xpto/lala", "Exact"),
178194
aErr("/foo/bar/[a-z]{3}", "Prefix"),
179195
aErr("/lala/xp\ntest", "Prefix"),
196+
aErr("/$lala/test", "Prefix"),
197+
aErr("#lala/test", "Prefix"),
180198
aErr("notvalidpathname-panics", "<nil>"),
181199
),
182200
},

internal/ingress/inspector/rules.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ var (
2828
invalidSecretsDir = regexp.MustCompile(`/var/run/secrets`)
2929
invalidByLuaDirective = regexp.MustCompile(`.*_by_lua.*`)
3030

31-
// validPathType enforces alphanumeric, -, _ and / characters.
32-
// The field (?i) turns this regex case insensitive
31+
// validPathType enforces alphanumeric, -, _ , . and / characters.
32+
// The field (?i) turns this regex case-insensitive
3333
// The remaining regex says that the string must start with a "/" (^/)
34-
// the group [[:alnum:]\_\-\/]* says that any amount of characters (A-Za-z0-9), _, - and /
34+
// the group [[:alnum:]\_\-\/\.]* says that any amount of characters (A-Za-z0-9), _, - , . and /
3535
// are accepted until the end of the line
3636
// Nothing else is accepted.
37-
validPathType = regexp.MustCompile(`(?i)^/[[:alnum:]\_\-/]*$`)
37+
validPathType = regexp.MustCompile(`(?i)^/[[:alnum:]._\-/]*$`)
3838

3939
invalidRegex = []regexp.Regexp{}
4040
)

0 commit comments

Comments
 (0)