Skip to content

Commit 73d8b13

Browse files
committed
fixes
1 parent b628855 commit 73d8b13

2 files changed

Lines changed: 24 additions & 9 deletions

File tree

cmd/push-validator/cmd_chain.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,15 @@ Examples:
102102
if flagOutput != "json" {
103103
fmt.Println(" → Verifying checksum")
104104
}
105-
if err := installer.VerifyChecksum(archiveData, release, asset.Name); err != nil {
105+
verified, err := installer.VerifyChecksum(archiveData, release, asset.Name)
106+
if err != nil {
106107
return fmt.Errorf("checksum verification failed: %w", err)
107108
}
108-
fmt.Printf(" %s Checksum verified\n", p.Colors.Success("✓"))
109+
if verified {
110+
fmt.Printf(" %s Checksum verified\n", p.Colors.Success("✓"))
111+
} else {
112+
fmt.Printf(" %s Checksum file not available, skipping verification\n", p.Colors.Warning("⚠"))
113+
}
109114
}
110115

111116
// Extract and install

internal/chain/chain.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,20 +204,30 @@ func (pr *progressReader) Read(p []byte) (int, error) {
204204
return n, err
205205
}
206206

207-
// VerifyChecksum validates the downloaded archive
208-
func (inst *Installer) VerifyChecksum(data []byte, release *Release, assetName string) error {
207+
// VerifyChecksum validates the downloaded archive.
208+
// Returns (verified bool, err error):
209+
// - (true, nil): checksum verified successfully
210+
// - (false, nil): checksum file not found, verification skipped
211+
// - (false, err): checksum mismatch or download error
212+
func (inst *Installer) VerifyChecksum(data []byte, release *Release, assetName string) (bool, error) {
209213
checksumAsset, err := GetChecksumAsset(release, assetName)
210214
if err != nil {
211-
return err
215+
// Checksum file not found in release - skip verification gracefully
216+
return false, nil
212217
}
213218

214219
// Download checksum file
215220
resp, err := http.Get(checksumAsset.BrowserDownloadURL)
216221
if err != nil {
217-
return fmt.Errorf("failed to download checksum: %w", err)
222+
return false, fmt.Errorf("failed to download checksum: %w", err)
218223
}
219224
defer func() { _ = resp.Body.Close() }()
220225

226+
if resp.StatusCode == http.StatusNotFound {
227+
// Checksum file URL returned 404 - skip verification gracefully
228+
return false, nil
229+
}
230+
221231
// Parse checksum file (format: "sha256 filename" or just "sha256")
222232
var expectedHash string
223233
scanner := bufio.NewScanner(resp.Body)
@@ -234,18 +244,18 @@ func (inst *Installer) VerifyChecksum(data []byte, release *Release, assetName s
234244
}
235245

236246
if expectedHash == "" {
237-
return fmt.Errorf("could not parse checksum file")
247+
return false, fmt.Errorf("could not parse checksum file")
238248
}
239249

240250
// Calculate actual hash
241251
hash := sha256.Sum256(data)
242252
actualHash := hex.EncodeToString(hash[:])
243253

244254
if actualHash != expectedHash {
245-
return fmt.Errorf("checksum mismatch: expected %s, got %s", expectedHash, actualHash)
255+
return false, fmt.Errorf("checksum mismatch: expected %s, got %s", expectedHash, actualHash)
246256
}
247257

248-
return nil
258+
return true, nil
249259
}
250260

251261
// ExtractAndInstall extracts the binary and installs to cosmovisor directory

0 commit comments

Comments
 (0)