From 726024151132466496251c3fb45c060c657f0a04 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Tue, 8 Nov 2022 22:29:05 +0100 Subject: [PATCH] Remove some logs caused by external apps (#16027) --- cmd/bucket-listobjects-handlers.go | 18 +++++++++++++----- cmd/erasure-object.go | 1 + cmd/handler-utils.go | 4 ---- cmd/object-api-input-checks.go | 3 --- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/cmd/bucket-listobjects-handlers.go b/cmd/bucket-listobjects-handlers.go index 382777f31..33dfe4f5a 100644 --- a/cmd/bucket-listobjects-handlers.go +++ b/cmd/bucket-listobjects-handlers.go @@ -35,7 +35,7 @@ import ( // - delimiter if set should be equal to '/', otherwise the request is rejected. // - marker if set should have a common prefix with 'prefix' param, otherwise // the request is rejected. -func validateListObjectsArgs(marker, delimiter, encodingType string, maxKeys int) APIErrorCode { +func validateListObjectsArgs(prefix, marker, delimiter, encodingType string, maxKeys int) APIErrorCode { // Max keys cannot be negative. if maxKeys < 0 { return ErrInvalidMaxKeys @@ -48,6 +48,14 @@ func validateListObjectsArgs(marker, delimiter, encodingType string, maxKeys int } } + if !IsValidObjectPrefix(prefix) { + return ErrInvalidObjectName + } + + if marker != "" && !HasPrefix(marker, prefix) { + return ErrNotImplemented + } + return ErrNone } @@ -83,7 +91,7 @@ func (api objectAPIHandlers) ListObjectVersionsHandler(w http.ResponseWriter, r } // Validate the query params before beginning to serve the request. - if s3Error := validateListObjectsArgs(marker, delimiter, encodingType, maxkeys); s3Error != ErrNone { + if s3Error := validateListObjectsArgs(prefix, marker, delimiter, encodingType, maxkeys); s3Error != ErrNone { writeErrorResponse(ctx, w, errorCodes.ToAPIErr(s3Error), r.URL) return } @@ -148,7 +156,7 @@ func (api objectAPIHandlers) ListObjectsV2MHandler(w http.ResponseWriter, r *htt // Validate the query params before beginning to serve the request. // fetch-owner is not validated since it is a boolean - if s3Error := validateListObjectsArgs(token, delimiter, encodingType, maxKeys); s3Error != ErrNone { + if s3Error := validateListObjectsArgs(prefix, token, delimiter, encodingType, maxKeys); s3Error != ErrNone { writeErrorResponse(ctx, w, errorCodes.ToAPIErr(s3Error), r.URL) return } @@ -218,7 +226,7 @@ func (api objectAPIHandlers) ListObjectsV2Handler(w http.ResponseWriter, r *http // Validate the query params before beginning to serve the request. // fetch-owner is not validated since it is a boolean - if s3Error := validateListObjectsArgs(token, delimiter, encodingType, maxKeys); s3Error != ErrNone { + if s3Error := validateListObjectsArgs(prefix, token, delimiter, encodingType, maxKeys); s3Error != ErrNone { writeErrorResponse(ctx, w, errorCodes.ToAPIErr(s3Error), r.URL) return } @@ -325,7 +333,7 @@ func (api objectAPIHandlers) ListObjectsV1Handler(w http.ResponseWriter, r *http } // Validate all the query params before beginning to serve the request. - if s3Error := validateListObjectsArgs(marker, delimiter, encodingType, maxKeys); s3Error != ErrNone { + if s3Error := validateListObjectsArgs(prefix, marker, delimiter, encodingType, maxKeys); s3Error != ErrNone { writeErrorResponse(ctx, w, errorCodes.ToAPIErr(s3Error), r.URL) return } diff --git a/cmd/erasure-object.go b/cmd/erasure-object.go index 5d859e2da..27270e7b5 100644 --- a/cmd/erasure-object.go +++ b/cmd/erasure-object.go @@ -533,6 +533,7 @@ func readAllXL(ctx context.Context, disks []StorageAPI, bucket, object string, r ignoredErrs := []error{ errFileNotFound, + errFileNameTooLong, errVolumeNotFound, errFileVersionNotFound, errDiskNotFound, diff --git a/cmd/handler-utils.go b/cmd/handler-utils.go index cb24ceac8..1cc70b773 100644 --- a/cmd/handler-utils.go +++ b/cmd/handler-utils.go @@ -367,10 +367,6 @@ func getResource(path string, host string, domains []string) (string, error) { // If virtual-host-style is enabled construct the "resource" properly. xhost, err := xnet.ParseHost(host) if err != nil { - reqInfo := (&logger.ReqInfo{}).AppendTags("host", host) - reqInfo.AppendTags("path", path) - ctx := logger.SetReqInfo(context.Background(), reqInfo) - logger.LogIf(ctx, err) return "", err } diff --git a/cmd/object-api-input-checks.go b/cmd/object-api-input-checks.go index 9cffdedb1..a85f32316 100644 --- a/cmd/object-api-input-checks.go +++ b/cmd/object-api-input-checks.go @@ -41,16 +41,13 @@ func checkDelObjArgs(ctx context.Context, bucket, object string) error { func checkBucketAndObjectNames(ctx context.Context, bucket, object string) error { // Verify if bucket is valid. if !isMinioMetaBucketName(bucket) && s3utils.CheckValidBucketName(bucket) != nil { - logger.LogIf(ctx, BucketNameInvalid{Bucket: bucket}) return BucketNameInvalid{Bucket: bucket} } // Verify if object is valid. if len(object) == 0 { - logger.LogIf(ctx, ObjectNameInvalid{Bucket: bucket, Object: object}) return ObjectNameInvalid{Bucket: bucket, Object: object} } if !IsValidObjectPrefix(object) { - logger.LogIf(ctx, ObjectNameInvalid{Bucket: bucket, Object: object}) return ObjectNameInvalid{Bucket: bucket, Object: object} } if runtime.GOOS == globalWindowsOSName && strings.Contains(object, "\\") {