mirror of
https://github.com/kyverno/policy-reporter.git
synced 2024-12-14 11:57:32 +00:00
commit
471f36132b
6 changed files with 14 additions and 9 deletions
|
@ -1,5 +1,9 @@
|
|||
# Changelog
|
||||
|
||||
# 2.7.1
|
||||
* Policy Reporter
|
||||
* Add Resource APIVersion to the Results REST APIs
|
||||
|
||||
# 2.7.0
|
||||
* Policy Reporter
|
||||
* PolicyReport Filter:
|
||||
|
|
|
@ -5,8 +5,8 @@ description: |
|
|||
It creates Prometheus Metrics and can send rule validation events to different targets like Loki, Elasticsearch, Slack or Discord
|
||||
|
||||
type: application
|
||||
version: 2.7.0
|
||||
appVersion: 2.4.0
|
||||
version: 2.7.1
|
||||
appVersion: 2.4.1
|
||||
|
||||
icon: https://github.com/kyverno/kyverno/raw/main/img/logo.png
|
||||
home: https://kyverno.github.io/policy-reporter
|
||||
|
|
|
@ -2,7 +2,7 @@ image:
|
|||
registry: ghcr.io
|
||||
repository: kyverno/policy-reporter
|
||||
pullPolicy: IfNotPresent
|
||||
tag: 2.4.0
|
||||
tag: 2.4.1
|
||||
|
||||
imagePullSecrets: []
|
||||
|
||||
|
|
|
@ -396,7 +396,7 @@ func Test_V1_API(t *testing.T) {
|
|||
t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusOK)
|
||||
}
|
||||
|
||||
expected := `[{"id":"123","namespace":"test","kind":"Deployment","name":"nginx","message":"validation error: requests and limits required. Rule autogen-check-for-requests-and-limits failed at path /spec/template/spec/containers/0/resources/requests/","category":"Best Practices","policy":"require-requests-and-limits-required","rule":"autogen-check-for-requests-and-limits","status":"fail","severity":"high"},{"id":"124","namespace":"test","kind":"Pod","name":"nginx","message":"validation error: requests and limits required. Rule autogen-check-for-requests-and-limits failed at path /spec/template/spec/containers/0/resources/requests/","category":"Best Practices","policy":"require-requests-and-limits-required","rule":"autogen-check-for-requests-and-limits","status":"pass"}]`
|
||||
expected := `[{"id":"123","namespace":"test","kind":"Deployment","apiVersion":"v1","name":"nginx","message":"validation error: requests and limits required. Rule autogen-check-for-requests-and-limits failed at path /spec/template/spec/containers/0/resources/requests/","category":"Best Practices","policy":"require-requests-and-limits-required","rule":"autogen-check-for-requests-and-limits","status":"fail","severity":"high"},{"id":"124","namespace":"test","kind":"Pod","apiVersion":"v1","name":"nginx","message":"validation error: requests and limits required. Rule autogen-check-for-requests-and-limits failed at path /spec/template/spec/containers/0/resources/requests/","category":"Best Practices","policy":"require-requests-and-limits-required","rule":"autogen-check-for-requests-and-limits","status":"pass"}]`
|
||||
if !strings.Contains(rr.Body.String(), expected) {
|
||||
t.Errorf("handler returned unexpected body: got %v want %v", rr.Body.String(), expected)
|
||||
}
|
||||
|
@ -416,7 +416,7 @@ func Test_V1_API(t *testing.T) {
|
|||
t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusOK)
|
||||
}
|
||||
|
||||
expected := "{\"id\":\"125\",\"kind\":\"Namespace\",\"name\":\"test\",\"message\":\"validation error: The label `test` is required. Rule check-for-labels-on-namespace\",\"category\":\"Convention\",\"policy\":\"require-ns-labels\",\"rule\":\"check-for-labels-on-namespace\",\"status\":\"pass\",\"severity\":\"medium\"}"
|
||||
expected := "{\"id\":\"125\",\"kind\":\"Namespace\",\"apiVersion\":\"v1\",\"name\":\"test\",\"message\":\"validation error: The label `test` is required. Rule check-for-labels-on-namespace\",\"category\":\"Convention\",\"policy\":\"require-ns-labels\",\"rule\":\"check-for-labels-on-namespace\",\"status\":\"pass\",\"severity\":\"medium\"}"
|
||||
if !strings.Contains(rr.Body.String(), expected) {
|
||||
t.Errorf("handler returned unexpected body: got %v want %v", rr.Body.String(), expected)
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ type ListResult struct {
|
|||
ID string `json:"id"`
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
Kind string `json:"kind"`
|
||||
APIVersion string `json:"apiVersion"`
|
||||
Name string `json:"name"`
|
||||
Message string `json:"message"`
|
||||
Category string `json:"category,omitempty"`
|
||||
|
|
|
@ -607,7 +607,7 @@ func (s *policyReportStore) FetchNamespacedResults(filter api.Filter) ([]*api.Li
|
|||
}
|
||||
|
||||
rows, err := s.db.Query(`
|
||||
SELECT id, resource_namespace, resource_kind, resource_name, message, policy, rule, severity, properties, status, category
|
||||
SELECT id, resource_namespace, resource_kind, resource_api_version, resource_name, message, policy, rule, severity, properties, status, category
|
||||
FROM policy_report_result WHERE resource_namespace != ""`+where+`
|
||||
ORDER BY resource_namespace, resource_name, resource_uid ASC`, args...)
|
||||
|
||||
|
@ -619,7 +619,7 @@ func (s *policyReportStore) FetchNamespacedResults(filter api.Filter) ([]*api.Li
|
|||
result := api.ListResult{}
|
||||
var props []byte
|
||||
|
||||
err := rows.Scan(&result.ID, &result.Namespace, &result.Kind, &result.Name, &result.Message, &result.Policy, &result.Rule, &result.Severity, &props, &result.Status, &result.Category)
|
||||
err := rows.Scan(&result.ID, &result.Namespace, &result.Kind, &result.APIVersion, &result.Name, &result.Message, &result.Policy, &result.Rule, &result.Severity, &props, &result.Status, &result.Category)
|
||||
if err != nil {
|
||||
return list, err
|
||||
}
|
||||
|
@ -641,7 +641,7 @@ func (s *policyReportStore) FetchClusterResults(filter api.Filter) ([]*api.ListR
|
|||
}
|
||||
|
||||
rows, err := s.db.Query(`
|
||||
SELECT id, resource_namespace, resource_kind, resource_name, message, policy, rule, severity, properties, status, category
|
||||
SELECT id, resource_namespace, resource_kind, resource_api_version, resource_name, message, policy, rule, severity, properties, status, category
|
||||
FROM policy_report_result WHERE resource_namespace =""`+where+`
|
||||
ORDER BY resource_namespace, resource_name, resource_uid ASC`, args...)
|
||||
|
||||
|
@ -653,7 +653,7 @@ func (s *policyReportStore) FetchClusterResults(filter api.Filter) ([]*api.ListR
|
|||
result := api.ListResult{}
|
||||
var props []byte
|
||||
|
||||
err := rows.Scan(&result.ID, &result.Namespace, &result.Kind, &result.Name, &result.Message, &result.Policy, &result.Rule, &result.Severity, &props, &result.Status, &result.Category)
|
||||
err := rows.Scan(&result.ID, &result.Namespace, &result.Kind, &result.APIVersion, &result.Name, &result.Message, &result.Policy, &result.Rule, &result.Severity, &props, &result.Status, &result.Category)
|
||||
if err != nil {
|
||||
return list, err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue