-
Notifications
You must be signed in to change notification settings - Fork 508
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into naveen/feat/changescope
- Loading branch information
Showing
13 changed files
with
537 additions
and
331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright 2022 Security Scorecard Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package checker | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/ossf/scorecard/v4/clients" | ||
ghrepo "github.com/ossf/scorecard/v4/clients/githubrepo" | ||
"github.com/ossf/scorecard/v4/clients/localdir" | ||
"github.com/ossf/scorecard/v4/log" | ||
) | ||
|
||
// GetClients returns a list of clients for running scorecard checks. | ||
// TODO(repo): Pass a `http.RoundTripper` here. | ||
func GetClients(ctx context.Context, repoURI, localURI string, logger *log.Logger) ( | ||
clients.Repo, // repo | ||
clients.RepoClient, // repoClient | ||
clients.RepoClient, // ossFuzzClient | ||
clients.CIIBestPracticesClient, // ciiClient | ||
clients.VulnerabilitiesClient, // vulnClient | ||
error) { | ||
var githubRepo clients.Repo | ||
if localURI != "" { | ||
localRepo, errLocal := localdir.MakeLocalDirRepo(localURI) | ||
return localRepo, /*repo*/ | ||
localdir.CreateLocalDirClient(ctx, logger), /*repoClient*/ | ||
nil, /*ossFuzzClient*/ | ||
nil, /*ciiClient*/ | ||
nil, /*vulnClient*/ | ||
fmt.Errorf("getting local directory client: %w", errLocal) | ||
} | ||
|
||
githubRepo, errGitHub := ghrepo.MakeGithubRepo(repoURI) | ||
if errGitHub != nil { | ||
return githubRepo, | ||
nil, | ||
nil, | ||
nil, | ||
nil, | ||
fmt.Errorf("getting local directory client: %w", errGitHub) | ||
} | ||
|
||
ossFuzzRepoClient, errOssFuzz := ghrepo.CreateOssFuzzRepoClient(ctx, logger) | ||
|
||
// TODO(repo): Should we be handling the OSS-Fuzz client error like this? | ||
return githubRepo, /*repo*/ | ||
ghrepo.CreateGithubRepoClient(ctx, logger), /*repoClient*/ | ||
ossFuzzRepoClient, /*ossFuzzClient*/ | ||
clients.DefaultCIIBestPracticesClient(), /*ciiClient*/ | ||
clients.DefaultVulnerabilitiesClient(), /*vulnClient*/ | ||
fmt.Errorf("getting OSS-Fuzz repo client: %w", errOssFuzz) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.