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

✨ Do not expose sarif and policy command #1405

Merged
merged 5 commits into from
Dec 21, 2021
Merged
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
32 changes: 19 additions & 13 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ const (

scorecardLong = "A program that shows security scorecard for an open source software."
scorecardUse = `./scorecard [--repo=<repo_url>] [--local=folder] [--checks=check1,...]
[--show-details] [--policy=file] or ./scorecard --{npm,pypi,rubygems}=<package_name>
[--checks=check1,...] [--show-details] [--policy=file]`
[--show-details] or ./scorecard --{npm,pypi,rubygems}=<package_name>
[--checks=check1,...] [--show-details]`
scorecardShort = "Security Scorecards"
)

const cliEnableSarif = "ENABLE_SARIF"

//nolint:gochecknoinits
func init() {
// Add the zap flag manually
Expand All @@ -95,8 +97,6 @@ func init() {
rootCmd.Flags().StringVar(
&rubygems, "rubygems", "",
"rubygems package to check, given that the rubygems package has a GitHub repository")
rootCmd.Flags().StringVar(&format, "format", formatDefault,
"output format. allowed values are [default, sarif, json]")
rootCmd.Flags().StringSliceVar(
&metaData, "metadata", []string{}, "metadata for the project. It can be multiple separated by commas")
rootCmd.Flags().BoolVar(&showDetails, "show-details", false, "show extra details about each check")
Expand All @@ -106,7 +106,17 @@ func init() {
}
rootCmd.Flags().StringSliceVar(&checksToRun, "checks", []string{},
fmt.Sprintf("Checks to run. Possible values are: %s", strings.Join(checkNames, ",")))
rootCmd.Flags().StringVar(&policyFile, "policy", "", "policy to enforce")

var sarifEnabled bool
_, sarifEnabled = os.LookupEnv(cliEnableSarif)
if sarifEnabled {
rootCmd.Flags().StringVar(&policyFile, "policy", "", "policy to enforce")
rootCmd.Flags().StringVar(&format, "format", formatDefault,
"output format allowed values are [default, sarif, json]")
} else {
rootCmd.Flags().StringVar(&format, "format", formatDefault,
"output format allowed values are [default, json]")
}

var v6 bool
_, v6 = os.LookupEnv("SCORECARD_V6")
Expand All @@ -126,21 +136,17 @@ func Execute() {
// nolint: gocognit, gocyclo
func scorecardCmd(cmd *cobra.Command, args []string) {
// UPGRADEv4: remove.
var v4 bool
_, v4 = os.LookupEnv("SCORECARD_V4")
var sarifEnabled bool
_, sarifEnabled = os.LookupEnv(cliEnableSarif)

if format == formatSarif && !v4 {
if format == formatSarif && !sarifEnabled {
log.Panic("sarif not supported yet")
}

if policyFile != "" && !v4 {
if policyFile != "" && !sarifEnabled {
log.Panic("policy not supported yet")
}

if local != "" && !v4 {
log.Panic("--local option not supported yet")
}

var v6 bool
_, v6 = os.LookupEnv("SCORECARD_V6")
if raw && !v6 {
Expand Down