Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsimon committed Mar 17, 2022
1 parent 5e85c14 commit c8097e7
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 21 deletions.
3 changes: 1 addition & 2 deletions checks/binary_artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const CheckBinaryArtifacts string = "Binary-Artifacts"

//nolint
func init() {
var supportedRequestTypes = []checker.RequestType{
supportedRequestTypes := []checker.RequestType{
checker.FileBased,
checker.CommitBased,
}
Expand All @@ -47,7 +47,6 @@ func BinaryArtifacts(c *checker.CheckRequest) checker.CheckResult {
// Return raw results.
if c.RawResults != nil {
c.RawResults.BinaryArtifactResults = rawData
return checker.CheckResult{}
}

// Return the score evaluation.
Expand Down
1 change: 0 additions & 1 deletion checks/branch_protection.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func BranchProtection(c *checker.CheckRequest) checker.CheckResult {
// Return raw results.
if c.RawResults != nil {
c.RawResults.BranchProtectionResults = rawData
return checker.CheckResult{}
}

// Return the score evaluation.
Expand Down
1 change: 0 additions & 1 deletion checks/code_review.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func CodeReview(c *checker.CheckRequest) checker.CheckResult {
// Return raw results.
if c.RawResults != nil {
c.RawResults.CodeReviewResults = rawData
return checker.CheckResult{}
}

// Return the score evaluation.
Expand Down
3 changes: 1 addition & 2 deletions checks/dependency_update_tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const CheckDependencyUpdateTool = "Dependency-Update-Tool"

//nolint
func init() {
var supportedRequestTypes = []checker.RequestType{
supportedRequestTypes := []checker.RequestType{
checker.FileBased,
}
if err := registerCheck(CheckDependencyUpdateTool, DependencyUpdateTool, supportedRequestTypes); err != nil {
Expand All @@ -46,7 +46,6 @@ func DependencyUpdateTool(c *checker.CheckRequest) checker.CheckResult {
// Return raw results.
if c.RawResults != nil {
c.RawResults.DependencyUpdateToolResults = rawData
return checker.CheckResult{}
}

// Return the score evaluation.
Expand Down
1 change: 0 additions & 1 deletion checks/security_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func SecurityPolicy(c *checker.CheckRequest) checker.CheckResult {
// Set the raw results.
if c.RawResults != nil {
c.RawResults.SecurityPolicyResults = rawData
return checker.CheckResult{}
}

return evaluation.SecurityPolicy(CheckSecurityPolicy, c.Dlogger, &rawData)
Expand Down
1 change: 0 additions & 1 deletion checks/vulnerabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func Vulnerabilities(c *checker.CheckRequest) checker.CheckResult {
// Set the raw results.
if c.RawResults != nil {
c.RawResults.VulnerabilitiesResults = rawData
return checker.CheckResult{}
}

return evaluation.Vulnerabilities(CheckVulnerabilities, c.Dlogger, &rawData)
Expand Down
1 change: 0 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ func rootCmd(o *options.Options) {
ctx,
repoURI,
o.Commit,
o.Format == options.FormatRaw,
enabledChecks,
repoClient,
ossFuzzRepoClient,
Expand Down
2 changes: 1 addition & 1 deletion cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func serveCmd(o *options.Options) *cobra.Command {
defer ossFuzzRepoClient.Close()
ciiClient := clients.DefaultCIIBestPracticesClient()
repoResult, err := pkg.RunScorecards(
ctx, repo, clients.HeadSHA /*commitSHA*/, false /*raw*/, checks.AllChecks, repoClient,
ctx, repo, clients.HeadSHA /*commitSHA*/, checks.AllChecks, repoClient,
ossFuzzRepoClient, ciiClient, vulnsClient)
if err != nil {
logger.Error(err, "running enabled scorecard checks on repo")
Expand Down
2 changes: 1 addition & 1 deletion cron/worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func processRequest(ctx context.Context,
for _, check := range blacklistedChecks {
delete(checksToRun, check)
}
result, err := pkg.RunScorecards(ctx, repo, commitSHA, false /*raw*/, checksToRun,
result, err := pkg.RunScorecards(ctx, repo, commitSHA, checksToRun,
repoClient, ossFuzzRepoClient, ciiClient, vulnsClient)
if errors.Is(err, sce.ErrRepoUnreachable) {
// Not accessible repo - continue.
Expand Down
16 changes: 6 additions & 10 deletions pkg/scorecard.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ func runEnabledChecks(ctx context.Context,
repo clients.Repo, raw *checker.RawResults, checksToRun checker.CheckNameToFnMap,
repoClient clients.RepoClient, ossFuzzRepoClient clients.RepoClient, ciiClient clients.CIIBestPracticesClient,
vulnsClient clients.VulnerabilitiesClient,
resultsCh chan checker.CheckResult) {
resultsCh chan checker.CheckResult,
) {
request := checker.CheckRequest{
Ctx: ctx,
RepoClient: repoClient,
Expand Down Expand Up @@ -78,12 +79,12 @@ func getRepoCommitHash(r clients.RepoClient) (string, error) {
func RunScorecards(ctx context.Context,
repo clients.Repo,
commitSHA string,
raw bool,
checksToRun checker.CheckNameToFnMap,
repoClient clients.RepoClient,
ossFuzzRepoClient clients.RepoClient,
ciiClient clients.CIIBestPracticesClient,
vulnsClient clients.VulnerabilitiesClient) (ScorecardResult, error) {
vulnsClient clients.VulnerabilitiesClient,
) (ScorecardResult, error) {
if err := repoClient.InitRepo(repo, commitSHA); err != nil {
// No need to call sce.WithMessage() since InitRepo will do that for us.
//nolint:wrapcheck
Expand All @@ -108,13 +109,8 @@ func RunScorecards(ctx context.Context,
Date: time.Now(),
}
resultsCh := make(chan checker.CheckResult)
if raw {
go runEnabledChecks(ctx, repo, &ret.RawResults, checksToRun, repoClient, ossFuzzRepoClient,
ciiClient, vulnsClient, resultsCh)
} else {
go runEnabledChecks(ctx, repo, nil, checksToRun, repoClient, ossFuzzRepoClient,
ciiClient, vulnsClient, resultsCh)
}
go runEnabledChecks(ctx, repo, &ret.RawResults, checksToRun, repoClient, ossFuzzRepoClient,
ciiClient, vulnsClient, resultsCh)

for result := range resultsCh {
ret.Checks = append(ret.Checks, result)
Expand Down

0 comments on commit c8097e7

Please sign in to comment.