Add '+' to key sanitizer whitelist (#8396)

This commit is contained in:
Andrew Burke
2021-10-28 16:02:55 -07:00
committed by GitHub
parent e6339821d8
commit 71ea32fbae
6 changed files with 12 additions and 8 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ require (
github.com/gravitational/license v0.0.0-20210218173955-6d8fb49b117a
github.com/gravitational/oxy v0.0.0-20210316180922-c73d80d27348
github.com/gravitational/reporting v0.0.0-20180907002058-ac7b85c75c4c
github.com/gravitational/roundtrip v1.0.0
github.com/gravitational/roundtrip v1.0.1
github.com/gravitational/teleport/api v0.0.0
github.com/gravitational/trace v1.1.16-0.20210617142343-5335ac7a6c19
github.com/gravitational/ttlmap v0.0.0-20171116003245-91fd36b9004c
+2 -2
View File
@@ -386,8 +386,8 @@ github.com/gravitational/protobuf v1.3.2-0.20201123192827-2b9fcfaffcbf h1:MQ4e8X
github.com/gravitational/protobuf v1.3.2-0.20201123192827-2b9fcfaffcbf/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/gravitational/reporting v0.0.0-20180907002058-ac7b85c75c4c h1:UwN3jo2EfZSGDchLVqH/EJ2A5GWvKROx3NJNUI6/plg=
github.com/gravitational/reporting v0.0.0-20180907002058-ac7b85c75c4c/go.mod h1:rBJeI3JYVzbL7Yw2hYrp4QdKIkncb1pUHo95DyoEGns=
github.com/gravitational/roundtrip v1.0.0 h1:eb+0EABfSKC8607CQ4oOyWCm9zVIfio/wW78TjQqLSc=
github.com/gravitational/roundtrip v1.0.0/go.mod h1:qccpLd30tAJVSpx7aOEEnws4ZT3njPwdbtT8lNQxbAs=
github.com/gravitational/roundtrip v1.0.1 h1:eD/y0av12Gu9VIwNgPY/ltmpeVk0Azek/yIJvOPuTuY=
github.com/gravitational/roundtrip v1.0.1/go.mod h1:qccpLd30tAJVSpx7aOEEnws4ZT3njPwdbtT8lNQxbAs=
github.com/gravitational/trace v1.1.15/go.mod h1:RvdOUHE4SHqR3oXlFFKnGzms8a5dugHygGw1bqDstYI=
github.com/gravitational/trace v1.1.16-0.20210617142343-5335ac7a6c19 h1:xGVds0BJZh27H1/DrlEZM+7C57ck0XgVJU6VQRa0jkQ=
github.com/gravitational/trace v1.1.16-0.20210617142343-5335ac7a6c19/go.mod h1:RvdOUHE4SHqR3oXlFFKnGzms8a5dugHygGw1bqDstYI=
+2 -2
View File
@@ -28,11 +28,11 @@ import (
)
// errorMessage is the error message to return when invalid input is provided by the caller.
const errorMessage = "special characters are not allowed in resource names, please use name composed only from characters, hyphens and dots: %q"
const errorMessage = "special characters are not allowed in resource names, please use name composed only from characters, hyphens, dots, and plus signs: %q"
// whitelistPattern is the pattern of allowed characters for each key within
// the path.
var whitelistPattern = regexp.MustCompile(`^[0-9A-Za-z@_:.\-/]*$`)
var whitelistPattern = regexp.MustCompile(`^[0-9A-Za-z@_:.\-/+]*$`)
// blacklistPattern matches some unallowed combinations
var blacklistPattern = regexp.MustCompile(`//`)
+4
View File
@@ -64,6 +64,10 @@ func (s *Suite) TestSanitizeBucket(c *check.C) {
inKey: RangeEnd([]byte("Malformed \xf0\x90\x28\xbc UTF8")),
outError: true,
},
{
inKey: []byte("test+subaddr@example.com"),
outError: false,
},
}
for i, tt := range tests {
+2 -2
View File
@@ -24,10 +24,10 @@ import (
)
// errorMessage is the error message to return when invalid input is provided by the caller.
const errorMessage = "invalid path, path can only be composed of characters, hyphens, slashes, and dots"
const errorMessage = "invalid path, path can only be composed of characters, hyphens, plus signs, slashes, and dots"
// whitelistPattern is the pattern of allowed characters for the path.
var whitelistPattern = regexp.MustCompile(`^[0-9A-Za-z@/_:.-]*$`)
var whitelistPattern = regexp.MustCompile(`^[0-9A-Za-z@/_:.+-]*$`)
// isPathSafe checks if the passed in path conforms to a whitelist.
func isPathSafe(s string) error {
+1 -1
View File
@@ -417,7 +417,7 @@ github.com/gravitational/oxy/utils
github.com/gravitational/reporting
github.com/gravitational/reporting/client
github.com/gravitational/reporting/types
# github.com/gravitational/roundtrip v1.0.0
# github.com/gravitational/roundtrip v1.0.1
## explicit
github.com/gravitational/roundtrip
# github.com/gravitational/teleport/api v0.0.0 => ./api