Skip to content

Commit

Permalink
fix(GROW-2950): remove gcp audit log storage references
Browse files Browse the repository at this point in the history
  • Loading branch information
ipcrm committed Jun 13, 2024
1 parent 08f67ba commit 8f9576c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 313 deletions.
132 changes: 8 additions & 124 deletions cli/cmd/generate_gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,9 @@ var (
"you want to monitor: (optional)"
QuestionGcpRegions = "Specify a comma separated list of regions to deploy Agentless:"

GcpAdvancedOptAuditLog = "Configure additional Audit Log options"
QuestionGcpUseExistingBucket = "Use an existing bucket?"
QuestionGcpExistingBucketName = "Specify an existing bucket name:"
QuestionGcpConfigureNewBucket = "Configure settings for new bucket?"
QuestionGcpBucketRegion = "Specify the bucket region: (optional)"
QuestionGcpCustomBucketName = "Specify a custom bucket name: (optional)"
QuestionGcpBucketLifecycle = "Specify the bucket lifecycle rule age: (optional)"
QuestionGcpEnableUBLA = "Enable uniform bucket level access(UBLA)?"
QuestionGcpUseExistingSink = "Use an existing sink?"
QuestionGcpExistingSinkName = "Specify the existing sink name"
GcpAdvancedOptAuditLog = "Configure additional Audit Log options"
QuestionGcpUseExistingSink = "Use an existing sink?"
QuestionGcpExistingSinkName = "Specify the existing sink name"

GcpAdvancedOptIntegrationName = "Customize integration name(s)"
QuestionGcpConfigurationIntegrationName = "Specify a custom configuration integration name: (optional)"
Expand Down Expand Up @@ -110,16 +103,11 @@ See help output for more details on the parameter value(s) required for Terrafor
gcp.WithExistingServiceAccount(GenerateGcpCommandState.ExistingServiceAccount),
gcp.WithConfigurationIntegrationName(GenerateGcpCommandState.ConfigurationIntegrationName),
gcp.WithAuditLogLabels(GenerateGcpCommandState.AuditLogLabels),
gcp.WithBucketLabels(GenerateGcpCommandState.BucketLabels),
gcp.WithPubSubSubscriptionLabels(GenerateGcpCommandState.PubSubSubscriptionLabels),
gcp.WithPubSubTopicLabels(GenerateGcpCommandState.PubSubTopicLabels),
gcp.WithCustomBucketName(GenerateGcpCommandState.CustomBucketName),
gcp.WithBucketRegion(GenerateGcpCommandState.BucketRegion),
gcp.WithExistingLogBucketName(GenerateGcpCommandState.ExistingLogBucketName),
gcp.WithExistingLogSinkName(GenerateGcpCommandState.ExistingLogSinkName),
gcp.WithAuditLogIntegrationName(GenerateGcpCommandState.AuditLogIntegrationName),
gcp.WithLaceworkProfile(GenerateGcpCommandState.LaceworkProfile),
gcp.WithLogBucketLifecycleRuleAge(GenerateGcpCommandState.LogBucketLifecycleRuleAge),
gcp.WithFoldersToInclude(GenerateGcpCommandState.FoldersToInclude),
gcp.WithFoldersToExclude(GenerateGcpCommandState.FoldersToExclude),
gcp.WithCustomFilter(GenerateGcpCommandState.CustomFilter),
Expand Down Expand Up @@ -283,20 +271,17 @@ See help output for more details on the parameter value(s) required for Terrafor
)

type GcpGenerateCommandExtraState struct {
AskAdvanced bool
Output string
ConfigureNewBucketSettings bool
UseExistingServiceAccount bool
UseExistingBucket bool
UseExistingSink bool
TerraformApply bool
AskAdvanced bool
Output string
UseExistingServiceAccount bool
UseExistingSink bool
TerraformApply bool
}

