1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

fix: panic in background reports (#7332)

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
Charles-Edouard Brétéché 2023-05-30 16:15:47 +02:00 committed by GitHub
parent 7a838de4f1
commit 8ecf829647
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View file

@ -309,9 +309,9 @@ func (c *controller) reconcileReport(
for _, result := range scanner.ScanResource(ctx, *target, nsLabels, policy) {
if result.Error != nil {
return result.Error
} else {
ruleResults = append(ruleResults, reportutils.EngineResponseToReportResults(result.EngineResponse)...)
utils.GenerateEvents(logger, c.eventGen, c.config, result.EngineResponse)
} else if result.EngineResponse != nil {
ruleResults = append(ruleResults, reportutils.EngineResponseToReportResults(*result.EngineResponse)...)
utils.GenerateEvents(logger, c.eventGen, c.config, *result.EngineResponse)
}
}
}

View file

@ -21,7 +21,7 @@ type scanner struct {
}
type ScanResult struct {
EngineResponse engineapi.EngineResponse
EngineResponse *engineapi.EngineResponse
Error error
}
@ -61,11 +61,11 @@ func (s *scanner) ScanResource(ctx context.Context, resource unstructured.Unstru
}
if response == nil {
response = ivResponse
} else {
} else if ivResponse != nil {
response.PolicyResponse.Rules = append(response.PolicyResponse.Rules, ivResponse.PolicyResponse.Rules...)
}
}
results[policy] = ScanResult{*response, multierr.Combine(errors...)}
results[policy] = ScanResult{response, multierr.Combine(errors...)}
}
return results
}