s3: Return invalid bucket name the first thing in all S3 calls (#17742)

This commit is contained in:
Anis Eleuch
2023-07-28 18:49:20 +01:00
committed by GitHub
parent 114fab4c70
commit 7057d00a28
3 changed files with 16 additions and 4 deletions

View File

@@ -29,6 +29,7 @@ import (
"time"
"github.com/dustin/go-humanize"
"github.com/minio/minio-go/v7/pkg/s3utils"
"github.com/minio/minio-go/v7/pkg/set"
xnet "github.com/minio/pkg/net"
@@ -400,6 +401,17 @@ func setRequestValidityMiddleware(h http.Handler) http.Handler {
writeErrorResponse(r.Context(), w, errorCodes.ToAPIErr(ErrAllAccessDisabled), r.URL)
return
}
} else {
// Validate bucket names if it is not empty
if bucketName != "" && s3utils.CheckValidBucketNameStrict(bucketName) != nil {
if ok {
tc.FuncName = "handler.ValidRequest"
tc.ResponseRecorder.LogErrBody = true
}
defer logger.AuditLog(r.Context(), w, r, mustGetClaimsFromToken(r))
writeErrorResponse(r.Context(), w, errorCodes.ToAPIErr(ErrInvalidBucketName), r.URL)
return
}
}
// Deny SSE-C requests if not made over TLS
if !globalIsTLS && (crypto.SSEC.IsRequested(r.Header) || crypto.SSECopy.IsRequested(r.Header)) {