Manual Cherrypick: Add audits for accessing posts without membership (#31266) (#35022)

Automatic Merge
Этот коммит содержится в:
Daniel Espino García
2026-01-26 11:23:28 +01:00
коммит произвёл GitHub
родитель 12dce033d6
Коммит 21a86506f9
79 изменённых файлов: 1707 добавлений и 1001 удалений

Просмотреть файл

@@ -151,7 +151,8 @@ func (h *permalinkBroadcastHook) Process(msg *platform.HookedWebSocketEvent, web
}
rctx := request.EmptyContext(webConn.Platform.Log())
if !webConn.Suite.HasPermissionToReadChannel(rctx, webConn.UserId, previewChannel) {
ok, isMember := webConn.Suite.HasPermissionToReadChannel(rctx, webConn.UserId, previewChannel)
if !ok {
// Do nothing.
// In this case, the sanitized post is already attached to the ws event.
return nil
@@ -164,6 +165,16 @@ func (h *permalinkBroadcastHook) Process(msg *platform.HookedWebSocketEvent, web
}
msg.Add("post", postJSON)
auditRec := webConn.Suite.MakeAuditRecord(rctx, "websocketPost", model.AuditStatusSuccess)
defer webConn.Suite.LogAuditRec(rctx, auditRec, nil)
model.AddEventParameterToAuditRec(auditRec, "channel_id", previewChannel.Id)
model.AddEventParameterToAuditRec(auditRec, "user_id", webConn.UserId)
model.AddEventParameterToAuditRec(auditRec, "source", "permalinkBroadcastHook")
if !isMember {
model.AddEventParameterToAuditRec(auditRec, "non_channel_member_access", true)
}
return nil
}