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

Fix checksum encoding, content-encoding header #4507

Conversation

haydenbaker
Copy link
Contributor

Motivation and Context

  • Flexible checksums are supposed to be base64-encoded, not hex

Modifications

  • Updates encoding of checksums to be configurable
  • Updates FlexibleChecksummer to be more configurable through options

Testing

  • Ran with a few s3 integ tests, and chunk-encoded payloads now return 200's

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

Comment on lines -58 to -62

@Override
public String getChecksum() {
return value;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer needed (i added this default method), string repr is now configurable

Comment on lines -100 to -107

/**
* Return an encoded-string representation of the checksum. By default, this returns a String that is the lowercase, base16
* (hex) representation of the checksum.
*/
default String getChecksum() {
return toHex(getChecksumBytes());
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer needed (i added this default method), string repr is now configurable

@@ -41,7 +42,7 @@ public void reset() {
public Pair<String, List<String>> get() {
return Pair.of(
checksumName,
Collections.singletonList(checksum.getChecksum())
Collections.singletonList(BinaryUtils.toBase64(checksum.getChecksumBytes()))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flexible checksum as trailer MUST be base64

@haydenbaker haydenbaker marked this pull request as ready for review September 29, 2023 00:36
@haydenbaker haydenbaker requested a review from a team as a code owner September 29, 2023 00:36
Comment on lines -110 to -112
if (request instanceof SdkHttpFullRequest) {
return (SdkHttpFullRequest) request;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this old code and what's the story behind the removal?

Copy link
Contributor Author

@haydenbaker haydenbaker Sep 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sorry for not clarifying. This code is problematic, because in cases where the request IS an SdkHttpFullRequest (such as in the integ tests) and the payload is transformed in signing (chunk-encoding), the underlying payload never gets re-set to the transformed payload from signing.

@sonarcloud
Copy link

sonarcloud bot commented Oct 1, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug C 9 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot E 2 Security Hotspots
Code Smell A 482 Code Smells

85.0% 85.0% Coverage
4.4% 4.4% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@haydenbaker haydenbaker merged commit ff8dbad into feature/master/sra-identity-auth Oct 2, 2023
6 of 7 checks passed
@haydenbaker haydenbaker deleted the haydenbaker/sra-ia-checksums-and-encoding-fixes branch October 2, 2023 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants