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 47c9bae commit f66eb10
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
3 changes: 1 addition & 2 deletions pkg/json_probe_results.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type JSONScorecardProbeResult struct {
Repo jsonRepoV2 `json:"repo"`
Scorecard jsonScorecardV2 `json:"scorecard"`
Findings []finding.Finding `json:"findings"`
Metadata map[string]string `json:"metadata"`
Metadata map[string]any `json:"metadata"`
}

// TODO: finsinds should enventually be part of the scorecard structure.
Expand All @@ -48,7 +48,6 @@ func (r *ScorecardResult) AsPJSON(writer io.Writer) error {
},
Date: r.Date.Format("2006-01-02"),
Findings: r.Findings,
Metadata: r.RawResults.Metadata,
}

if err := encoder.Encode(out); err != nil {
Expand Down
32 changes: 20 additions & 12 deletions pkg/scorecard.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"context"
"errors"
"fmt"
"os"
"strings"
"sync"
"time"
Expand All @@ -29,6 +30,7 @@ import (
"github.com/ossf/scorecard/v4/clients"
sce "github.com/ossf/scorecard/v4/errors"
"github.com/ossf/scorecard/v4/finding"
"github.com/ossf/scorecard/v4/options"
"github.com/ossf/scorecard/v4/probes"
"github.com/ossf/scorecard/v4/probes/zrunner"
)
Expand Down Expand Up @@ -163,17 +165,23 @@ func runScorecardChecksV5(ctx context.Context,
ret.Checks = append(ret.Checks, result)
}

// Run the probes.
var findings []finding.Finding
// TODO(#3049): only run the probes for checks.
// NOTE: We will need separate functions to support:
// - `--probes X,Y`
// - `--check-definitions-file path/to/config.yml
// NOTE: we discard the returned error because the errors are
// already cotained in the findings and we want to return the findings
// to users.
// See https://github.com/ossf/scorecard/blob/main/probes/zrunner/runner.go#L34-L45.
findings, _ = zrunner.Run(&ret.RawResults, probes.All)
ret.Findings = findings
if value, _ := os.LookupEnv(options.EnvVarScorecardExperimental); value == "1" {
// Run the probes.
var findings []finding.Finding
// TODO(#3049): only run the probes for checks.
// NOTE: We will need separate functions to support:
// - `--probes X,Y`
// - `--check-definitions-file path/to/config.yml
// NOTE: we discard the returned error because the errors are
// already cotained in the findings and we want to return the findings
// to users.
// See https://github.com/ossf/scorecard/blob/main/probes/zrunner/runner.go#L34-L45.
// Note: we discard the error because each probe's error is reported within
// the probe and we don't want the entire scorecard run to fail if a single error
// is encountered.
//nolint:errcheck
findings, _ = zrunner.Run(&ret.RawResults, probes.All)
ret.Findings = findings
}
return ret, nil
}

0 comments on commit f66eb10

Please sign in to comment.