Skip to content

Commit

Permalink
Update URI() for GitLab repos. Add fuzzing test
Browse files Browse the repository at this point in the history
Signed-off-by: Raghav Kaul <[email protected]>
  • Loading branch information
raghavkaul committed Sep 12, 2023
1 parent 8b096ad commit db473fe
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clients/gitlabrepo/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
33 changes: 33 additions & 0 deletions e2e/fuzzing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit db473fe

Please sign in to comment.