From f7f75d0bb3d8dca5c8c5d37494bd66c213b6c675 Mon Sep 17 00:00:00 2001 From: Raghav Kaul <8695110+raghavkaul@users.noreply.github.com> Date: Mon, 18 Sep 2023 15:22:25 -0400 Subject: [PATCH] Update URI() for GitLab repos. Add fuzzing test (#3477) Signed-off-by: Raghav Kaul --- clients/gitlabrepo/client.go | 2 +- e2e/fuzzing_test.go | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/clients/gitlabrepo/client.go b/clients/gitlabrepo/client.go index f79e502aa56..601d9dbff75 100644 --- a/clients/gitlabrepo/client.go +++ b/clients/gitlabrepo/client.go @@ -163,7 +163,7 @@ func (client *Client) InitRepo(inputRepo clients.Repo, commitSHA string, commitD } func (client *Client) URI() string { - return fmt.Sprintf("%s/%s/%s", client.repourl.host, client.repourl.owner, client.repourl.projectID) + return fmt.Sprintf("%s/%s/%s", client.repourl.host, client.repourl.owner, client.repourl.project) } func (client *Client) LocalPath() (string, error) { diff --git a/e2e/fuzzing_test.go b/e2e/fuzzing_test.go index 7344e3d76bb..cf94f297688 100644 --- a/e2e/fuzzing_test.go +++ b/e2e/fuzzing_test.go @@ -25,6 +25,7 @@ import ( "github.com/ossf/scorecard/v4/checks/raw" "github.com/ossf/scorecard/v4/clients" "github.com/ossf/scorecard/v4/clients/githubrepo" + "github.com/ossf/scorecard/v4/clients/gitlabrepo" "github.com/ossf/scorecard/v4/clients/ossfuzz" scut "github.com/ossf/scorecard/v4/utests" ) @@ -60,6 +61,38 @@ var _ = Describe("E2E TEST:"+checks.CheckFuzzing, func() { Expect(repoClient.Close()).Should(BeNil()) Expect(ossFuzzRepoClient.Close()).Should(BeNil()) }) + It("Should return use of OSS-Fuzz - GitLab", func() { + dl := scut.TestDetailLogger{} + repo, err := gitlabrepo.MakeGitlabRepo("gitlab.com/libtiff/libtiff") + Expect(err).Should(BeNil()) + + repoClient, err := gitlabrepo.CreateGitlabClient(context.Background(), repo.Host()) + Expect(err).Should(BeNil()) + err = repoClient.InitRepo(repo, clients.HeadSHA, 0) + + Expect(err).Should(BeNil()) + ossFuzzRepoClient, err := ossfuzz.CreateOSSFuzzClientEager(ossfuzz.StatusURL) + Expect(err).Should(BeNil()) + + req := checker.CheckRequest{ + Ctx: context.Background(), + RepoClient: repoClient, + OssFuzzRepo: ossFuzzRepoClient, + Repo: repo, + Dlogger: &dl, + } + expected := scut.TestReturn{ + Error: nil, + Score: checker.MaxResultScore, + NumberOfWarn: 0, + NumberOfInfo: 1, + NumberOfDebug: 0, + } + result := checks.Fuzzing(&req) + Expect(scut.ValidateTestReturn(nil, "use fuzzing", &expected, &result, &dl)).Should(BeTrue()) + Expect(repoClient.Close()).Should(BeNil()) + Expect(ossFuzzRepoClient.Close()).Should(BeNil()) + }) It("Should return use of ClusterFuzzLite", func() { dl := scut.TestDetailLogger{} repo, err := githubrepo.MakeGithubRepo("ossf-tests/scorecard-check-fuzzing-cflite")