Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: laurentsimon <[email protected]>
  • Loading branch information
laurentsimon committed Jun 1, 2023
1 parent f66eb10 commit fa6a519
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 23 deletions.
6 changes: 5 additions & 1 deletion checker/raw_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ type RawResults struct {
LicenseResults LicenseData
TokenPermissionsResults TokenPermissionsData
CITestResults CITestData
Metadata map[string]string
Metadata MetadataData
}

type MetadataData struct {
Metadata map[string]string
}

type RevisionCIInfo struct {
Expand Down
2 changes: 0 additions & 2 deletions pkg/json_probe_results.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ type JSONScorecardProbeResult struct {
Repo jsonRepoV2 `json:"repo"`
Scorecard jsonScorecardV2 `json:"scorecard"`
Findings []finding.Finding `json:"findings"`
Metadata map[string]any `json:"metadata"`
}

// TODO: finsinds should enventually be part of the scorecard structure.
func (r *ScorecardResult) AsPJSON(writer io.Writer) error {
encoder := json.NewEncoder(writer)
out := JSONScorecardProbeResult{
Expand Down
23 changes: 3 additions & 20 deletions pkg/scorecard.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,6 @@ func RunScorecard(ctx context.Context,
ossFuzzRepoClient clients.RepoClient,
ciiClient clients.CIIBestPracticesClient,
vulnsClient clients.VulnerabilitiesClient,
) (ScorecardResult, error) {
return runScorecardChecksV5(ctx, repo, commitSHA, commitDepth,
checksToRun, repoClient, ossFuzzRepoClient,
ciiClient, vulnsClient)
}

func runScorecardChecksV5(ctx context.Context,
repo clients.Repo,
commitSHA string,
commitDepth int,
checksToRun checker.CheckNameToFnMap,
repoClient clients.RepoClient,
ossFuzzRepoClient clients.RepoClient,
ciiClient clients.CIIBestPracticesClient,
vulnsClient clients.VulnerabilitiesClient,
) (ScorecardResult, error) {
if err := repoClient.InitRepo(repo, commitSHA, commitDepth); err != nil {
// No need to call sce.WithMessage() since InitRepo will do that for us.
Expand All @@ -121,16 +106,14 @@ func runScorecardChecksV5(ctx context.Context,

commitSHA, err := getRepoCommitHash(repoClient)
if err != nil || commitSHA == "" {
//nolint:wrapcheck
return ScorecardResult{}, err
}
defaultBranch, err := repoClient.GetDefaultBranchName()
if err != nil {
if !errors.Is(err, clients.ErrUnsupportedFeature) {
//nolint:wrapcheck
return ScorecardResult{}, err
return ScorecardResult{}, sce.WithMessage(sce.ErrScorecardInternal, fmt.Sprintf("GetDefaultBranchName:%v", err.Error()))
}
defaultBranch = "<unknown>"
defaultBranch = "unknown"
}

versionInfo := version.GetVersionInfo()
Expand All @@ -149,7 +132,7 @@ func runScorecardChecksV5(ctx context.Context,

// Set metadata for all checks to use. This is necessary
// to create remediations from the probe yaml files.
ret.RawResults.Metadata = map[string]string{
ret.RawResults.Metadata.Metadata = map[string]string{
"repository.host": repo.Host(),
"repository.name": strings.TrimPrefix(repo.URI(), repo.Host()+"/"),
"repository.uri": repo.URI(),
Expand Down

0 comments on commit fa6a519

Please sign in to comment.