func (gcp *GcpGenerateCommandExtraState) isEmpty() bool {
return gcp.Output == "" &&
!gcp.AskAdvanced &&
!gcp.UseExistingServiceAccount &&
!gcp.UseExistingBucket &&
!gcp.UseExistingSink &&
!gcp.TerraformApply
}
Expand Down Expand Up @@ -361,22 +346,6 @@ func initGenerateGcpTfCommandFlags() {
"configuration_integration_name",
"",
"specify a custom configuration integration name")
generateGcpTfCommand.PersistentFlags().StringVar(
&GenerateGcpCommandState.CustomBucketName,
"custom_bucket_name",
"",
"override prefix based storage bucket name generation with a custom name")
// TODO: Implement AuditLogLabels, BucketLabels, PubSubSubscriptionLabels & PubSubTopicLabels
generateGcpTfCommand.PersistentFlags().StringVar(
&GenerateGcpCommandState.BucketRegion,
"bucket_region",
"",
"specify bucket region")
generateGcpTfCommand.PersistentFlags().StringVar(
&GenerateGcpCommandState.ExistingLogBucketName,
"existing_bucket_name",
"",
"specify existing bucket name")
generateGcpTfCommand.PersistentFlags().StringVar(
&GenerateGcpCommandState.ExistingLogSinkName,
"existing_sink_name",
Expand All @@ -393,27 +362,13 @@ func initGenerateGcpTfCommandFlags() {
[]string{},
"List of GCP regions to deploy for Agentless integration")

// DEPRECATED
generateGcpTfCommand.PersistentFlags().BoolVar(
&GenerateGcpCommandState.EnableForceDestroyBucket,
"enable_force_destroy_bucket",
true,
"enable force bucket destroy")
errcheckWARN(generateGcpTfCommand.PersistentFlags().MarkDeprecated(
"enable_force_destroy_bucket", "by default, force destroy is enabled.",
))
// ---

generateGcpTfCommand.PersistentFlags().BoolVar(
&GenerateGcpCommandState.EnableUBLA,
"enable_ubla",
true,
"enable universal bucket level access(ubla)")
generateGcpTfCommand.PersistentFlags().IntVar(
&GenerateGcpCommandState.LogBucketLifecycleRuleAge,
"bucket_lifecycle_rule_age",
-1,
"specify the lifecycle rule age")
generateGcpTfCommand.PersistentFlags().StringVar(
&GenerateGcpCommandState.CustomFilter,
"custom_filter",
Expand Down Expand Up @@ -534,10 +489,6 @@ func promptGcpAuditLogQuestions(
extraState *GcpGenerateCommandExtraState,
) error {

// Present the user with Bucket Configuration options, if required
if err := promptGcpBucketConfiguration(config, extraState); err != nil {
return err
}
err := SurveyMultipleQuestionWithValidation([]SurveyQuestionWithValidationArgs{
{
Prompt: &survey.Confirm{Message: QuestionGcpUseExistingSink, Default: extraState.UseExistingSink},
Expand All @@ -561,73 +512,6 @@ func promptGcpAuditLogQuestions(
return err
}

func promptGcpBucketConfiguration(
config *gcp.GenerateGcpTfConfigurationArgs, extraState *GcpGenerateCommandExtraState,
) error {
// Prompt to configure bucket information (not required when using the Pub Sub Audit Log)
if err := SurveyMultipleQuestionWithValidation([]SurveyQuestionWithValidationArgs{
{
Prompt: &survey.Confirm{Message: QuestionGcpUseExistingBucket, Default: extraState.UseExistingBucket},
Checks: []*bool{&config.AuditLog, usePubSubActivityDisabled(config)},
Response: &extraState.UseExistingBucket,
},
{
Prompt: &survey.Input{Message: QuestionGcpExistingBucketName, Default: config.ExistingLogBucketName},
Checks: []*bool{&config.AuditLog, &extraState.UseExistingBucket, usePubSubActivityDisabled(config)},
Required: true,
Response: &config.ExistingLogBucketName,
},
}, config.AuditLog); err != nil {
return err
}

newBucket := !extraState.UseExistingBucket
err := SurveyMultipleQuestionWithValidation([]SurveyQuestionWithValidationArgs{
{
Prompt: &survey.Confirm{Message: QuestionGcpConfigureNewBucket, Default: extraState.ConfigureNewBucketSettings},
Checks: []*bool{&config.AuditLog, &newBucket, usePubSubActivityDisabled(config)},
Required: true,
Response: &extraState.ConfigureNewBucketSettings,
},
{
Prompt: &survey.Input{Message: QuestionGcpBucketRegion, Default: config.BucketRegion},
Checks: []*bool{&config.AuditLog,
&newBucket,
&extraState.ConfigureNewBucketSettings,
usePubSubActivityDisabled(config)},
Opts: []survey.AskOpt{survey.WithValidator(validateGcpRegion)},
Response: &config.BucketRegion,
},
{
Prompt: &survey.Input{Message: QuestionGcpCustomBucketName, Default: config.CustomBucketName},
Checks: []*bool{&config.AuditLog,
&newBucket,
&extraState.ConfigureNewBucketSettings,
usePubSubActivityDisabled(config)},
Response: &config.CustomBucketName,
},
{
Prompt: &survey.Input{Message: QuestionGcpBucketLifecycle, Default: "-1"},
Checks: []*bool{&config.AuditLog,
&newBucket,
&extraState.ConfigureNewBucketSettings,
usePubSubActivityDisabled(config)},
Response: &config.LogBucketLifecycleRuleAge,
},
{
Prompt: &survey.Confirm{Message: QuestionGcpEnableUBLA, Default: config.EnableUBLA},
Checks: []*bool{&config.AuditLog,
&newBucket,
&extraState.ConfigureNewBucketSettings,
usePubSubActivityDisabled(config)},
Required: true,
Response: &config.EnableUBLA,
},
}, config.AuditLog)

return err
}

func usePubSubActivityDisabled(config *gcp.GenerateGcpTfConfigurationArgs) *bool {

Check failure on line 515 in cli/cmd/generate_gcp.go

View workflow job for this annotation

GitHub Actions / run-linting-and-unit-tests

func `usePubSubActivityDisabled` is unused (unused)
usePubSubActivityDisabled := !config.UsePubSubAudit
return &usePubSubActivityDisabled
Expand Down
Loading

0 comments on commit 8f9576c

Please sign in to comment.