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

api: add checksum validation in Content Library update session file API #3429

Merged
merged 1 commit into from
Apr 30, 2024

Conversation

dilyar85
Copy link
Member

@dilyar85 dilyar85 commented Apr 30, 2024

Description

This PR updates the AddLibraryItemFileFromURI API with an optional LibraryItemFileChecksumInfo that the server can use to verify the uploaded library file content.
It also updates the govc library.import command accordingly with the new checksum arguments (-c for checksum value & -a for checksum algorithm).

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Updated the existing govc bats to verify the new arguments syntax. Passed all tests locally:
  • Manually verified the new API change against a real VC:
# No checksum specified:
$ govc library.import -pull checksum-test https://releases.ubuntu.com/14.04.6/ubuntu-14.04.6-server-amd64.iso

$ govc library.ls checksum-test/
/checksum-test/ubuntu-14.04.6-server-amd64

# Invalid checksum algorithm:
$ govc library.import -a=foo -pull checksum-test https://releases.ubuntu.com/14.04.6/ubuntu-14.04.6-server-amd64.iso
govc: invalid checksum algorithm: foo

# Invalid checksum value:
$ govc library.import -c=invalid -pull checksum-test https://releases.ubuntu.com/14.04.6/ubuntu-14.04.6-server-amd64.iso
govc: The import of library item 2a57efd7-32be-4aad-80f6-4212f123a82c has failed. Reason: Error transferring file ubuntu-14.04.6-server-amd64.iso from https://releases.ubuntu.com/14.04.6/ubuntu-14.04.6-server-amd64.iso. Reason: Checksum mismatch for endpoint https://releases.ubuntu.com/14.04.6/ubuntu-14.04.6-server-amd64.iso in item ubuntu-14.04.6-server-amd64.iso: [actual checksum = b17d7c1e9d0321ad5810ba77b69aef43f0f29a5422b08120e6ee0576c4527c0e; expected checksum = invalid].

# Valid checksum value and algorithm:
$ govc library.import -c=b17d7c1e9d0321ad5810ba77b69aef43f0f29a5422b08120e6ee0576c4527c0e -a=SHA256 -pull checksum-test https://releases.ubuntu.com/14.04.6/ubuntu-14.04.6-server-amd64.iso

$ govc library.ls checksum-test/
/checksum-test/ubuntu-14.04.6-server-amd64

Checklist:

  • My code follows the CONTRIBUTION [guidelines] of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged

@dilyar85 dilyar85 force-pushed the feature/library-item-checksum branch 2 times, most recently from abcfd39 to 2206bc9 Compare April 30, 2024 18:25
@dilyar85 dilyar85 force-pushed the feature/library-item-checksum branch from 2206bc9 to 45aa2e9 Compare April 30, 2024 18:52
Copy link
Member

@dougm dougm left a comment

Choose a reason for hiding this comment

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

lgtm, thanks @dilyar85

@dilyar85 dilyar85 merged commit f0980d5 into vmware:main Apr 30, 2024
11 checks passed
@dilyar85 dilyar85 deleted the feature/library-item-checksum branch April 30, 2024 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants