Skip to content

Commit

Permalink
🧹 remove share report flag
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-rock committed Jan 15, 2024
1 parent 7e1965c commit 1236401
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 30 deletions.
3 changes: 0 additions & 3 deletions apps/cnspec/cmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,4 @@ type CliConfig struct {
// Asset Category
Category string `json:"category,omitempty" mapstructure:"category"`
AutoDetectCICDCategory bool `json:"detect-cicd,omitempty" mapstructure:"detect-cicd"`

// Configure report sharing
ShareReport *bool `json:"share_report,omitempty" mapstructure:"share_report"`
}
23 changes: 0 additions & 23 deletions apps/cnspec/cmd/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"go.mondoo.com/cnspec/v10/cli/reporter"
"go.mondoo.com/cnspec/v10/policy"
"go.mondoo.com/cnspec/v10/policy/scan"
policy_upstream "go.mondoo.com/cnspec/v10/policy/upstream"
)

const (
Expand Down Expand Up @@ -63,7 +62,6 @@ func init() {
scanCmd.Flags().String("category", "inventory", "Set the category for the assets to 'inventory|cicd'.")
scanCmd.Flags().MarkHidden("category")
scanCmd.Flags().Int("score-threshold", 0, "If any score falls below the threshold, exit 1.")
scanCmd.Flags().Bool("share", false, "create a web-based private reports when cnspec is unauthenticated. Defaults to false.")
scanCmd.Flags().String("output-target", "", "Set output target to which the asset report will be sent. Currently only supports AWS SQS topic URLs and local files")
}

Expand Down Expand Up @@ -101,7 +99,6 @@ To manually configure a policy, use this:
viper.BindPFlag("asset-name", cmd.Flags().Lookup("asset-name"))
viper.BindPFlag("category", cmd.Flags().Lookup("category"))
viper.BindPFlag("score-threshold", cmd.Flags().Lookup("score-threshold"))
viper.BindPFlag("share", cmd.Flags().Lookup("share"))

// for all assets
viper.BindPFlag("incognito", cmd.Flags().Lookup("incognito"))
Expand Down Expand Up @@ -157,26 +154,6 @@ var scanCmdRun = func(cmd *cobra.Command, runtime *providers.Runtime, cliRes *pl
log.Fatal().Err(err).Msg("failed to write report to output target")
}

var shareReport bool
if viper.IsSet("share") {
shareReportFlag := viper.GetBool("share")
shareReport = shareReportFlag
}

// if report sharing was requested, share the report and print the URL
if conf.IsIncognito && shareReport {
proxy, err := config.GetAPIProxy()
if err != nil {
log.Error().Err(err).Msg("error getting proxy information")
} else {
reportId, err := policy_upstream.UploadSharedReport(report, os.Getenv(featureReportAlternateUrlEnv), proxy)
if err != nil {
log.Fatal().Err(err).Msg("could not upload report results")
}
fmt.Printf("View report at %s\n", reportId.Url)
}
}

// if we had asset errors, we return a non-zero exit code
// asset errors are only connection issues
if report != nil {
Expand Down
4 changes: 1 addition & 3 deletions test/cli/testdata/cnspec.ct
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Available Commands:
status Verify access to Mondoo Platform.
vault Manage vault environments.
version Display the cnspec version.
vuln Scans a target for Vulnerabilities.

Flags:
--api-proxy string Set proxy for communications with Mondoo API
Expand All @@ -34,7 +35,4 @@ Flags:
--log-level string Set log level: error, warn, info, debug, trace (default "info")
-v, --verbose Enable verbose output

Additional help topics:
cnspec vuln Scans a target for Vulnerabilities.

Use "cnspec [command] --help" for more information about a command.
1 change: 0 additions & 1 deletion test/cli/testdata/cnspec_scan.ct
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ Flags:
-f, --policy-bundle strings Path to local policy file
--props stringToString Custom values for properties (default [])
--score-threshold int If any score falls below the threshold, exit 1.
--share create a web-based private reports when cnspec is unauthenticated. Defaults to false.

Global Flags:
--api-proxy string Set proxy for communications with Mondoo API
Expand Down

0 comments on commit 1236401

Please sign in to comment.