Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Added CLI output for --probes #4391

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
pmc "github.com/ossf/scorecard/v5/cmd/internal/packagemanager"
docs "github.com/ossf/scorecard/v5/docs/checks"
sce "github.com/ossf/scorecard/v5/errors"
"github.com/ossf/scorecard/v5/finding"
sclog "github.com/ossf/scorecard/v5/log"
"github.com/ossf/scorecard/v5/options"
"github.com/ossf/scorecard/v5/pkg/scorecard"
Expand Down Expand Up @@ -164,7 +165,8 @@ func rootCmd(o *options.Options) error {

if o.Format == options.FormatDefault {
if len(enabledProbes) > 0 {
printProbeResults(enabledProbes)
printProbeResults(enabledProbes, repoResult.Findings)
return nil
eddie-knight marked this conversation as resolved.
Show resolved Hide resolved
} else {
printCheckResults(enabledChecks)
}
Expand Down Expand Up @@ -201,10 +203,19 @@ func printCheckStart(enabledChecks checker.CheckNameToFnMap) {
}
}

func printProbeResults(enabledProbes []string) {
func printProbeResults(enabledProbes []string, findings []finding.Finding) {
for _, probeName := range enabledProbes {
fmt.Fprintf(os.Stderr, "Finished probe %s\n", probeName)
}
for _, result := range findings {
if result.Remediation != nil {
eddie-knight marked this conversation as resolved.
Show resolved Hide resolved
// Remediation is indicative of a bad result.
// This output is a light alternative to the details provided by --format=probe
fmt.Fprintf(os.Stderr, "[%s] Remediation required: %s\n", result.Probe, result.Remediation.Text)
} else {
fmt.Fprintf(os.Stderr, "[%s] Passed: %s\n", result.Probe, result.Message)
Comment on lines +214 to +216
Copy link
Member

@spencerschrock spencerschrock Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How important are these exact phrases to your use case? Just informational?
I ask because I may want this cleaned up in the future/follow-up to be part of AsString. I'm not sure what it would look like, but being able to send the string to os.Stdout or the specified --output file would be good long-term.

}
}
}

func printCheckResults(enabledChecks checker.CheckNameToFnMap) {
Expand Down
Loading