From 4483c6f57a968c2825aa2abcc1aee64cea67e884 Mon Sep 17 00:00:00 2001 From: Angira Kekteeva Date: Tue, 26 Jul 2022 05:08:25 +0400 Subject: [PATCH] [#619] Filter system metadata Signed-off-by: Angira Kekteeva --- api/headers.go | 29 ++++++++++++++++++++--------- api/layer/object.go | 3 ++- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/api/headers.go b/api/headers.go index 363babd19..52b37287f 100644 --- a/api/headers.go +++ b/api/headers.go @@ -2,15 +2,16 @@ package api // Standard S3 HTTP request/response constants. const ( - MetadataPrefix = "X-Amz-Meta-" - AmzMetadataDirective = "X-Amz-Metadata-Directive" - AmzVersionID = "X-Amz-Version-Id" - AmzTaggingCount = "X-Amz-Tagging-Count" - AmzTagging = "X-Amz-Tagging" - AmzDeleteMarker = "X-Amz-Delete-Marker" - AmzCopySource = "X-Amz-Copy-Source" - AmzCopySourceRange = "X-Amz-Copy-Source-Range" - AmzDate = "X-Amz-Date" + MetadataPrefix = "X-Amz-Meta-" + NeoFSSystemMetadataPrefix = "S3-" + AmzMetadataDirective = "X-Amz-Metadata-Directive" + AmzVersionID = "X-Amz-Version-Id" + AmzTaggingCount = "X-Amz-Tagging-Count" + AmzTagging = "X-Amz-Tagging" + AmzDeleteMarker = "X-Amz-Delete-Marker" + AmzCopySource = "X-Amz-Copy-Source" + AmzCopySourceRange = "X-Amz-Copy-Source-Range" + AmzDate = "X-Amz-Date" LastModified = "Last-Modified" Date = "Date" @@ -88,3 +89,13 @@ var ResponseModifiers = map[string]string{ "response-content-disposition": ContentDisposition, "response-content-encoding": ContentEncoding, } + +var SystemMetadata = map[string]struct{}{ + Date: {}, + CacheControl: {}, + ContentDisposition: {}, + ContentLength: {}, + ContentType: {}, + LastModified: {}, + ETag: {}, +} diff --git a/api/layer/object.go b/api/layer/object.go index 6eebb9bba..7ff32a3ee 100644 --- a/api/layer/object.go +++ b/api/layer/object.go @@ -613,7 +613,8 @@ func (n *layer) getAllObjectsVersions(ctx context.Context, bkt *data.BucketInfo, } func IsSystemHeader(key string) bool { - return strings.HasPrefix(key, "S3-") + _, ok := api.SystemMetadata[key] + return ok || strings.HasPrefix(key, api.NeoFSSystemMetadataPrefix) } func shouldSkip(node *data.NodeVersion, p allObjectParams, existed map[string]struct{}) bool {