-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix audit log reporting for source events and commands #1022
Conversation
You have successfully added a new Trivy configuration |
c2e4fbd
to
65b24ec
Compare
65b24ec
to
f9980f3
Compare
f9980f3
to
6afd6a0
Compare
c958fd2
to
46c64f0
Compare
if reportErr != nil { | ||
d.log.Error(err) | ||
} | ||
}(n) | ||
} | ||
|
||
if err := d.reportAuditEvent(ctx, pluginName, event.RawObject, dispatch.sourceName, dispatch.sourceDisplayName); err != nil { | ||
d.log.Errorf("while reporting audit event for source %q: %s", dispatch.sourceName, err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about d.log.Errorf("while reporting audit event for source %q: %w", dispatch.sourceName, err)
? To not lose error details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is logging, so actually we'll still print just error message. When using %w
, we still have just an error message, but wrapped in a bit odd format: https://go.dev/play/p/nDVTk9L-VPl
So %s
for logging is more readable, and it is used in all over the places 🤔 To get all the stacktrace etc. we'd need to use %v
, but that would make our logs hard to read 😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works great 🚀 Added minor comments, feel free to ignore them if I miss something :)
8bfe26e
to
d6d19f7
Compare
Description
This PR contains various bug fixes and improvements for audit reporting.
Changes proposed in this pull request:
Source event reporting:
Command reporting:
edit
for edit sourcebindings,kubectl
for executors,botkube/kubernetes
for sources)Others
Testing
See other related PRs for testing instructions.