Skip to content

Commit

Permalink
refactor: remove unused return type
Browse files Browse the repository at this point in the history
  • Loading branch information
natesales committed Feb 18, 2025
1 parent 79a2085 commit 86376c1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (s *SecureClient) GroundTruth() *GroundTruth {

// Verify fetches the latest verification information from GitHub and Sigstore and stores the ground truth results in the client
func (s *SecureClient) Verify() (*GroundTruth, error) {
_, digest, err := github.FetchLatestRelease(s.repo)
digest, err := github.FetchLatestDigest(s.repo)
if err != nil {
return nil, fmt.Errorf("failed to fetch latest release: %v", err)
}
Expand Down
18 changes: 9 additions & 9 deletions github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,43 @@ import (
"github.com/tinfoilsh/verifier/util"
)

// FetchLatestRelease gets the latest release and attestation digest of a repo
func FetchLatestRelease(repo string) (string, string, error) {
// FetchLatestDigest gets the latest release and attestation digest of a repo
func FetchLatestDigest(repo string) (string, error) {
url := "https://api.github.com/repos/" + repo + "/releases/latest"
releaseResponse, err := util.Get(url)
if err != nil {
return "", "", err
return "", err
}

var responseJSON struct {
TagName string `json:"tag_name"`
Body string `json:"body"`
}
if err := json.Unmarshal(releaseResponse, &responseJSON); err != nil {
return "", "", err
return "", err
}

// Backwards compatibility for old EIF releases
eifRegex := regexp.MustCompile(`EIF hash: ([a-fA-F0-9]{64})`)
matches := eifRegex.FindStringSubmatch(responseJSON.Body)
if len(matches) > 1 {
return responseJSON.TagName, matches[1], nil
return matches[1], nil
}

url = fmt.Sprintf(`https://github.com/%s/releases/download/%s/tinfoil.hash`, repo, responseJSON.TagName)
digestResp, err := http.Get(url)
if err != nil {
return "", "", err
return "", err
}
if digestResp.StatusCode != 200 {
return "", "", fmt.Errorf("failed to fetch attestation digest: %s", digestResp.Status)
return "", fmt.Errorf("failed to fetch attestation digest: %s", digestResp.Status)
}
digest, err := io.ReadAll(digestResp.Body)
if err != nil {
return "", "", err
return "", err
}

return responseJSON.TagName, strings.TrimSpace(string(digest)), nil
return strings.TrimSpace(string(digest)), nil
}

// FetchAttestationBundle fetches the sigstore bundle from a repo for a given repo and EIF hash
Expand Down

0 comments on commit 86376c1

Please sign in to comment.