Skip to content

Commit

Permalink
✨ GitLab: Release (#3340)
Browse files Browse the repository at this point in the history
* Remove experimental flag

Signed-off-by: Raghav Kaul <raghavkaul@google.com>

* Docs

Signed-off-by: Raghav Kaul <raghavkaul@google.com>

* update tests

Signed-off-by: Raghav Kaul <raghavkaul@google.com>

---------

Signed-off-by: Raghav Kaul <raghavkaul@google.com>
  • Loading branch information
raghavkaul authored Aug 4, 2023
1 parent 76dc144 commit 7ed886f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,24 @@ RESULTS
|---------|------------------------|--------------------------------|--------------------------------|---------------------------------------------------------------------------|
```

##### Using a GitLab Repository

To run Scorecard on a GitLab repository, you must create a [GitLab Access Token](https://gitlab.com/-/profile/personal_access_tokens) with the following permissions:

- `read_api`
- `read_user`
- `read_repository`

You can run Scorecard on a GitLab repository by setting the `GITLAB_AUTH_TOKEN` environment variable:

```bash
export GITLAB_AUTH_TOKEN=glpat-xxxx

scorecard --repo gitlab.com/<org>/<project>/<subproject>
```

For an example of using Scorecard in GitLab CI/CD, see [here](https://gitlab.com/ossf-test/scorecard-pipeline-example).

##### Using GitHub Enterprise Server (GHES) based Repository

To use a GitHub Enterprise host `github.corp.com`, use the `GH_HOST` environment variable.
Expand Down
10 changes: 3 additions & 7 deletions checker/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package checker
import (
"context"
"fmt"
"os"

"github.com/ossf/scorecard/v4/clients"
ghrepo "github.com/ossf/scorecard/v4/clients/githubrepo"
Expand Down Expand Up @@ -54,14 +53,11 @@ func GetClients(ctx context.Context, repoURI, localURI string, logger *log.Logge
retErr
}

_, experimental := os.LookupEnv("SCORECARD_EXPERIMENTAL")
var repoClient clients.RepoClient

if experimental {
repo, makeRepoError = glrepo.MakeGitlabRepo(repoURI)
if repo != nil && makeRepoError == nil {
repoClient, makeRepoError = glrepo.CreateGitlabClient(ctx, repo.Host())
}
repo, makeRepoError = glrepo.MakeGitlabRepo(repoURI)
if repo != nil && makeRepoError == nil {
repoClient, makeRepoError = glrepo.CreateGitlabClient(ctx, repo.Host())
}

if makeRepoError != nil || repo == nil {
Expand Down
19 changes: 2 additions & 17 deletions checker/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,32 +68,17 @@ func TestGetClients(t *testing.T) { //nolint:gocognit
wantErr: true,
},
{
name: "repoURI is gitlab which is not supported",
name: "repoURI is gitlab which is supported",
args: args{
ctx: context.Background(),
repoURI: "https://gitlab.com/ossf/scorecard",
repoURI: "https://gitlab.com/ossf-test/scorecard",
localURI: "",
},
shouldOSSFuzzBeNil: false,
shouldRepoClientBeNil: false,
shouldVulnClientBeNil: false,
shouldRepoBeNil: true,
wantErr: true,
},
{
name: "repoURI is gitlab and experimental is true",
args: args{
ctx: context.Background(),
repoURI: "https://gitlab.com/ossf/scorecard",
localURI: "",
},
shouldOSSFuzzBeNil: false,
shouldRepoBeNil: false,
shouldRepoClientBeNil: false,
shouldVulnClientBeNil: false,
shouldCIIBeNil: false,
wantErr: false,
experimental: true,
},
{
name: "repoURI is corp github host",
Expand Down

0 comments on commit 7ed886f

Please sign in to comment.