[release-10.11] MM-69010: Validate incoming webhook user membership (#36917)
Automatic Merge
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
beaa59db54
Коммит
f6d3a7827e
@@ -64,11 +64,18 @@ func createIncomingHook(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if _, err = c.App.GetUser(hook.UserId); err != nil {
|
||||
var hookUser *model.User
|
||||
if hookUser, err = c.App.GetUser(hook.UserId); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
|
||||
if appErr := c.App.ValidateIncomingWebhookUser(c.AppContext, *c.AppContext.Session(), hookUser, channel); appErr != nil {
|
||||
c.LogAudit("fail - invalid webhook user")
|
||||
c.Err = appErr
|
||||
return
|
||||
}
|
||||
|
||||
userId = hook.UserId
|
||||
}
|
||||
|
||||
@@ -162,6 +169,15 @@ func updateIncomingHook(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
// Moving the hook must not attribute its owner's posts to a channel they cannot access.
|
||||
if updatedHook.ChannelId != oldHook.ChannelId {
|
||||
if appErr := c.App.ValidateIncomingWebhookUserChannelAccess(c.AppContext, oldHook.UserId, channel); appErr != nil {
|
||||
c.LogAudit("fail - invalid webhook user")
|
||||
c.Err = appErr
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
incomingHook, err := c.App.UpdateIncomingWebhook(oldHook, &updatedHook)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
|
||||
Ссылка в новой задаче
Block a user