Skip to content

Commit

Permalink
Add basic checksum validation to huak_python_manager
Browse files Browse the repository at this point in the history
  • Loading branch information
cnpryer committed Oct 20, 2023
1 parent d9e58e8 commit d323caa
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions crates/huak_python_manager/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ fn download_release(release: &Release, to: &PathBuf) -> Result<(), Error> {

/// Validation for release installation. The following is verified prior to installation:
/// - checksum
fn validate_release(_release: &Release) -> Result<(), Error> {
todo!()
fn validate_release(release: &Release) -> Result<(), Error> {
let url = format!("{}.sha256", release.url);
let response = reqwest::blocking::get(&url)?;

if !response.status().is_success() {
bail!("failed to fetch checksum from {url}");
}

if response.text()?.strip_suffix('\n') != Some(release.checksum) {
bail!("failed to validate checksum");
}

Ok(())
}

0 comments on commit d323caa

Please sign in to comment.