Skip to content

Commit

Permalink
Merge pull request #2273 from opengovern/fix-control-summary
Browse files Browse the repository at this point in the history
fix: filter integrations in job summary
  • Loading branch information
artaasadi authored Dec 17, 2024
2 parents 6c3866f + 7efe443 commit cbfe93f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
12 changes: 6 additions & 6 deletions jobs/compliance-summarizer-job/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ func (w *Worker) RunJob(ctx context.Context, j types2.Job) error {
zap.Any("resource", resource))
jd.AddComplianceResult(w.logger, j, f, resource, jobIntegrations)

if f.BenchmarkID == j.BenchmarkID {
if len(jobIntegrations) > 0 {
if _, ok := jobIntegrations[f.IntegrationID]; !ok {
continue
}
}
if f.ComplianceJobID == j.ComplianceJobID {
//if len(jobIntegrations) > 0 {
// if _, ok := jobIntegrations[f.IntegrationID]; !ok {
// continue
// }
//}
addJobSummary(controlSummary, controlView, resourceView, f)
integrationsMap[f.IntegrationID] = true
totalControls[f.ControlID] = true
Expand Down
6 changes: 1 addition & 5 deletions jobs/compliance-summarizer-job/types/job_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ func (jd *JobDocs) AddComplianceResult(logger *zap.Logger, job Job,
}

if job.BenchmarkID == complianceResult.BenchmarkID {
if len(jobIntegrations) == 0 {
jd.BenchmarkSummary.Integrations.addComplianceResult(complianceResult)
} else if _, ok := jobIntegrations[complianceResult.IntegrationID]; ok {
jd.BenchmarkSummary.Integrations.addComplianceResult(complianceResult)
}
jd.BenchmarkSummary.Integrations.addComplianceResult(complianceResult)
}

var platformResourceID, resourceType, resourceName string
Expand Down
12 changes: 3 additions & 9 deletions services/compliance/http_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7677,9 +7677,7 @@ func (h HttpHandler) GetQuickScanSummary(c echo.Context) error {
h.logger.Error("failed to get compliance job", zap.Error(err))
return echo.NewHTTPError(http.StatusInternalServerError, "failed to get compliance job")
}
if complianceJob.JobStatus == string(schedulerapi.ComplianceJobFailed) {
return echo.NewHTTPError(http.StatusBadRequest, "job has been failed")
} else if complianceJob.JobStatus == string(schedulerapi.ComplianceJobTimeout) {
if complianceJob.JobStatus == string(schedulerapi.ComplianceJobTimeout) {
return echo.NewHTTPError(http.StatusBadRequest, "job has been timed out")
} else if complianceJob.JobStatus == string(schedulerapi.ComplianceJobRunnersInProgress) ||
complianceJob.JobStatus == string(schedulerapi.ComplianceJobCreated) ||
Expand Down Expand Up @@ -7868,9 +7866,7 @@ func (h HttpHandler) GetComplianceJobReport(c echo.Context) error {
h.logger.Error("failed to get compliance job", zap.Error(err))
return echo.NewHTTPError(http.StatusInternalServerError, "failed to get compliance job")
}
if complianceJob.JobStatus == string(schedulerapi.ComplianceJobFailed) {
return echo.NewHTTPError(http.StatusBadRequest, "job has been failed")
} else if complianceJob.JobStatus == string(schedulerapi.ComplianceJobTimeout) {
if complianceJob.JobStatus == string(schedulerapi.ComplianceJobTimeout) {
return echo.NewHTTPError(http.StatusBadRequest, "job has been timed out")
} else if complianceJob.JobStatus == string(schedulerapi.ComplianceJobRunnersInProgress) ||
complianceJob.JobStatus == string(schedulerapi.ComplianceJobCreated) ||
Expand Down Expand Up @@ -7918,9 +7914,7 @@ func (h HttpHandler) GetJobReportSummary(ctx echo.Context) error {
h.logger.Error("failed to get compliance job", zap.Error(err))
return echo.NewHTTPError(http.StatusInternalServerError, "failed to get compliance job")
}
if complianceJob.JobStatus == string(schedulerapi.ComplianceJobFailed) {
return echo.NewHTTPError(http.StatusBadRequest, "job has been failed")
} else if complianceJob.JobStatus == string(schedulerapi.ComplianceJobTimeout) {
if complianceJob.JobStatus == string(schedulerapi.ComplianceJobTimeout) {
return echo.NewHTTPError(http.StatusBadRequest, "job has been timed out")
} else if complianceJob.JobStatus == string(schedulerapi.ComplianceJobRunnersInProgress) ||
complianceJob.JobStatus == string(schedulerapi.ComplianceJobCreated) ||
Expand Down

0 comments on commit cbfe93f

Please sign in to comment.