Skip to content

Fix validating hash on uncompressed storage #819

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

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

Conversation

AlessandroPatti
Copy link
Contributor

When storage mode is uncompressed, cas blobs are not validated against their sha and accepted regardless. The validation is instead performed when using zstd storage mode. This refactors casbob.WriteAndClose to write both compressed and uncompress blobs and validate their content.

Copy link
Collaborator

@mostynb mostynb left a comment

Choose a reason for hiding this comment

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

Yikes- thanks for finding and reporting this!

@@ -352,7 +352,7 @@ func (c *diskCache) writeAndCloseFile(ctx context.Context, r io.Reader, kind cac
var err error
var sizeOnDisk int64

if kind == cache.CAS && c.storageMode != casblob.Identity {
if kind == cache.CAS {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why isn't this change alone sufficient (and why is the casblob.go refactoring required) ? It's hard to tell in the github UI.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The WriteAndCose method computed and wrote the CAS blob header (here) even when Identity was passed, but uncompressed expects the blobs to be plain

Co-authored-by: Mostyn Bramley-Moore <[email protected]>
@AlessandroPatti AlessandroPatti requested a review from mostynb May 6, 2025 07:08
mostynb added a commit to mostynb/bazel-remote that referenced this pull request Jun 7, 2025
This seems to have been unchecked since v2.0.0. Alternative fix to buchgr#819.
mostynb added a commit to mostynb/bazel-remote that referenced this pull request Jun 7, 2025
This seems to have been unchecked since v2.0.0. Alternative fix to buchgr#819.
mostynb added a commit to mostynb/bazel-remote that referenced this pull request Jun 7, 2025
This seems to have been unchecked since v2.0.0. Alternative fix to buchgr#819.
@mostynb
Copy link
Collaborator

mostynb commented Jun 7, 2025

Sorry it took so long to get to this. I refactored your test a bit and then implemented a simpler fix which doesn't touch casblob: #826

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