fix: refuse installation when SHA256 checksum is unavailable
While reviewing the software update code, I found that _verify_installer_integrity returns True when no SHA256 hash is available from GitHub, allowing installation to proceed without any integrity check.
This can happen when the GitHub API is unreachable or when the release has no checksum file. In this case, a corrupted download would be silently installed on the user's machine.
The fix changes the behaviour to refuse installation when no hash is available, delete the unverified file, and log an error instead of a warning so the user clearly understands why the update was stopped.
Checklist
- [x] Verified by a human programmer
- [x] Code follows our coding standards
- [x] No breaking changes or properly documented
Testing
- [x] Unit tests pass
Added four tests to tests/unit_backend_internet.py:
- test_verify_installer_integrity_no_hash_returns_false
- test_verify_installer_integrity_empty_hash_returns_false
- test_verify_installer_integrity_valid_hash_passes
- test_verify_installer_integrity_wrong_hash_fails
All tests pass locally (Python 3.12.10, pytest-9.0.3)
Thank you for the feedback! You are right that refusing completely would frustrate users since GitHub often returns no SHA.
I have updated the fix to log a clear warning when no hash is available but still proceed with installation. This way users are informed about the unverified state without being blocked.
When a hash IS available and mismatches, installation is still aborted as before.
Could you please let me know if any further changes are needed? I am happy to update the PR based on your feedback.