[MM-64686] Expose audit logging functionality via plugin API (#31204)
This commit exposes audit logging functionality to plugins via the plugin API, allowing plugins to create and log audit records. Additionally, it addresses a gob encoding issue that could cause plugin crashes when audit data contains nil pointers or unregistered types.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
efb960a160
Коммит
aaa62a40ae
@@ -6,9 +6,12 @@ package audit
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||
)
|
||||
|
||||
const DefMaxQueueSize = 1000
|
||||
|
||||
type Audit struct {
|
||||
logger *mlog.Logger
|
||||
|
||||
@@ -30,14 +33,14 @@ func (a *Audit) Init(maxQueueSize int) {
|
||||
}
|
||||
|
||||
// LogRecord emits an audit record with complete info.
|
||||
func (a *Audit) LogRecord(level mlog.Level, rec Record) {
|
||||
func (a *Audit) LogRecord(level mlog.Level, rec model.AuditRecord) {
|
||||
flds := []mlog.Field{
|
||||
mlog.String(KeyEventName, rec.EventName),
|
||||
mlog.String(KeyStatus, rec.Status),
|
||||
mlog.Any(KeyActor, rec.Actor),
|
||||
mlog.Any(KeyEvent, rec.EventData),
|
||||
mlog.Any(KeyMeta, rec.Meta),
|
||||
mlog.Any(KeyError, rec.Error),
|
||||
mlog.String(model.AuditKeyEventName, rec.EventName),
|
||||
mlog.String(model.AuditKeyStatus, rec.Status),
|
||||
mlog.Any(model.AuditKeyActor, rec.Actor),
|
||||
mlog.Any(model.AuditKeyEvent, rec.EventData),
|
||||
mlog.Any(model.AuditKeyMeta, rec.Meta),
|
||||
mlog.Any(model.AuditKeyError, rec.Error),
|
||||
}
|
||||
|
||||
a.logger.Log(level, "", flds...)
|
||||
|
||||
Ссылка в новой задаче
Block a user