honor bucket-key S3 feature (#4976)

fixes #4973
This commit is contained in:
Harshavardhana
2024-07-03 13:17:25 -07:00
committed by GitHub
parent 26680ab77c
commit f0176c041b
+20 -2
View File
@@ -109,12 +109,30 @@ func (stat statMessage) String() (msg string) {
}
if maxKeyEncrypted > 0 {
if keyID, ok := stat.Metadata["X-Amz-Server-Side-Encryption-Aws-Kms-Key-Id"]; ok {
// Handle various AWS S3 headers, behaviors etc.
var found bool
if enabled, ok := stat.Metadata["X-Amz-Server-Side-Encryption-Bucket-Key-Enabled"]; ok {
if enabled == "true" {
msgBuilder.WriteString(fmt.Sprintf("%-10s: SSE-%s\n", "Encryption", "KMS"))
}
// we still need to treat this as 'true' because X-Amz-Server-Side-Encryption-Bucket-Key-Enabled
// can be set to 'false' by the server to indicate there is no SSE enabled on the object
// we shouldn't be printing `unknown` in that scenario.
found = true
} else if keyID, ok := stat.Metadata["X-Amz-Server-Side-Encryption-Aws-Kms-Key-Id"]; ok {
msgBuilder.WriteString(fmt.Sprintf("%-10s: SSE-%s (%s)\n", "Encryption", "KMS", keyID))
found = true
} else if _, ok := stat.Metadata["X-Amz-Server-Side-Encryption-Customer-Key-Md5"]; ok {
msgBuilder.WriteString(fmt.Sprintf("%-10s: SSE-%s\n", "Encryption", "C"))
} else {
found = true
} else if algo, ok := stat.Metadata["X-Amz-Server-Side-Encryption"]; ok && algo == "AES256" {
msgBuilder.WriteString(fmt.Sprintf("%-10s: SSE-%s\n", "Encryption", "S3"))
found = true
}
if !found {
// encryption headers are present but not something we recognize, check `mc stat --debug`
// to obtain more information and understand if we are missing something.
msgBuilder.WriteString(fmt.Sprintf("%-10s: SSE-%s\n", "Encryption", "Unknown"))
}
}