Skip to content

Commit

Permalink
feat(cli): add compliance report disable warning (#778)
Browse files Browse the repository at this point in the history
ALLY-989
  • Loading branch information
hazedav authored Apr 25, 2022
1 parent e47ea55 commit ae2ffb7
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions cli/cmd/compliance_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"strings"
"time"

"github.com/AlecAivazis/survey/v2"
"github.com/olekukonko/tablewriter"
"github.com/pkg/errors"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -273,6 +274,14 @@ To disable all recommendations for CIS_1_1 report run:
},
Args: cobra.ExactArgs(1),
RunE: func(_ *cobra.Command, args []string) error {
// prompt for changes
proceed, err := complianceAwsDisableReportDisplayChanges()
if err != nil {
return errors.Wrap(err, "unable to confirm disable")
}
if !proceed {
return nil
}

schema, err := fetchCachedAwsComplianceReportSchema(args[0])
if err != nil {
Expand Down Expand Up @@ -451,6 +460,45 @@ func init() {
)
}

// Simple helper to prompt for approval after disable request
func complianceAwsDisableReportCmdPrompt() (int, error) {
message := `WARNING! Disabling all recommendations for CIS_1_1 will disable the following reports and its corresponding compliance alerts:
AWS CIS Benchmark and S3 Report
AWS HIPAA Report
AWS ISO 27001:2013 Report
AWS NIST 800-171 Report
AWS NIST 800-53 Report
AWS PCI DSS Report
AWS SOC 2 Report
AWS SOC 2 Report Rev2
Would you like to proceed?
`
options := []string{
"Proceed with disable",
"Quit",
}

var answer int
err := SurveyQuestionInteractiveOnly(SurveyQuestionWithValidationArgs{
Prompt: &survey.Select{
Message: message,
Options: options,
},
Response: &answer,
})

return answer, err
}

func complianceAwsDisableReportDisplayChanges() (bool, error) {
answer, err := complianceAwsDisableReportCmdPrompt()
if err != nil {
return false, err
}
return answer == 0, nil
}

func complianceAwsReportDetailsTable(report *api.ComplianceAwsReport) [][]string {
return [][]string{
[]string{"Report Type", report.ReportType},
Expand Down

0 comments on commit ae2ffb7

Please sign in to comment.