feat: log details on log denies#2813
Conversation
Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #2813 +/- ##
==========================================
+ Coverage 52.73% 52.86% +0.12%
==========================================
Files 132 132
Lines 11629 11632 +3
==========================================
+ Hits 6133 6149 +16
+ Misses 5013 5005 -8
+ Partials 483 478 -5
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
|
Why don't you think |
|
FWIW audit already reports details: gatekeeper/pkg/audit/manager.go Line 1115 in b7230e0 |
| Mutator = "mutator" | ||
| DebugLevel = 2 // r.log.Debug(foo) == r.log.V(logging.DebugLevel).Info(foo) | ||
| ExecutionStats = "execution_stats" | ||
| ViolationMetadata = "violation_metadata" |
There was a problem hiding this comment.
We should be consistent with how audit handles the details field:
gatekeeper/pkg/audit/manager.go
Line 1115 in b7230e0
There was a problem hiding this comment.
Oh I missed that! 🤦🏼
Deduping this comment with the audit logging. I figured that logging the details of the rego evaluations for every object for every audit run would be too noisy. At present, we only log details for a violation in audit so this should be consistent w the audit behavior now:
gatekeeper/pkg/audit/manager.go
Lines 1106 to 1131 in b7230e0
Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
|
@maxsmythe PTAL when you have some time 🙏🏼 ; this is a one liner now hehe |
Co-authored-by: Jaydipkumar Arvindbhai Gabani <gabanijaydip@gmail.com> Signed-off-by: alex <8968914+acpana@users.noreply.github.com>
Smallest of patches to log the details of a violation. I don't think this has a place in
auditbut am open to reconsider.Addresses #2790
Example:
{ "level": "info", "ts": 1685780064.9552832, "logger": "webhook", "msg": "denied admission: All namespaces must have an `owner` label that points to your company username", "hookType": "validation", "process": "admission", "event_type": "violation", "constraint_name": "all-must-have-owner", "constraint_group": "constraints.gatekeeper.sh", "constraint_api_version": "v1beta1", "constraint_kind": "K8sRequiredLabelsOptimized", "constraint_action": "deny", "violation_metadata": { "details": { "missing_labels": [ "owner" ] } }, "resource_group": "", "resource_api_version": "v1", "resource_kind": "Namespace", "resource_namespace": "", "resource_name": "disallowed-namespace", "request_username": "kubernetes-admin" }