Skip to content

Commit

Permalink
Merge pull request #33 from getsolus/checksum-check
Browse files Browse the repository at this point in the history
builder/source: check the sha256sum matches when downloading
  • Loading branch information
silkeh authored Jul 28, 2023
2 parents f53f0c3 + 5c43be1 commit b63668d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions builder/source/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ import (
"crypto/sha1"
"crypto/sha256"
"encoding/hex"
"github.com/cavaliergopher/grab/v3"
"github.com/cheggaaa/pb/v3"
"io/ioutil"
"net/url"
"os"
"path/filepath"
"time"

"github.com/cavaliergopher/grab/v3"
"github.com/cheggaaa/pb/v3"

log "github.com/DataDrake/waterlog"
)

Expand Down Expand Up @@ -123,6 +124,15 @@ func (s *SimpleSource) download(destination string) error {
return err
}

// Ensure the checksum matches
if !s.legacy {
sum, err := hex.DecodeString(s.validator)
if err != nil {
return err
}
req.SetChecksum(sha256.New(), sum, false)
}

resp := grab.NewClient().Do(req)

// Setup our progress bar
Expand Down

0 comments on commit b63668d

Please sign in to comment.