MM-42271: Restrict support packet generation to system admin. (#19726)

Этот коммит содержится в:
mkraft
2022-03-09 11:42:08 -05:00
коммит произвёл GitHub
родитель d543db6186
Коммит 06c2aa70b0
2 изменённых файлов: 9 добавлений и 4 удалений

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

@@ -81,10 +81,9 @@ func generateSupportPacket(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
// Checking to see if the user is a admin of any sort or not
// If they are a admin, they should theoretically have access to one or more of the system console read permissions
if !c.App.SessionHasPermissionToAny(*c.AppContext.Session(), model.SysconsoleReadPermissions) {
c.SetPermissionError(model.SysconsoleReadPermissions...)
// Support packet generation is limited to system admins (MM-42271).
if !c.App.SessionHasPermissionTo(*c.AppContext.Session(), model.PermissionManageSystem) {
c.SetPermissionError(model.PermissionManageSystem)
return
}

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

@@ -222,6 +222,12 @@ func TestGenerateSupportPacket(t *testing.T) {
CheckForbiddenStatus(t, resp)
})
t.Run("As a system role, not system admin", func(t *testing.T) {
_, resp, err := th.SystemManagerClient.GenerateSupportPacket()
require.Error(t, err)
CheckForbiddenStatus(t, resp)
})
t.Run("As a Regular User", func(t *testing.T) {
_, resp, err := th.Client.GenerateSupportPacket()
require.Error(t, err)