-
Notifications
You must be signed in to change notification settings - Fork 369
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
feat!: Use HashStreamValidator
for Data Validation
#1951
Conversation
- Removes `fast-crc32c` support
HashStreamValidator
for Data Validation HashStreamValidator
for Data Validation
@@ -874,6 +876,9 @@ class File extends ServiceObject<File> { | |||
pathPrefix: '/acl', | |||
}); | |||
|
|||
this.crc32cGenerator = | |||
options.crc32cGenerator || this.bucket.crc32cGenerator; |
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 there a reason to look to the bucket if one is not passed as an option? Should there be a default within the File class?
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.
It appears all File
s must have a bucket (looking at the construction) and all buckets have a generator (whether custom or the default) - this way customers can set things at a storage, bucket, or per-object level
// http://stackoverflow.com/questions/25096737/ | ||
// base64-encoding-of-crc32c-long-value | ||
failed = !validateStream.test('crc32c', metadata.crc32c.substr(4)); | ||
failed = !validateStream.test('crc32c', metadata.crc32c); |
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.
Any reason you know of that this was previously removing the first 4 bytes? I think you mentioned it was only checking those bytes?
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.
Yea… unfortunately we weren’t checking the complete hash before - just the last byte
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.
Any idea why? Also any idea on the performance impact of now checking the entire range of bytes?
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.
In short, invalid implementation - see the link from the removed comment:
This would result in inaccurate validation. E.g.:
Before:
Line 2373 in a9c4c18
crc32c: {crc32c: '####wA=='}, |
After:
Line 2194 in 06e92ac
crc32c: {crc32c: 'hqBywA=='}, |
The perf for validation is the same - the update
method is the sensitive portion for performance
} | ||
} | ||
|
||
_flush(callback: () => void) { |
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.
Might be good to also just mark these functions with private
.
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.
Wanted to, but TS doesn’t like it as the parent class has it public
* feat!: Use `HashStreamValidator` for stream validation - Removes `fast-crc32c` support * fix: remove logs * test: `crc32cGenerator` option * test: improve `compression` test reliability * chore: add temp debug logs * chore: more debug logs * fix: use static gzip content to remove test variance * chore: remove debug logs * chore: lint
Fixes #1910 🦕