diff --git a/checks/active.go b/checks/active.go index 9218a5d9..a4b9b9fa 100644 --- a/checks/active.go +++ b/checks/active.go @@ -24,10 +24,10 @@ import ( var lookbackDays int = 90 func init() { - registerCheck("Active", PeriodicCommits) + registerCheck("Active", IsActive) } -func PeriodicCommits(c checker.Checker) checker.CheckResult { +func IsActive(c checker.Checker) checker.CheckResult { commits, _, err := c.Client.Repositories.ListCommits(c.Ctx, c.Owner, c.Repo, &github.CommitsListOptions{}) if err != nil { return checker.RetryResult(err) diff --git a/checks/cii_best_practices.go b/checks/cii_best_practices.go index a5762337..6d5119be 100644 --- a/checks/cii_best_practices.go +++ b/checks/cii_best_practices.go @@ -23,14 +23,14 @@ import ( ) func init() { - registerCheck("CII-Best-Practices", CiiBestPractices) + registerCheck("CII-Best-Practices", CIIBestPractices) } type response struct { BadgeLevel string `json:"badge_level"` } -func CiiBestPractices(c checker.Checker) checker.CheckResult { +func CIIBestPractices(c checker.Checker) checker.CheckResult { repoUrl := fmt.Sprintf("https://github.com/%s/%s", c.Owner, c.Repo) url := fmt.Sprintf("https://bestpractices.coreinfrastructure.org/projects.json?url=%s", repoUrl) resp, err := c.HttpClient.Get(url) diff --git a/checks/sast.go b/checks/sast.go index 149898fe..6edf9427 100644 --- a/checks/sast.go +++ b/checks/sast.go @@ -22,7 +22,14 @@ import ( var sastTools map[string]bool = map[string]bool{"github-code-scanning": true, "sonarcloud": true} func init() { - registerCheck("SAST", checker.MultiCheck(CodeQLInCheckDefinitions, SASTToolInCheckRuns)) + registerCheck("SAST", SAST) +} + +func SAST(c checker.Checker) checker.CheckResult { + return checker.MultiCheck( + CodeQLInCheckDefinitions, + SASTToolInCheckRuns, + )(c) } func SASTToolInCheckRuns(c checker.Checker) checker.CheckResult { diff --git a/e2e/active_test.go b/e2e/active_test.go new file mode 100644 index 00000000..56020e9b --- /dev/null +++ b/e2e/active_test.go @@ -0,0 +1,30 @@ +package e2e + +import ( + "context" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + "github.com/ossf/scorecard/checker" + "github.com/ossf/scorecard/checks" +) + +var _ = Describe("E2E TEST:Active", func() { + Context("E2E TEST:Validating active status", func() { + It("Should return valid active status", func() { + l := log{} + checker := checker.Checker{ + Ctx: context.Background(), + Client: ghClient, + HttpClient: client, + Owner: "apache", + Repo: "airflow", + GraphClient: graphClient, + Logf: l.Logf, + } + result := checks.IsActive(checker) + Expect(result.Error).Should(BeNil()) + Expect(result.Pass).Should(BeTrue()) + }) + }) +}) diff --git a/e2e/ci_tests_test.go b/e2e/ci_tests_test.go new file mode 100644 index 00000000..aabaa901 --- /dev/null +++ b/e2e/ci_tests_test.go @@ -0,0 +1,30 @@ +package e2e + +import ( + "context" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + "github.com/ossf/scorecard/checker" + "github.com/ossf/scorecard/checks" +) + +var _ = Describe("E2E TEST:CITests", func() { + Context("E2E TEST:Validating use of CI tests", func() { + It("Should return use of CI tests", func() { + l := log{} + checker := checker.Checker{ + Ctx: context.Background(), + Client: ghClient, + HttpClient: client, + Owner: "apache", + Repo: "airflow", + GraphClient: graphClient, + Logf: l.Logf, + } + result := checks.CITests(checker) + Expect(result.Error).Should(BeNil()) + Expect(result.Pass).Should(BeTrue()) + }) + }) +}) diff --git a/e2e/cii_best_practices_test.go b/e2e/cii_best_practices_test.go new file mode 100644 index 00000000..21b94cb3 --- /dev/null +++ b/e2e/cii_best_practices_test.go @@ -0,0 +1,30 @@ +package e2e + +import ( + "context" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + "github.com/ossf/scorecard/checker" + "github.com/ossf/scorecard/checks" +) + +var _ = Describe("E2E TEST:CIIBestPractices", func() { + Context("E2E TEST:Validating use of CII Best Practices", func() { + It("Should return use of CII Best Practices", func() { + l := log{} + checker := checker.Checker{ + Ctx: context.Background(), + Client: ghClient, + HttpClient: client, + Owner: "tensorflow", + Repo: "tensorflow", + GraphClient: graphClient, + Logf: l.Logf, + } + result := checks.CIIBestPractices(checker) + Expect(result.Error).Should(BeNil()) + Expect(result.Pass).Should(BeTrue()) + }) + }) +}) diff --git a/e2e/code_review_test.go b/e2e/code_review_test.go new file mode 100644 index 00000000..1cd9f5b9 --- /dev/null +++ b/e2e/code_review_test.go @@ -0,0 +1,30 @@ +package e2e + +import ( + "context" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + "github.com/ossf/scorecard/checker" + "github.com/ossf/scorecard/checks" +) + +var _ = Describe("E2E TEST:CodeReview", func() { + Context("E2E TEST:Validating use of code reviews", func() { + It("Should return use of code reviews", func() { + l := log{} + checker := checker.Checker{ + Ctx: context.Background(), + Client: ghClient, + HttpClient: client, + Owner: "apache", + Repo: "airflow", + GraphClient: graphClient, + Logf: l.Logf, + } + result := checks.DoesCodeReview(checker) + Expect(result.Error).Should(BeNil()) + Expect(result.Pass).Should(BeTrue()) + }) + }) +}) diff --git a/e2e/contributors_test.go b/e2e/contributors_test.go new file mode 100644 index 00000000..2abe4769 --- /dev/null +++ b/e2e/contributors_test.go @@ -0,0 +1,30 @@ +package e2e + +import ( + "context" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + "github.com/ossf/scorecard/checker" + "github.com/ossf/scorecard/checks" +) + +var _ = Describe("E2E TEST:CodeReview", func() { + Context("E2E TEST:Validating project contributors", func() { + It("Should return valid project contributors", func() { + l := log{} + checker := checker.Checker{ + Ctx: context.Background(), + Client: ghClient, + HttpClient: client, + Owner: "apache", + Repo: "airflow", + GraphClient: graphClient, + Logf: l.Logf, + } + result := checks.Contributors(checker) + Expect(result.Error).Should(BeNil()) + Expect(result.Pass).Should(BeTrue()) + }) + }) +}) diff --git a/e2e/frozen_deps_test.go b/e2e/frozen_deps_test.go new file mode 100644 index 00000000..f71c5409 --- /dev/null +++ b/e2e/frozen_deps_test.go @@ -0,0 +1,30 @@ +package e2e + +import ( + "context" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + "github.com/ossf/scorecard/checker" + "github.com/ossf/scorecard/checks" +) + +var _ = Describe("E2E TEST:FrozenDeps", func() { + Context("E2E TEST:Validating deps are frozen", func() { + It("Should return deps are frozen", func() { + l := log{} + checker := checker.Checker{ + Ctx: context.Background(), + Client: ghClient, + HttpClient: client, + Owner: "tensorflow", + Repo: "tensorflow", + GraphClient: graphClient, + Logf: l.Logf, + } + result := checks.FrozenDeps(checker) + Expect(result.Error).Should(BeNil()) + Expect(result.Pass).Should(BeTrue()) + }) + }) +}) diff --git a/e2e/fuzzing_test.go b/e2e/fuzzing_test.go new file mode 100644 index 00000000..5756cfae --- /dev/null +++ b/e2e/fuzzing_test.go @@ -0,0 +1,30 @@ +package e2e + +import ( + "context" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + "github.com/ossf/scorecard/checker" + "github.com/ossf/scorecard/checks" +) + +var _ = Describe("E2E TEST:Fuzzing", func() { + Context("E2E TEST:Validating use of fuzzing tools", func() { + It("Should return use of fuzzing tools", func() { + l := log{} + checker := checker.Checker{ + Ctx: context.Background(), + Client: ghClient, + HttpClient: client, + Owner: "tensorflow", + Repo: "tensorflow", + GraphClient: graphClient, + Logf: l.Logf, + } + result := checks.Fuzzing(checker) + Expect(result.Error).Should(BeNil()) + Expect(result.Pass).Should(BeTrue()) + }) + }) +}) diff --git a/e2e/packaging_test.go b/e2e/packaging_test.go index 7255e511..b92261e5 100644 --- a/e2e/packaging_test.go +++ b/e2e/packaging_test.go @@ -10,8 +10,8 @@ import ( ) var _ = Describe("E2E TEST:Packaging", func() { - Context("E2E TEST:Validating packaging", func() { - It("Should return valid packaging workflow", func() { + Context("E2E TEST:Validating use of packaging in CI/CD", func() { + It("Should return use of packaging in CI/CD", func() { l := log{} checker := checker.Checker{ Ctx: context.Background(), diff --git a/e2e/pull_requests_test.go b/e2e/pull_requests_test.go new file mode 100644 index 00000000..4258fd3e --- /dev/null +++ b/e2e/pull_requests_test.go @@ -0,0 +1,30 @@ +package e2e + +import ( + "context" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + "github.com/ossf/scorecard/checker" + "github.com/ossf/scorecard/checks" +) + +var _ = Describe("E2E TEST:PullRequests", func() { + Context("E2E TEST:Validating use of pull requests", func() { + It("Should return use of pull requests", func() { + l := log{} + checker := checker.Checker{ + Ctx: context.Background(), + Client: ghClient, + HttpClient: client, + Owner: "apache", + Repo: "airflow", + GraphClient: graphClient, + Logf: l.Logf, + } + result := checks.PullRequests(checker) + Expect(result.Error).Should(BeNil()) + Expect(result.Pass).Should(BeTrue()) + }) + }) +}) diff --git a/e2e/sast_test.go b/e2e/sast_test.go new file mode 100644 index 00000000..82fa06b0 --- /dev/null +++ b/e2e/sast_test.go @@ -0,0 +1,30 @@ +package e2e + +import ( + "context" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + "github.com/ossf/scorecard/checker" + "github.com/ossf/scorecard/checks" +) + +var _ = Describe("E2E TEST:SAST", func() { + Context("E2E TEST:Validating use of SAST tools", func() { + It("Should return use of SAST tools", func() { + l := log{} + checker := checker.Checker{ + Ctx: context.Background(), + Client: ghClient, + HttpClient: client, + Owner: "apache", + Repo: "airflow", + GraphClient: graphClient, + Logf: l.Logf, + } + result := checks.SAST(checker) + Expect(result.Error).Should(BeNil()) + Expect(result.Pass).Should(BeTrue()) + }) + }) +}) diff --git a/e2e/security_policy_test.go b/e2e/security_policy_test.go new file mode 100644 index 00000000..e3dc7417 --- /dev/null +++ b/e2e/security_policy_test.go @@ -0,0 +1,30 @@ +package e2e + +import ( + "context" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + "github.com/ossf/scorecard/checker" + "github.com/ossf/scorecard/checks" +) + +var _ = Describe("E2E TEST:SecurityPolicy", func() { + Context("E2E TEST:Validating security policy", func() { + It("Should return valid security policy", func() { + l := log{} + checker := checker.Checker{ + Ctx: context.Background(), + Client: ghClient, + HttpClient: client, + Owner: "tensorflow", + Repo: "tensorflow", + GraphClient: graphClient, + Logf: l.Logf, + } + result := checks.SecurityPolicy(checker) + Expect(result.Error).Should(BeNil()) + Expect(result.Pass).Should(BeTrue()) + }) + }) +})