Skip to content

Commit 1703089

Browse files
committed
🐛 Added CLI output for --probes
Signed-off-by: Eddie Knight <[email protected]>
1 parent 367426e commit 1703089

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

cmd/root.go

+12-4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
pmc "github.com/ossf/scorecard/v5/cmd/internal/packagemanager"
3535
docs "github.com/ossf/scorecard/v5/docs/checks"
3636
sce "github.com/ossf/scorecard/v5/errors"
37+
"github.com/ossf/scorecard/v5/finding"
3738
sclog "github.com/ossf/scorecard/v5/log"
3839
"github.com/ossf/scorecard/v5/options"
3940
"github.com/ossf/scorecard/v5/pkg/scorecard"
@@ -164,9 +165,8 @@ func rootCmd(o *options.Options) error {
164165

165166
if o.Format == options.FormatDefault {
166167
if len(enabledProbes) > 0 {
167-
printProbeResults(enabledProbes)
168-
} else {
169-
printCheckResults(enabledChecks)
168+
printProbeResults(enabledProbes, repoResult.Findings)
169+
return nil
170170
}
171171
}
172172

@@ -180,6 +180,7 @@ func rootCmd(o *options.Options) error {
180180
return fmt.Errorf("failed to format results: %w", resultsErr)
181181
}
182182

183+
printCheckResults(enabledChecks)
183184
// intentionally placed at end to preserve outputting results, even if a check has a runtime error
184185
for _, result := range repoResult.Checks {
185186
if result.Error != nil {
@@ -201,10 +202,17 @@ func printCheckStart(enabledChecks checker.CheckNameToFnMap) {
201202
}
202203
}
203204

204-
func printProbeResults(enabledProbes []string) {
205+
func printProbeResults(enabledProbes []string, findings []finding.Finding) {
205206
for _, probeName := range enabledProbes {
206207
fmt.Fprintf(os.Stderr, "Finished probe %s\n", probeName)
207208
}
209+
for _, result := range findings {
210+
if result.Remediation != nil {
211+
fmt.Fprintf(os.Stderr, "[%s] Remediation required: %s\n", result.Probe, result.Remediation.Text)
212+
} else {
213+
fmt.Fprintf(os.Stderr, "[%s] Passed: %s\n", result.Probe, result.Message)
214+
}
215+
}
208216
}
209217

210218
func printCheckResults(enabledChecks checker.CheckNameToFnMap) {

0 commit comments

Comments
 (0)