Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check both MD5 locations for S3 KMS support. #1272

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

neolynx
Copy link
Member

@neolynx neolynx commented Apr 17, 2024

Replaces #1167

Fixes #1117

Description of the Change

If the S3 bucket used to house a repo has KMS encryption enabled then the etag of an object may not match the MD5 of the file. This may cause an incorrect error to be reported stating the file already exists and is different.

A mechanism exists to work around this issue by using the MD5 stored in object metadata. This check doesn't always cover the case where KMS is enabled as the fallback is only used if the etag is not 32 characters long.

This commit changes the fallback mechanism so that it is used in any case where the object's etag is not 32 characters or if the S3 bucket has encryption enabled for new objects by default.

Checklist

  • unit-test added (if change is algorithm)
  • functional test added/updated (if change is functional)
  • man page updated (if applicable)
  • bash completion updated (if applicable)
  • documentation updated
  • author name in AUTHORS

Copy link

codecov bot commented Apr 20, 2024

Codecov Report

Attention: Patch coverage is 57.89474% with 8 lines in your changes are missing coverage. Please review.

Project coverage is 74.81%. Comparing base (8d09c20) to head (4960b40).
Report is 1 commits behind head on master.

Files Patch % Lines
s3/public.go 57.89% 6 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1272      +/-   ##
==========================================
+ Coverage   74.79%   74.81%   +0.02%     
==========================================
  Files         144      144              
  Lines       16256    16261       +5     
==========================================
+ Hits        12158    12165       +7     
  Misses       3156     3156              
+ Partials      942      940       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@neolynx neolynx changed the title fix/kms md5 check Check both MD5 locations for S3 KMS support. Apr 20, 2024
@neolynx neolynx added the needs review Ready for review & merge label Apr 20, 2024
@neolynx neolynx added the increase coverage The PR lacks test coverage label Apr 21, 2024
Melraidin and others added 4 commits April 24, 2024 17:41
If the S3 bucket used to house a repo has KMS encryption enabled then
the etag of an object may not match the MD5 of the file. This may
cause an incorrect error to be reported stating the file already
exists and is different.

A mechanism exists to work around this issue by using the MD5 stored
in object metadata. This check doesn't always cover the case where KMS
is enabled as the fallback is only used if the etag is not 32
characters long.

This commit changes the fallback mechanism so that it is used in any
case where the object's etag does not match the source MD5. This will
incur a performance penalty of an extra head request for each object
with a mismatch.
Adds check to see if the S3 bucket is encrypted by default. If so this
uses the existing workaround for object etags not matching file MD5s.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
increase coverage The PR lacks test coverage needs review Ready for review & merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'file already exists and is different' when publishing to S3 with KMS encryption
2 participants