From a98fc42331a70f25548730237955f847cc9a2118 Mon Sep 17 00:00:00 2001 From: Chris Brown <1731074+ccbrown@users.noreply.github.com> Date: Sat, 19 Apr 2025 20:23:16 -0400 Subject: [PATCH] set canManageScps field for accounts --- backend/app/aws_integration.go | 4 +++- backend/app/report.go | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/app/aws_integration.go b/backend/app/aws_integration.go index 452bfd5..c72fd54 100644 --- a/backend/app/aws_integration.go +++ b/backend/app/aws_integration.go @@ -210,7 +210,7 @@ func (s *Session) CreateAWSIntegration(ctx context.Context, input CreateAWSInteg { today := time.Now().Truncate(24 * time.Hour) for i := 0; i < 7; i++ { - if err := s.app.queueAWSIntegrationReportGeneration(ctx, queueAWSIntegrationReportGenerationInput{ + if err := s.app.doReconAndQueueAWSIntegrationReportGeneration(ctx, doReconAndQueueAWSIntegrationReportGenerationInput{ Integration: integration, StartTime: today.Add(-time.Duration(i) * 24 * time.Hour), Duration: 24 * time.Hour, @@ -320,6 +320,7 @@ type PutAWSIntegrationReconInput struct { TeamId model.Id Time time.Time Accounts []PutAWSIntegrationReconAccountInput + CanManageSCPs bool } type PutAWSIntegrationReconAccountInput struct { @@ -333,6 +334,7 @@ func (a *App) PutAWSIntegrationRecon(ctx context.Context, input PutAWSIntegratio TeamId: input.TeamId, Time: input.Time, ExpirationTime: input.Time.Add(3 * 24 * time.Hour), + CanManageSCPs: input.CanManageSCPs, Accounts: make([]model.AWSIntegrationAccountRecon, len(input.Accounts)), } for i, account := range input.Accounts { diff --git a/backend/app/report.go b/backend/app/report.go index ce27983..068660c 100644 --- a/backend/app/report.go +++ b/backend/app/report.go @@ -80,7 +80,7 @@ func (a *App) QueueTeamReportGeneration(ctx context.Context, input QueueTeamRepo return fmt.Errorf("failed to get aws integrations: %w", err) } for _, integration := range integrations { - if err := a.queueAWSIntegrationReportGeneration(ctx, queueAWSIntegrationReportGenerationInput{ + if err := a.doReconAndQueueAWSIntegrationReportGeneration(ctx, doReconAndQueueAWSIntegrationReportGenerationInput{ Integration: integration, StartTime: input.StartTime, Duration: input.Duration, @@ -111,7 +111,7 @@ func (s *Session) QueueAWSIntegrationReportGeneration(ctx context.Context, input } else if integration == nil { return NotFoundError("No such AWS integration.") } - return s.SanitizedError(s.app.queueAWSIntegrationReportGeneration(ctx, queueAWSIntegrationReportGenerationInput{ + return s.SanitizedError(s.app.doReconAndQueueAWSIntegrationReportGeneration(ctx, doReconAndQueueAWSIntegrationReportGenerationInput{ Integration: integration, StartTime: input.StartTime, Duration: input.Duration, @@ -120,7 +120,7 @@ func (s *Session) QueueAWSIntegrationReportGeneration(ctx context.Context, input })) } -type queueAWSIntegrationReportGenerationInput struct { +type doReconAndQueueAWSIntegrationReportGenerationInput struct { Integration *model.AWSIntegration StartTime time.Time Duration time.Duration @@ -132,7 +132,7 @@ type queueAWSIntegrationReportGenerationInput struct { ReconOnly bool } -func (a *App) queueAWSIntegrationReportGeneration(ctx context.Context, input queueAWSIntegrationReportGenerationInput) error { +func (a *App) doReconAndQueueAWSIntegrationReportGeneration(ctx context.Context, input doReconAndQueueAWSIntegrationReportGenerationInput) error { creds, err := a.assumeAWSIntegrationRole(ctx, input.Integration) if err != nil { return fmt.Errorf("failed to assume role: %w", err) @@ -233,6 +233,7 @@ func (a *App) queueAWSIntegrationReportGeneration(ctx context.Context, input que TeamId: input.Integration.TeamId, Time: time.Now(), Accounts: accountRecons, + CanManageSCPs: input.Integration.ManageSCPs, }); err != nil { return fmt.Errorf("failed to put aws integration recon: %w", err) }