[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
@@ -15,7 +15,6 @@ import (
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/app"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/audit"
|
||||
)
|
||||
|
||||
func (api *API) InitLicense() {
|
||||
@@ -54,7 +53,7 @@ func getClientLicense(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func addLicense(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
auditRec := c.MakeAuditRecord("addLicense", audit.Fail)
|
||||
auditRec := c.MakeAuditRecord("addLicense", model.AuditStatusFail)
|
||||
defer c.LogAuditRec(auditRec)
|
||||
c.LogAudit("attempt")
|
||||
|
||||
@@ -83,7 +82,7 @@ func addLicense(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
fileData := fileArray[0]
|
||||
audit.AddEventParameter(auditRec, "filename", fileData.Filename)
|
||||
model.AddEventParameterToAuditRec(auditRec, "filename", fileData.Filename)
|
||||
|
||||
file, err := fileData.Open()
|
||||
if err != nil {
|
||||
@@ -156,7 +155,7 @@ func addLicense(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func removeLicense(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
auditRec := c.MakeAuditRecord("removeLicense", audit.Fail)
|
||||
auditRec := c.MakeAuditRecord("removeLicense", model.AuditStatusFail)
|
||||
defer c.LogAuditRec(auditRec)
|
||||
c.LogAudit("attempt")
|
||||
|
||||
@@ -177,7 +176,7 @@ func removeLicense(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func requestTrialLicense(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
auditRec := c.MakeAuditRecord("requestTrialLicense", audit.Fail)
|
||||
auditRec := c.MakeAuditRecord("requestTrialLicense", model.AuditStatusFail)
|
||||
defer c.LogAuditRec(auditRec)
|
||||
c.LogAudit("attempt")
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user