Cherry-pick MM-66789: Restrict log downloads to a root path for support packets (#35164)
Automatic Merge
Этот коммит содержится в:
@@ -106,7 +106,14 @@ func setupTestHelper(tb testing.TB, dbStore store.Store, sqlSettings *model.SqlS
|
||||
consoleLevel = mlog.LvlStdLog.Name
|
||||
}
|
||||
*memoryConfig.LogSettings.ConsoleLevel = consoleLevel
|
||||
*memoryConfig.LogSettings.FileLocation = filepath.Join(tempWorkspace, "logs", "mattermost.log")
|
||||
// Use a subdirectory within the logging root (from MM_LOG_PATH or default)
|
||||
// to ensure the path is within the allowed logging root for security validation.
|
||||
// Each test gets its own subdirectory based on the tempWorkspace name for isolation.
|
||||
testLogsDir := filepath.Join(config.GetLogRootPath(), filepath.Base(tempWorkspace))
|
||||
err = os.MkdirAll(testLogsDir, 0700)
|
||||
require.NoError(tb, err, "failed to create test logs directory")
|
||||
*memoryConfig.LogSettings.FileLocation = testLogsDir
|
||||
*memoryConfig.NotificationLogSettings.FileLocation = testLogsDir
|
||||
*memoryConfig.AnnouncementSettings.AdminNoticesEnabled = false
|
||||
*memoryConfig.AnnouncementSettings.UserNoticesEnabled = false
|
||||
*memoryConfig.PluginSettings.AutomaticPrepackagedPlugins = false
|
||||
|
||||
@@ -88,6 +88,9 @@ func generateSupportPacket(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
auditRec := c.MakeAuditRecord(model.AuditEventGenerateSupportPacket, model.AuditStatusFail)
|
||||
defer c.LogAuditRec(auditRec)
|
||||
|
||||
// We support the existing API hence the logs are always included
|
||||
// if nothing specified.
|
||||
includeLogs := true
|
||||
@@ -99,6 +102,9 @@ func generateSupportPacket(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
PluginPackets: r.Form["plugin_packets"],
|
||||
}
|
||||
|
||||
auditRec.AddMeta("include_logs", supportPacketOptions.IncludeLogs)
|
||||
auditRec.AddMeta("plugin_packets", supportPacketOptions.PluginPackets)
|
||||
|
||||
// Checking to see if the server has a e10 or e20 license (this feature is only permitted for servers with licenses)
|
||||
if c.App.Channels().License() == nil {
|
||||
c.Err = model.NewAppError("Api4.generateSupportPacket", "api.no_license", nil, "", http.StatusForbidden)
|
||||
@@ -132,6 +138,9 @@ func generateSupportPacket(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
fileBytesReader := bytes.NewReader(fileBytes)
|
||||
|
||||
auditRec.Success()
|
||||
auditRec.AddMeta("filename", outputZipFilename)
|
||||
|
||||
// Prevent caching so support packets are always fresh
|
||||
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user