Skip to content

Commit

Permalink
Scheduled scans - resolve cloud accounts in an organization (#2391)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramanan-ravi authored Dec 11, 2024
1 parent e3f014e commit ef43f0d
Showing 1 changed file with 13 additions and 2 deletions.
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

0 comments on commit ef43f0d

Please sign in to comment.