From 9a2a4f16bd204311b44da8ac9d9cb6d293fd0053 Mon Sep 17 00:00:00 2001 From: Azeem Shaikh Date: Mon, 23 May 2022 19:05:02 -0700 Subject: [PATCH] Replace `checker.Release` with `clients.Release` (#1946) Co-authored-by: Azeem Shaikh --- checker/raw_result.go | 16 +--------------- checks/evaluation/signed_releases.go | 4 ++-- checks/raw/signed_releases.go | 22 +++------------------- pkg/json_raw_results.go | 2 +- 4 files changed, 7 insertions(+), 37 deletions(-) diff --git a/checker/raw_result.go b/checker/raw_result.go index efc451b5..6122ffb8 100644 --- a/checker/raw_result.go +++ b/checker/raw_result.go @@ -93,7 +93,7 @@ type BinaryArtifactData struct { // SignedReleasesData contains the raw results // for the Signed-Releases check. type SignedReleasesData struct { - Releases []Release + Releases []clients.Release } // DependencyUpdateToolData contains the raw results @@ -271,20 +271,6 @@ type Vulnerability struct { // TODO(vuln): Add additional fields, if needed. } -// Release represents a project release. -type Release struct { - Tag string - URL string - Assets []ReleaseAsset - // TODO: add needed fields, e.g. Path. -} - -// ReleaseAsset represents a release asset. -type ReleaseAsset struct { - Name string - URL string -} - // CIIBestPracticesData contains data foor CIIBestPractices check. type CIIBestPracticesData struct { Badge clients.BadgeLevel diff --git a/checks/evaluation/signed_releases.go b/checks/evaluation/signed_releases.go index e1f6847b..4c43dfdd 100644 --- a/checks/evaluation/signed_releases.go +++ b/checks/evaluation/signed_releases.go @@ -42,7 +42,7 @@ func SignedReleases(name string, dl checker.DetailLogger, r *checker.SignedRelea } dl.Debug(&checker.LogMessage{ - Text: fmt.Sprintf("GitHub release found: %s", release.Tag), + Text: fmt.Sprintf("GitHub release found: %s", release.TagName), }) totalReleases++ @@ -70,7 +70,7 @@ func SignedReleases(name string, dl checker.DetailLogger, r *checker.SignedRelea dl.Warn(&checker.LogMessage{ Path: release.URL, Type: checker.FileTypeURL, - Text: fmt.Sprintf("release artifact %s not signed", release.Tag), + Text: fmt.Sprintf("release artifact %s not signed", release.TagName), }) } if totalReleases >= releaseLookBack { diff --git a/checks/raw/signed_releases.go b/checks/raw/signed_releases.go index 62e669b7..39b3343b 100644 --- a/checks/raw/signed_releases.go +++ b/checks/raw/signed_releases.go @@ -27,23 +27,7 @@ func SignedReleases(c *checker.CheckRequest) (checker.SignedReleasesData, error) return checker.SignedReleasesData{}, fmt.Errorf("%w", err) } - var results checker.SignedReleasesData - for i, r := range releases { - results.Releases = append(results.Releases, - checker.Release{ - Tag: r.TagName, - URL: r.URL, - }) - - for _, asset := range r.Assets { - a := checker.ReleaseAsset{ - URL: asset.URL, - Name: asset.Name, - } - results.Releases[i].Assets = append(results.Releases[i].Assets, a) - } - } - - // Return raw results. - return results, nil + return checker.SignedReleasesData{ + Releases: releases, + }, nil } diff --git a/pkg/json_raw_results.go b/pkg/json_raw_results.go index ca9f100b..56d2e7ef 100644 --- a/pkg/json_raw_results.go +++ b/pkg/json_raw_results.go @@ -278,7 +278,7 @@ func (r *jsonScorecardRawResult) addSignedReleasesRawResults(sr *checker.SignedR for i, release := range sr.Releases { r.Results.Releases = append(r.Results.Releases, jsonRelease{ - Tag: release.Tag, + Tag: release.TagName, URL: release.URL, }) for _, asset := range release.Assets {