-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Request/Response Checksum Behavior Updates #3277
base: flexible-checksums-v2
Are you sure you want to change the base?
Request/Response Checksum Behavior Updates #3277
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## flexible-checksums-v2 #3277 +/- ##
========================================================
Coverage ? 93.14%
========================================================
Files ? 66
Lines ? 14424
Branches ? 0
========================================================
Hits ? 13435
Misses ? 989
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
# `payload_signing_enabled` config overrides this logic and forces the | ||
# header. | ||
def test_content_sha256_not_set_if_config_value_is_true(self): | ||
# By default, put_object() provides a trailing checksum and includes the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this right? I wouldn't expect us to be using trailing checksums by default on put_object
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because CRC32 is the new default, put_object
will use trailing checksums by default. This is because put_object
has streaming input.
You can see this behavior in the current version of the SDK by running:
import boto3
boto3.set_stream_logger('')
s3 = boto3.client("s3")
response = s3.put_object(
Body=b"Example data.",
Bucket="<bucket_name>",
Key="example_key.txt",
ChecksumAlgorithm="CRC32",
)
2d66b37
to
d586cba
Compare
ccbc9c0
to
17ef6f7
Compare
Add ``request_checksum_calculation`` and ``response_checksum_validation`` config options.
* Add support for CRC64NVME when the CRT is available. * Update crc64nvme priority
…ed checksums." This reverts commit 93a47eb.
Add ``request_checksum_calculation`` and ``response_checksum_validation`` config options.
* Add support for CRC64NVME when the CRT is available. * Update crc64nvme priority
d586cba
to
fac0754
Compare
009ea3d
to
626c08a
Compare
botocore/httpchecksum.py
Outdated
if "extra_headers" in algorithm: | ||
request["headers"].update(algorithm["extra_headers"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this work if the user already supplied these headers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The header we're worried about would only get added when the default checksum is used. This means that the user didn't supply the "requestAlgorithmMember"
member. The user's input would always take precedence.
I'll update this logic to be less generic as suggested by your other comment.
botocore/httpchecksum.py
Outdated
if has_checksum_header(request): | ||
return | ||
|
||
extra_headers = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a rough idea of what expansion we're expecting here? Generally grab-bag style containers like this tend to grow in unexpected ways. It may be worth constraining to the exact header we're expecting since it's tightly coupled to the checksum we're creating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated this to instead store the following in our request checksum context:
"request_algorithm_header": {
"name": "foo",
"value": "bar",
},
We can later check if "request_algorithm_header" in request["context"]["checksum"]
and apply the header if it exists. Let me know if that's better.
# We only support unsigned trailer checksums currently. As this | ||
# disables payload signing we'll only use trailers over TLS. | ||
location_type = "trailer" | ||
if request["context"]["client_config"].signature_version != 's3': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: would we prefer this if condition to be added to the parent if viaand
?
This PR makes the following updates to the botocore flexible checksum behavior:
Request Checksum Calculation
awscrt
dependency.request_checksum_calculation
config is set towhen_supported
(default value), a checksum will be generated whenever one of the following conditions is true:httpchecksum
trait and defines arequestAlgorithmMember
.httpchecksum
trait and definesrequestChecksumRequired: true
.request_checksum_calculation
config is set towhen_required
, a checksum will be generated only when:httpchecksum
trait and definesrequestChecksumRequired: true
.S3 Customizations:
Response Checksum Validation
requestValidationModeMember
by the user will be used by the SDK.requestValidationModeMember
value is not set by the user, the following behavior is experienced:response_checksum_validation
config is set towhen_supported
(default value), therequestValidationModeMember
will be set toENABLED
.response_checksum_validation
config is set towhen_required
, therequestValidationModeMember
will not be set and checksum validation is skipped.