Skip to content

Commit

Permalink
Make digest verification optional
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Sep 28, 2023
1 parent 59e3943 commit 408e100
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ func MakeUpdate() *cobra.Command {
SilenceErrors: false,
}

command.Flags().Bool("verify", true, "Verify the checksum of the downloaded binary")

command.RunE = func(cmd *cobra.Command, args []string) error {

verifyDigest, _ := cmd.Flags().GetBool("verify")

name := "arkade"
toolList := get.MakeTools()
var tool *get.Tool
Expand Down Expand Up @@ -91,17 +95,19 @@ func MakeUpdate() *cobra.Command {
return err
}

digest, err := downloadDigest(downloadUrl + ".sha256")
if err != nil {
return err
}
if verifyDigest {
digest, err := downloadDigest(downloadUrl + ".sha256")
if err != nil {
return err
}

match, err := compareSHA(digest, newBinary)
if err != nil {
return fmt.Errorf("SHA256 checksum failed for %s, error: %w", newBinary, err)
}
if !match {
return fmt.Errorf("SHA256 checksum failed for %s", newBinary)
match, err := compareSHA(digest, newBinary)
if err != nil {
return fmt.Errorf("SHA256 checksum failed for %s, error: %w", newBinary, err)
}
if !match {
return fmt.Errorf("SHA256 checksum failed for %s", newBinary)
}
}

if err := replaceExec(executable, newBinary); err != nil {
Expand Down

0 comments on commit 408e100

Please sign in to comment.