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

Validate checksums when fetching cached files for app packaging #4081

Merged
merged 1 commit into from
Nov 19, 2024

Conversation

sethboyles
Copy link
Member

@sethboyles sethboyles commented Nov 9, 2024

Although resource matching stores files by their sha1 checksum, when later fetching the resource to include in app packaging, the bits packer does not validate the checksum still matches. The packer will still include the corrupted file, and users (most likely) won't receive an error until the staging process. This state is only recoverable by clearing the resource cache, which relies on operator intervention.

With this change, when a bad checksum is found, the cached resource(s) are deleted, and an error is raised, causing faster feedback. Since the cached resources have been deleted, a second push/package upload should succeed.

  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the main branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

@sethboyles sethboyles force-pushed the validate-resource-checksums branch 4 times, most recently from 880e0c6 to ef5df5c Compare November 11, 2024 22:33
@sethboyles sethboyles requested review from a team November 11, 2024 22:57
* This also deletes any resources with bad/mismatched checksums
@sethboyles sethboyles force-pushed the validate-resource-checksums branch from ef5df5c to a174d5d Compare November 19, 2024 18:04
@@ -132,7 +132,7 @@ def make_request
end

context 'with at least one resource and an application' do
let(:req_body) { { resources: Oj.dump([{ 'fn' => 'lol', 'sha1' => 'abc', 'size' => 2048 }]), application: valid_zip } }
let(:req_body) { { resources: Oj.dump([{ 'fn' => 'lol', 'sha1' => 'da39a3ee5e6b4b0d3255bfef95601890afd80709', 'size' => 2048 }]), application: valid_zip } }
Copy link
Member

@a-b a-b Nov 19, 2024

Choose a reason for hiding this comment

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

question (non-blocking): why do we want a valid sha for these units? Can we mock the underlying library?

Copy link
Member Author

Choose a reason for hiding this comment

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

@sethboyles sethboyles merged commit 1f38b98 into main Nov 19, 2024
8 checks passed
@sethboyles sethboyles deleted the validate-resource-checksums branch November 19, 2024 18:39
ari-wg-gitbot added a commit to cloudfoundry/capi-release that referenced this pull request Nov 19, 2024
Changes in cloud_controller_ng:

- Validate checksums when fetching cached files for app packaging
    PR: cloudfoundry/cloud_controller_ng#4081
    Author: Seth Boyles <seth.boyles@broadcom.com>
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.

5 participants