mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
parent
db3da97a50
commit
5ecba587f7
@ -174,7 +174,7 @@ func testGetBucketNotificationHandler(obj ObjectLayer, instanceType string, t Te
|
|||||||
// get random bucket name.
|
// get random bucket name.
|
||||||
randBucket := getRandomBucketName()
|
randBucket := getRandomBucketName()
|
||||||
noNotificationBucket := "nonotification"
|
noNotificationBucket := "nonotification"
|
||||||
invalidBucket := "Invalid^Bucket"
|
invalidBucket := "Invalid\\Bucket"
|
||||||
|
|
||||||
// Create buckets for the following test cases.
|
// Create buckets for the following test cases.
|
||||||
for _, bucket := range []string{randBucket, noNotificationBucket} {
|
for _, bucket := range []string{randBucket, noNotificationBucket} {
|
||||||
@ -326,7 +326,7 @@ func TestGetBucketNotificationHandler(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testPutBucketNotificationHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
func testPutBucketNotificationHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
||||||
invalidBucket := "Invalid^Bucket"
|
invalidBucket := "Invalid\\Bucket"
|
||||||
// get random bucket name.
|
// get random bucket name.
|
||||||
randBucket := getRandomBucketName()
|
randBucket := getRandomBucketName()
|
||||||
|
|
||||||
@ -483,7 +483,7 @@ func TestPutBucketNotificationHandler(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testListenBucketNotificationHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
func testListenBucketNotificationHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
||||||
invalidBucket := "Invalid^Bucket"
|
invalidBucket := "Invalid\\Bucket"
|
||||||
noNotificationBucket := "nonotificationbucket"
|
noNotificationBucket := "nonotificationbucket"
|
||||||
// get random bucket name.
|
// get random bucket name.
|
||||||
randBucket := getRandomBucketName()
|
randBucket := getRandomBucketName()
|
||||||
@ -629,7 +629,7 @@ func TestListenBucketNotificationHandler(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testRemoveNotificationConfig(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
func testRemoveNotificationConfig(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
||||||
invalidBucket := "Invalid^Bucket"
|
invalidBucket := "Invalid\\Bucket"
|
||||||
// get random bucket name.
|
// get random bucket name.
|
||||||
randBucket := getRandomBucketName()
|
randBucket := getRandomBucketName()
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ func TestFSDeleteObject(t *testing.T) {
|
|||||||
t.Fatal("Unexpected error: ", err)
|
t.Fatal("Unexpected error: ", err)
|
||||||
}
|
}
|
||||||
// Test with invalid object name
|
// Test with invalid object name
|
||||||
if err := fs.DeleteObject(bucketName, "^"); !isSameType(errorCause(err), ObjectNameInvalid{}) {
|
if err := fs.DeleteObject(bucketName, "\\"); !isSameType(errorCause(err), ObjectNameInvalid{}) {
|
||||||
t.Fatal("Unexpected error: ", err)
|
t.Fatal("Unexpected error: ", err)
|
||||||
}
|
}
|
||||||
// Test with inexist bucket/object
|
// Test with inexist bucket/object
|
||||||
|
@ -514,7 +514,7 @@ func testListObjects(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
|||||||
{"test-bucket-list-object", "/", "", "/", 10, resultCases[30], nil, true},
|
{"test-bucket-list-object", "/", "", "/", 10, resultCases[30], nil, true},
|
||||||
|
|
||||||
// Test with invalid prefix (61)
|
// Test with invalid prefix (61)
|
||||||
{"test-bucket-list-object", "^", "", "/", 10, resultCases[30], ObjectNameInvalid{Bucket: "test-bucket-list-object", Object: "^"}, false},
|
{"test-bucket-list-object", "\\", "", "/", 10, resultCases[30], ObjectNameInvalid{Bucket: "test-bucket-list-object", Object: "\\"}, false},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, testCase := range testCases {
|
for i, testCase := range testCases {
|
||||||
|
@ -58,7 +58,7 @@ func testObjectNewMultipartUpload(obj ObjectLayer, instanceType string, t TestEr
|
|||||||
t.Fatalf("%s : %s", instanceType, err.Error())
|
t.Fatalf("%s : %s", instanceType, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = obj.NewMultipartUpload(bucket, "^", nil)
|
_, err = obj.NewMultipartUpload(bucket, "\\", nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("%s: Expected to fail since object name is invalid.", instanceType)
|
t.Fatalf("%s: Expected to fail since object name is invalid.", instanceType)
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ func testObjectAbortMultipartUpload(obj ObjectLayer, instanceType string, t Test
|
|||||||
expectedErrType error
|
expectedErrType error
|
||||||
}{
|
}{
|
||||||
{"--", object, uploadID, BucketNameInvalid{}},
|
{"--", object, uploadID, BucketNameInvalid{}},
|
||||||
{bucket, "^", uploadID, ObjectNameInvalid{}},
|
{bucket, "\\", uploadID, ObjectNameInvalid{}},
|
||||||
{"foo", object, uploadID, BucketNotFound{}},
|
{"foo", object, uploadID, BucketNotFound{}},
|
||||||
{bucket, object, "foo-foo", InvalidUploadID{}},
|
{bucket, object, "foo-foo", InvalidUploadID{}},
|
||||||
{bucket, object, uploadID, nil},
|
{bucket, object, uploadID, nil},
|
||||||
|
@ -75,11 +75,8 @@ func IsValidBucketName(bucket string) bool {
|
|||||||
// Rejects strings with following characters.
|
// Rejects strings with following characters.
|
||||||
//
|
//
|
||||||
// - Backslash ("\")
|
// - Backslash ("\")
|
||||||
// - Caret ("^")
|
|
||||||
// - Grave accent / back tick ("`")
|
|
||||||
// - Vertical bar / pipe ("|")
|
|
||||||
//
|
//
|
||||||
// Minio does not support object names with trailing "/".
|
// additionally minio does not support object names with trailing "/".
|
||||||
func IsValidObjectName(object string) bool {
|
func IsValidObjectName(object string) bool {
|
||||||
if len(object) == 0 {
|
if len(object) == 0 {
|
||||||
return false
|
return false
|
||||||
@ -103,7 +100,7 @@ func IsValidObjectPrefix(object string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// Reject unsupported characters in object name.
|
// Reject unsupported characters in object name.
|
||||||
if strings.ContainsAny(object, "`^|\\\"") {
|
if strings.ContainsAny(object, "\\") {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
@ -46,7 +46,7 @@ func TestIsValidBucketName(t *testing.T) {
|
|||||||
{"192.168.1.1", false},
|
{"192.168.1.1", false},
|
||||||
{"$this-is-not-valid-too", false},
|
{"$this-is-not-valid-too", false},
|
||||||
{"contains-$-dollar", false},
|
{"contains-$-dollar", false},
|
||||||
{"contains-^-carrot", false},
|
{"contains-^-carret", false},
|
||||||
{"contains-$-dollar", false},
|
{"contains-$-dollar", false},
|
||||||
{"contains-$-dollar", false},
|
{"contains-$-dollar", false},
|
||||||
{"......", false},
|
{"......", false},
|
||||||
@ -89,12 +89,17 @@ func TestIsValidObjectName(t *testing.T) {
|
|||||||
{"117Gn8rfHL2ACARPAhaFd0AGzic9pUbIA/5OCn5A", true},
|
{"117Gn8rfHL2ACARPAhaFd0AGzic9pUbIA/5OCn5A", true},
|
||||||
{"SHØRT", true},
|
{"SHØRT", true},
|
||||||
{"f*le", true},
|
{"f*le", true},
|
||||||
|
{"contains-^-carret", true},
|
||||||
|
{"contains-|-pipe", true},
|
||||||
|
{"contains-\"-quote", true},
|
||||||
|
{"contains-`-tick", true},
|
||||||
{"There are far too many object names, and far too few bucket names!", true},
|
{"There are far too many object names, and far too few bucket names!", true},
|
||||||
// cases for which test should fail.
|
// cases for which test should fail.
|
||||||
// passing invalid object names.
|
// passing invalid object names.
|
||||||
{"", false},
|
{"", false},
|
||||||
{"a/b/c/", false},
|
{"a/b/c/", false},
|
||||||
{"/a/b/c", false},
|
{"/a/b/c", false},
|
||||||
|
{"contains-\\-backslash", false},
|
||||||
{string([]byte{0xff, 0xfe, 0xfd}), false},
|
{string([]byte{0xff, 0xfe, 0xfd}), false},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ func (s *TestSuiteCommon) TestBucketSNSNotification(c *C) {
|
|||||||
|
|
||||||
verifyError(c, response, "InvalidArgument", "filter rule name must be either prefix or suffix", http.StatusBadRequest)
|
verifyError(c, response, "InvalidArgument", "filter rule name must be either prefix or suffix", http.StatusBadRequest)
|
||||||
|
|
||||||
invalidBucketNotificationBuf = `<NotificationConfiguration><TopicConfiguration><Event>s3:ObjectCreated:Put</Event><Filter><S3Key><FilterRule><Name>prefix</Name><Value>|||</Value></FilterRule></S3Key></Filter><Id>1</Id><Topic>arn:minio:sns:us-east-1:1:listen</Topic></TopicConfiguration></NotificationConfiguration>`
|
invalidBucketNotificationBuf = `<NotificationConfiguration><TopicConfiguration><Event>s3:ObjectCreated:Put</Event><Filter><S3Key><FilterRule><Name>prefix</Name><Value>hello\</Value></FilterRule></S3Key></Filter><Id>1</Id><Topic>arn:minio:sns:us-east-1:1:listen</Topic></TopicConfiguration></NotificationConfiguration>`
|
||||||
|
|
||||||
request, err = newTestSignedRequestV4("PUT", getPutNotificationURL(s.endPoint, bucketName),
|
request, err = newTestSignedRequestV4("PUT", getPutNotificationURL(s.endPoint, bucketName),
|
||||||
int64(len(invalidBucketNotificationBuf)), bytes.NewReader([]byte(invalidBucketNotificationBuf)), s.accessKey, s.secretKey)
|
int64(len(invalidBucketNotificationBuf)), bytes.NewReader([]byte(invalidBucketNotificationBuf)), s.accessKey, s.secretKey)
|
||||||
|
@ -173,7 +173,7 @@ func (s *TestSuiteCommonV2) TestBucketSNSNotification(c *C) {
|
|||||||
|
|
||||||
verifyError(c, response, "InvalidArgument", "filter rule name must be either prefix or suffix", http.StatusBadRequest)
|
verifyError(c, response, "InvalidArgument", "filter rule name must be either prefix or suffix", http.StatusBadRequest)
|
||||||
|
|
||||||
invalidBucketNotificationBuf = `<NotificationConfiguration><TopicConfiguration><Event>s3:ObjectCreated:Put</Event><Filter><S3Key><FilterRule><Name>prefix</Name><Value>|||</Value></FilterRule></S3Key></Filter><Id>1</Id><Topic>arn:minio:sns:us-east-1:1:listen</Topic></TopicConfiguration></NotificationConfiguration>`
|
invalidBucketNotificationBuf = `<NotificationConfiguration><TopicConfiguration><Event>s3:ObjectCreated:Put</Event><Filter><S3Key><FilterRule><Name>prefix</Name><Value>hello\</Value></FilterRule></S3Key></Filter><Id>1</Id><Topic>arn:minio:sns:us-east-1:1:listen</Topic></TopicConfiguration></NotificationConfiguration>`
|
||||||
|
|
||||||
request, err = newTestSignedRequestV2("PUT", getPutNotificationURL(s.endPoint, bucketName),
|
request, err = newTestSignedRequestV2("PUT", getPutNotificationURL(s.endPoint, bucketName),
|
||||||
int64(len(invalidBucketNotificationBuf)), bytes.NewReader([]byte(invalidBucketNotificationBuf)), s.accessKey, s.secretKey)
|
int64(len(invalidBucketNotificationBuf)), bytes.NewReader([]byte(invalidBucketNotificationBuf)), s.accessKey, s.secretKey)
|
||||||
|
Loading…
Reference in New Issue
Block a user