diff --git a/cmd/gateway-azure-anonymous.go b/cmd/gateway-azure-anonymous.go index 69ea9a80c..776d3c7df 100644 --- a/cmd/gateway-azure-anonymous.go +++ b/cmd/gateway-azure-anonymous.go @@ -133,10 +133,12 @@ func (a *azureObjects) AnonGetBucketInfo(bucket string) (bucketInfo BucketInfo, if err != nil { return bucketInfo, traceError(err) } + bucketInfo = BucketInfo{ Name: bucket, Created: t, } + return bucketInfo, nil } diff --git a/cmd/gateway-azure.go b/cmd/gateway-azure.go index 1be8540a9..ef446e91d 100644 --- a/cmd/gateway-azure.go +++ b/cmd/gateway-azure.go @@ -327,6 +327,14 @@ func (a *azureObjects) MakeBucketWithLocation(bucket, location string) error { // GetBucketInfo - Get bucket metadata.. func (a *azureObjects) GetBucketInfo(bucket string) (bi BucketInfo, e error) { + // Verify if bucket (container-name) is valid. + // IsValidBucketName has same restrictions as container names mentioned + // in azure documentation, so we will simply use the same function here. + // Ref - https://docs.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata + if !IsValidBucketName(bucket) { + return bi, traceError(BucketNameInvalid{Bucket: bucket}) + } + // Azure does not have an equivalent call, hence use // ListContainers with prefix resp, err := a.client.ListContainers(storage.ListContainersParameters{ diff --git a/cmd/gateway-gcs-anonymous.go b/cmd/gateway-gcs-anonymous.go index 095d37178..4e7d5f6d2 100644 --- a/cmd/gateway-gcs-anonymous.go +++ b/cmd/gateway-gcs-anonymous.go @@ -135,8 +135,14 @@ func (l *gcsGateway) AnonGetBucketInfo(bucket string) (bucketInfo BucketInfo, er return bucketInfo, gcsToObjectError(traceError(anonErrToObjectErr(resp.StatusCode, bucket)), bucket) } + t, err := time.Parse(time.RFC1123, resp.Header.Get("Last-Modified")) + if err != nil { + return bucketInfo, traceError(err) + } + // Last-Modified date being returned by GCS return BucketInfo{ - Name: bucket, + Name: bucket, + Created: t, }, nil } diff --git a/cmd/gateway-s3.go b/cmd/gateway-s3.go index 3ebc5aa5f..b95a5df9c 100644 --- a/cmd/gateway-s3.go +++ b/cmd/gateway-s3.go @@ -25,6 +25,7 @@ import ( minio "github.com/minio/minio-go" "github.com/minio/minio-go/pkg/policy" + "github.com/minio/minio-go/pkg/s3utils" ) // s3ToObjectError converts Minio errors to minio object layer errors. @@ -161,6 +162,17 @@ func (l *s3Objects) MakeBucketWithLocation(bucket, location string) error { // GetBucketInfo gets bucket metadata.. func (l *s3Objects) GetBucketInfo(bucket string) (bi BucketInfo, e error) { + // Verify if bucket name is valid. + // We are using a separate helper function here to validate bucket + // names instead of IsValidBucketName() because there is a possibility + // that certains users might have buckets which are non-DNS compliant + // in us-east-1 and we might severely restrict them by not allowing + // access to these buckets. + // Ref - http://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html + if s3utils.CheckValidBucketName(bucket) != nil { + return bi, traceError(BucketNameInvalid{Bucket: bucket}) + } + buckets, err := l.Client.ListBuckets() if err != nil { return bi, s3ToObjectError(traceError(err), bucket)