Skip to content

Conversation

@tsj-30
Copy link

@tsj-30 tsj-30 commented Oct 20, 2025

What this PR does / why we need it:
This PR adds SHA-256 checksum verification and robust URL validation for image downloads in the convert-upload-images-powervs script.
It ensures that corrupted or partially downloaded .qcow2 images (caused by unescaped characters like & in URLs) are detected and the script terminates safely instead of continuing with invalid data.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #92

Special notes for your reviewer:

**Output/Demonstration

sjtharun@Ss-MacBook-Pro convert-upload-images-powervs % ./convert-upload-images-powervs
--rhel-url "https://cloud.centos.org/centos/10-stream/ppc64le/images/CentOS-Stream-GenericCloud-10-20241118.0.ppc64le.qcow2"
--rhel-sha256 "27bdeb53a4e265409adcf37caa87103a5c544640fc99da19c06f6ff1dd389b30" \

+zsh:77> ./convert-upload-images-powervs --rhel-url https://cloud.centos.org/centos/10-stream/ppc64le/images/CentOS-Stream-GenericCloud-10-20241118.0.ppc64le.qcow2 --rhel-sha256 27bdeb53a4e265409adcf37caa87103a5c544640fc99da19c06f6ff1dd389b30
LOG: =========================================
LOG: Starting download: CentOS-Stream-GenericCloud-10-20241118.0.ppc64le.qcow2
LOG: Source URL: https://cloud.centos.org/centos/10-stream/ppc64le/images/CentOS-Stream-GenericCloud-10-20241118.0.ppc64le.qcow2
LOG: =========================================
LOG: Download attempt 1 of 3
LOG: Downloading CentOS-Stream-GenericCloud-10-20241118.0.ppc64le.qcow2...
LOG: Download completed, verifying integrity...
LOG: Verifying file size for CentOS-Stream-GenericCloud-10-20241118.0.ppc64le.qcow2...
LOG: Expected size: 739220480 bytes
LOG: Actual size: 739220480 bytes
SUCCESS: ✓ File size verification PASSED
LOG: Verifying SHA256 checksum for CentOS-Stream-GenericCloud-10-20241118.0.ppc64le.qcow2...
LOG: Expected: 27bdeb53a4e265409adcf37caa87103a5c544640fc99da19c06f6ff1dd389b30
LOG: Actual: 27bdeb53a4e265409adcf37caa87103a5c544640fc99da19c06f6ff1dd389b30
SUCCESS: ✓ Checksum verification PASSED for CentOS-Stream-GenericCloud-10-20241118.0.ppc64le.qcow2
SUCCESS: =========================================
SUCCESS: ✓ Download and verification completed successfully!
SUCCESS: File: CentOS-Stream-GenericCloud-10-20241118.0.ppc64le.qcow2
SUCCESS: Location: ./CentOS-Stream-GenericCloud-10-20241118.0.ppc64le.qcow2
SUCCESS: =========================================


@ppc64le-cloud-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: tsj-30
Once this PR has been reviewed and has the lgtm label, please assign mkumatag for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ppc64le-cloud-bot
Copy link
Contributor

Welcome @tsj-30! It looks like this is your first PR to ppc64le-cloud/pvsadm 🎉

@ppc64le-cloud-bot ppc64le-cloud-bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 20, 2025
@ppc64le-cloud-bot
Copy link
Contributor

Hi @tsj-30. Thanks for your PR.

I'm waiting for a ppc64le-cloud member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ppc64le-cloud-bot ppc64le-cloud-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 20, 2025
@mkumatag
Copy link
Contributor

@sudeeshjohn anyone using this script? may be need your reviewing this script

@sudeeshjohn
Copy link
Contributor

I would suggest to add the checksum validation in getImage function as well

func getImage(downloadDir string, srcUrl string, timeout time.Duration) (string, error) {

@tsj-30 tsj-30 requested a review from kishen-v November 10, 2025 05:32
@kishen-v kishen-v changed the title Add SHA256 checksum verification and robust URL validation for image … Add SHA256 checksum verification and robust URL validation for image Nov 10, 2025
@kishen-v
Copy link
Contributor

/ok-to-test

@ppc64le-cloud-bot ppc64le-cloud-bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add test: e2e run - qcow2ova, upload, import

5 participants