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

Scheduled scans - resolve cloud accounts in an organization #2391

Merged
merged 1 commit into from
Dec 11, 2024
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
15 changes: 13 additions & 2 deletions deepfence_worker/cronjobs/scheduled_tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/deepfence/ThreatMapper/deepfence_server/handler"
"github.com/deepfence/ThreatMapper/deepfence_server/model"
"github.com/deepfence/ThreatMapper/deepfence_server/reporters"
reportersScan "github.com/deepfence/ThreatMapper/deepfence_server/reporters/scan"
reporters_search "github.com/deepfence/ThreatMapper/deepfence_server/reporters/search"
"github.com/deepfence/ThreatMapper/deepfence_utils/controls"
ctl "github.com/deepfence/ThreatMapper/deepfence_utils/controls"
Expand Down Expand Up @@ -161,7 +162,12 @@ func runSystemScheduledTasks(ctx context.Context, messagePayload map[string]inte
log.Warn().Msgf("Unknown node type %s for compliance scan", nodeType)
return nil
}
_, _, err := handler.StartMultiCloudComplianceScan(ctx, nodeIds, benchmarkTypes, false)
cloudNodeIds, err := reportersScan.GetCloudAccountIDs(ctx, nodeIds, nil)
if err != nil {
log.Error().Msgf("Failed to resolve cloud accounts, error:%v", err)
return err
}
_, _, err = handler.StartMultiCloudComplianceScan(ctx, cloudNodeIds, benchmarkTypes, false)
if err != nil {
return err
}
Expand Down Expand Up @@ -237,7 +243,12 @@ func runCustomScheduledTasks(ctx context.Context, messagePayload map[string]inte
log.Warn().Msgf("Invalid benchmarkType for compliance scan, job id: %d", scheduleJobId)
return nil
}
_, _, err := handler.StartMultiCloudComplianceScan(ctx, nodeIds, model.BenchmarkTypeToArray(payload.BenchmarkTypes), false)
cloudNodeIds, err := reportersScan.GetCloudAccountIDs(ctx, nodeIds, nil)
if err != nil {
log.Error().Msgf("Failed to resolve cloud accounts, error:%v", err)
return err
}
_, _, err = handler.StartMultiCloudComplianceScan(ctx, cloudNodeIds, model.BenchmarkTypeToArray(payload.BenchmarkTypes), false)
if err != nil {
return err
}
Expand Down