diff --git a/checker/check_result.go b/checker/check_result.go index 495f60f68a35..5ce58b4b1c04 100644 --- a/checker/check_result.go +++ b/checker/check_result.go @@ -79,7 +79,6 @@ const ( // nolint:govet type CheckResult struct { // TODO(#1393): Remove old structure after deprecation. - Error error `json:"-"` Name string Details []string Confidence int @@ -161,7 +160,6 @@ func CreateResultWithScore(name, reason string, score int) CheckResult { return CheckResult{ Name: name, // Old structure. - Error: nil, Confidence: MaxResultScore, Pass: pass, // New structure. @@ -186,7 +184,6 @@ func CreateProportionalScoreResult(name, reason string, b, t int) CheckResult { return CheckResult{ Name: name, // Old structure. - Error: nil, Confidence: MaxResultConfidence, Pass: pass, // New structure. @@ -232,7 +229,6 @@ func CreateRuntimeErrorResult(name string, e error) CheckResult { return CheckResult{ Name: name, // Old structure. - Error: e, Confidence: 0, Pass: false, // New structure. diff --git a/checker/check_runner.go b/checker/check_runner.go index df80e7150800..af07f4e1a456 100644 --- a/checker/check_runner.go +++ b/checker/check_runner.go @@ -76,7 +76,7 @@ func logStats(ctx context.Context, startTime time.Time, result *CheckResult) err runTimeInSecs := time.Now().Unix() - startTime.Unix() opencensusstats.Record(ctx, stats.CheckRuntimeInSec.M(runTimeInSecs)) - if result.Error != nil { + if result.Error2 != nil { ctx, err := tag.New(ctx, tag.Upsert(stats.ErrorName, sce.GetName(result.Error2))) if err != nil { return sce.WithMessage(sce.ErrScorecardInternal, fmt.Sprintf("tag.New: %v", err)) diff --git a/checks/evaluation/branch_protection_test.go b/checks/evaluation/branch_protection_test.go index 7aa0aee824f0..9c4924eeed3a 100644 --- a/checks/evaluation/branch_protection_test.go +++ b/checks/evaluation/branch_protection_test.go @@ -285,7 +285,6 @@ func TestIsBranchProtected(t *testing.T) { score, err := testScore(tt.branch, &dl) actual := &checker.CheckResult{ Score: score, - Error: err, } if !scut.ValidateTestReturn(t, tt.name, &tt.expected, actual, &dl) { t.Fail() diff --git a/checks/vulnerabilities_test.go b/checks/vulnerabilities_test.go index f0cee6c942b6..5d13f387bb94 100644 --- a/checks/vulnerabilities_test.go +++ b/checks/vulnerabilities_test.go @@ -67,9 +67,9 @@ func TestVulnerabilities(t *testing.T) { VulnerabilitiesClient: mockVulnClient, } res := Vulnerabilities(&req) - if !tt.isError && res.Error != nil { + if !tt.isError && res.Error2 != nil { t.Fail() - } else if tt.isError && res.Error == nil { + } else if tt.isError && res.Error2 == nil { t.Fail() } ctrl.Finish() diff --git a/e2e/binary_artifacts_test.go b/e2e/binary_artifacts_test.go index 57fb842b8e26..807d739c1f1e 100644 --- a/e2e/binary_artifacts_test.go +++ b/e2e/binary_artifacts_test.go @@ -86,7 +86,6 @@ var _ = Describe("E2E TEST:"+checks.CheckBinaryArtifacts, func() { result := checks.BinaryArtifacts(&req) // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeFalse()) // New version. Expect(scut.ValidateTestReturn(nil, "binary artifacts", &expected, &result, &dl)).Should(BeTrue()) @@ -117,7 +116,6 @@ var _ = Describe("E2E TEST:"+checks.CheckBinaryArtifacts, func() { result := checks.BinaryArtifacts(&req) // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeFalse()) // New version. Expect(scut.ValidateTestReturn(nil, "binary artifacts", &expected, &result, &dl)).Should(BeTrue()) diff --git a/e2e/branch_protection_test.go b/e2e/branch_protection_test.go index 39fbb11550a1..781d67bd348f 100644 --- a/e2e/branch_protection_test.go +++ b/e2e/branch_protection_test.go @@ -54,7 +54,6 @@ var _ = Describe("E2E TEST PAT:"+checks.CheckBranchProtection, func() { result := checks.BranchProtection(&req) // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeFalse()) // New version. @@ -86,7 +85,6 @@ var _ = Describe("E2E TEST PAT:"+checks.CheckBranchProtection, func() { result := checks.BranchProtection(&req) // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeFalse()) // New version. @@ -118,7 +116,6 @@ var _ = Describe("E2E TEST PAT:"+checks.CheckBranchProtection, func() { result := checks.BranchProtection(&req) // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeFalse()) // New version. @@ -146,9 +143,9 @@ var _ = Describe("E2E TEST GITHUB_TOKEN:"+checks.CheckBranchProtection, func() { } result := checks.BranchProtection(&req) + Expect(result.Error2).ShouldNot(BeNil()) // There should be an error with the GITHUB_TOKEN, until it's supported // byt GitHub. - Expect(result.Error).ShouldNot(BeNil()) Expect(repoClient.Close()).Should(BeNil()) }) }) diff --git a/e2e/cii_best_practices_test.go b/e2e/cii_best_practices_test.go index e83f2b107239..7889b51c1b74 100644 --- a/e2e/cii_best_practices_test.go +++ b/e2e/cii_best_practices_test.go @@ -52,7 +52,6 @@ var _ = Describe("E2E TEST:"+checks.CheckCIIBestPractices, func() { result := checks.CIIBestPractices(&req) // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeFalse()) // New version. Expect(scut.ValidateTestReturn(nil, "passing badge", &expected, &result, &dl)).Should(BeTrue()) diff --git a/e2e/contributors_test.go b/e2e/contributors_test.go index 5b029c75328b..1d93e47d41bd 100644 --- a/e2e/contributors_test.go +++ b/e2e/contributors_test.go @@ -52,7 +52,6 @@ var _ = Describe("E2E TEST:"+checks.CheckContributors, func() { result := checks.Contributors(&req) // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeTrue()) // New version. Expect(scut.ValidateTestReturn(nil, "several contributors", &expected, &result, &dl)).Should(BeTrue()) diff --git a/e2e/dangerous_workflow_test.go b/e2e/dangerous_workflow_test.go index e56bd664e637..840244632791 100644 --- a/e2e/dangerous_workflow_test.go +++ b/e2e/dangerous_workflow_test.go @@ -56,7 +56,6 @@ var _ = Describe("E2E TEST:"+checks.CheckTokenPermissions, func() { // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeFalse()) // New version. Expect(scut.ValidateTestReturn(nil, "dangerous workflow", &expected, &result, &dl)).Should(BeTrue()) @@ -85,7 +84,6 @@ var _ = Describe("E2E TEST:"+checks.CheckTokenPermissions, func() { // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeFalse()) // New version. Expect(scut.ValidateTestReturn(nil, "dangerous workflow", &expected, &result, &dl)).Should(BeTrue()) @@ -126,7 +124,6 @@ var _ = Describe("E2E TEST:"+checks.CheckTokenPermissions, func() { // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeFalse()) // New version. Expect(scut.ValidateTestReturn(nil, "dangerous workflow", &expected, &result, &dl)).Should(BeTrue()) diff --git a/e2e/dependency_update_tool_test.go b/e2e/dependency_update_tool_test.go index c583f5ee94df..6e2befcd2c57 100644 --- a/e2e/dependency_update_tool_test.go +++ b/e2e/dependency_update_tool_test.go @@ -56,7 +56,6 @@ var _ = Describe("E2E TEST:"+checks.CheckDependencyUpdateTool, func() { result := checks.DependencyUpdateTool(&req) // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeTrue()) // New version. Expect(scut.ValidateTestReturn(nil, "dependabot", &expected, &result, &dl)).Should(BeTrue()) @@ -86,7 +85,6 @@ var _ = Describe("E2E TEST:"+checks.CheckDependencyUpdateTool, func() { result := checks.DependencyUpdateTool(&req) // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeTrue()) // New version. Expect(scut.ValidateTestReturn(nil, "renovabot", &expected, &result, &dl)).Should(BeTrue()) diff --git a/e2e/license_test.go b/e2e/license_test.go index 8efa1f530033..2a0f2e701c51 100644 --- a/e2e/license_test.go +++ b/e2e/license_test.go @@ -54,7 +54,6 @@ var _ = Describe("E2E TEST:"+checks.CheckLicense, func() { } result := checks.License(&req) - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeTrue()) Expect(scut.ValidateTestReturn(nil, "license found", &expected, &result, @@ -82,7 +81,6 @@ var _ = Describe("E2E TEST:"+checks.CheckLicense, func() { } result := checks.License(&req) - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeTrue()) Expect(scut.ValidateTestReturn(nil, "license found", &expected, &result, @@ -122,7 +120,6 @@ var _ = Describe("E2E TEST:"+checks.CheckLicense, func() { } result := checks.License(&req) - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeTrue()) Expect(scut.ValidateTestReturn(nil, "license found", &expected, &result, diff --git a/e2e/maintained_test.go b/e2e/maintained_test.go index 680e2ae3737a..0292fb351d7c 100644 --- a/e2e/maintained_test.go +++ b/e2e/maintained_test.go @@ -52,7 +52,6 @@ var _ = Describe("E2E TEST:"+checks.CheckMaintained, func() { result := checks.Maintained(&req) // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeTrue()) // New version. Expect(scut.ValidateTestReturn(nil, "active repo", &expected, &result, &dl)).Should(BeTrue()) diff --git a/e2e/permissions_test.go b/e2e/permissions_test.go index 4d6a9f937d94..0c59f3c3d7c2 100644 --- a/e2e/permissions_test.go +++ b/e2e/permissions_test.go @@ -56,7 +56,6 @@ var _ = Describe("E2E TEST:"+checks.CheckTokenPermissions, func() { // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeFalse()) // New version. Expect(scut.ValidateTestReturn(nil, "token permissions", &expected, &result, &dl)).Should(BeTrue()) @@ -86,7 +85,6 @@ var _ = Describe("E2E TEST:"+checks.CheckTokenPermissions, func() { // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeFalse()) // New version. Expect(scut.ValidateTestReturn(nil, "token permissions", &expected, &result, &dl)).Should(BeTrue()) @@ -128,7 +126,6 @@ var _ = Describe("E2E TEST:"+checks.CheckTokenPermissions, func() { // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeFalse()) // New version. Expect(scut.ValidateTestReturn(nil, "token permissions", &expected, &result, &dl)).Should(BeTrue()) diff --git a/e2e/sast_test.go b/e2e/sast_test.go index a5cef62a1576..ed21d6d0ba6a 100644 --- a/e2e/sast_test.go +++ b/e2e/sast_test.go @@ -52,7 +52,6 @@ var _ = Describe("E2E TEST:"+checks.CheckSAST, func() { result := checks.SAST(&req) // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeFalse()) // New version. Expect(scut.ValidateTestReturn(nil, "sast used", &expected, &result, &dl)).Should(BeTrue()) diff --git a/e2e/security_policy_test.go b/e2e/security_policy_test.go index 5c22803fffd1..8c856e21220f 100644 --- a/e2e/security_policy_test.go +++ b/e2e/security_policy_test.go @@ -56,7 +56,6 @@ var _ = Describe("E2E TEST:"+checks.CheckSecurityPolicy, func() { result := checks.SecurityPolicy(&req) // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeTrue()) // New version. Expect(scut.ValidateTestReturn(nil, "policy found", &expected, &result, &dl)).Should(BeTrue()) @@ -86,7 +85,6 @@ var _ = Describe("E2E TEST:"+checks.CheckSecurityPolicy, func() { result := checks.SecurityPolicy(&req) // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeTrue()) // New version. Expect(scut.ValidateTestReturn(nil, "policy found", &expected, &result, &dl)).Should(BeTrue()) @@ -116,7 +114,6 @@ var _ = Describe("E2E TEST:"+checks.CheckSecurityPolicy, func() { result := checks.SecurityPolicy(&req) // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeTrue()) // New version. Expect(scut.ValidateTestReturn(nil, "policy found", &expected, &result, &dl)).Should(BeTrue()) @@ -146,7 +143,6 @@ var _ = Describe("E2E TEST:"+checks.CheckSecurityPolicy, func() { result := checks.SecurityPolicy(&req) // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeTrue()) // New version. Expect(scut.ValidateTestReturn(nil, "policy found", &expected, &result, &dl)).Should(BeTrue()) @@ -187,7 +183,6 @@ var _ = Describe("E2E TEST:"+checks.CheckSecurityPolicy, func() { result := checks.SecurityPolicy(&req) // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeTrue()) // New version. Expect(scut.ValidateTestReturn(nil, "policy found", &expected, &result, &dl)).Should(BeTrue()) diff --git a/e2e/signedreleases_test.go b/e2e/signedreleases_test.go index 1c1f23322066..098a1997f5e5 100644 --- a/e2e/signedreleases_test.go +++ b/e2e/signedreleases_test.go @@ -52,7 +52,6 @@ var _ = Describe("E2E TEST:"+checks.CheckSignedReleases, func() { result := checks.SignedReleases(&req) // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeTrue()) // New version. Expect(scut.ValidateTestReturn(nil, "verified release", &expected, &result, &dl)).Should(BeTrue()) diff --git a/e2e/vulnerabilities_test.go b/e2e/vulnerabilities_test.go index 806e27384dfd..729cc6e5ff1b 100644 --- a/e2e/vulnerabilities_test.go +++ b/e2e/vulnerabilities_test.go @@ -55,7 +55,6 @@ var _ = Describe("E2E TEST:"+checks.CheckVulnerabilities, func() { result := checks.Vulnerabilities(&req) // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeTrue()) // New version. Expect(scut.ValidateTestReturn(nil, "no osv vulnerabilities", &expected, &result, &dl)).Should(BeTrue()) @@ -87,7 +86,6 @@ var _ = Describe("E2E TEST:"+checks.CheckVulnerabilities, func() { result := checks.Vulnerabilities(&checkRequest) // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeFalse()) // New version. Expect(scut.ValidateTestReturn(nil, "osv vulnerabilities", &expected, &result, &dl)).Should(BeTrue()) @@ -118,7 +116,6 @@ var _ = Describe("E2E TEST:"+checks.CheckVulnerabilities, func() { result := checks.Vulnerabilities(&checkRequest) // UPGRADEv2: to remove. // Old version. - Expect(result.Error).Should(BeNil()) Expect(result.Pass).Should(BeFalse()) // New version. Expect(scut.ValidateTestReturn(nil, "osv vulnerabilities", &expected, &result, &dl)).Should(BeTrue())