Skip to content

Validate CRC32c if x-goog-hash header is present #2281

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

Closed
jonasfj opened this issue Dec 16, 2019 · 3 comments · Fixed by #3546
Closed

Validate CRC32c if x-goog-hash header is present #2281

jonasfj opened this issue Dec 16, 2019 · 3 comments · Fixed by #3546

Comments

@jonasfj
Copy link
Member

jonasfj commented Dec 16, 2019

The x-goog-hash header is present in responses from GCS, see: https://cloud.google.com/storage/docs/hashes-etags

Please note that if the object was transcoded by GCS then the has will be invalid.
Also the validate must happen before gzip decompression, if the response is gzipped, and the request must be made with Accept-Encoding: gzip.

If we get this wrong, we won't be able to gzip data in GCS in the future, let's aim to avoid that.

@jonasfj
Copy link
Member Author

jonasfj commented Dec 16, 2019

Probably we can use package:crclib.

@jonasfj
Copy link
Member Author

jonasfj commented Jan 20, 2020

This is actually in:
https://pub.dev/documentation/crclib/latest/crclib/Crc32Iscsi-class.html

After viewing http.dart with @sigurdm it seems we'll have to do a minor refactor of all http handling before we can retry errors during the response phase of the requests.

@jonasfj
Copy link
Member Author

jonasfj commented Feb 11, 2022

There is also a crc32 implementation here:
https://github.com/dart-lang/pana/blob/master/lib/src/license_detection/crc32.dart

Thought this isn't the variant used by GCS, but it could probably be tweaked.

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 a pull request may close this issue.

1 participant