Doug Lauder
2023-03-22 17:22:27 -04:00
коммит произвёл GitHub
родитель b61c096497
Коммит c943ed6859
13276 изменённых файлов: 1695615 добавлений и 223189 удалений

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

@@ -11,7 +11,7 @@ import (
"net/http"
timePkg "time"
"github.com/mattermost/mattermost-server/v6/einterfaces"
"github.com/mattermost/mattermost-server/v6/server/channels/einterfaces"
"github.com/mattermost/mattermost-server/v6/model"
)

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

@@ -25,7 +25,7 @@ import (
"github.com/lib/pq"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/shared/mlog"
"github.com/mattermost/mattermost-server/v6/server/platform/shared/mlog"
)
var hookNameToId map[string]int = make(map[string]int)

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

@@ -11,7 +11,7 @@ import (
"log"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/shared/mlog"
"github.com/mattermost/mattermost-server/v6/server/platform/shared/mlog"
)
func init() {

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

@@ -15,10 +15,10 @@ import (
"github.com/pkg/errors"
"github.com/mattermost/mattermost-server/v6/einterfaces"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/shared/mlog"
"github.com/mattermost/mattermost-server/v6/utils"
"github.com/mattermost/mattermost-server/v6/server/channels/einterfaces"
"github.com/mattermost/mattermost-server/v6/server/channels/utils"
"github.com/mattermost/mattermost-server/v6/server/platform/shared/mlog"
)
var ErrNotFound = errors.New("Item not found")
@@ -109,9 +109,36 @@ func scanSearchPath(path string) ([]*model.BundleInfo, error) {
return ret, nil
}
var pluginIDBlocklist = map[string]bool{
"playbooks": true,
"com.mattermost.plugin-incident-response": true,
"com.mattermost.plugin-incident-management": true,
"focalboard": true,
}
func PluginIDIsBlocked(id string) bool {
_, ok := pluginIDBlocklist[id]
return ok
}
// Returns a list of all plugins within the environment.
func (env *Environment) Available() ([]*model.BundleInfo, error) {
return scanSearchPath(env.pluginDir)
rawList, err := scanSearchPath(env.pluginDir)
if err != nil {
return nil, err
}
// Filter any plugins that match the blocklist
filteredList := make([]*model.BundleInfo, 0, len(rawList))
for _, bundleInfo := range rawList {
if PluginIDIsBlocked(bundleInfo.Manifest.Id) {
env.logger.Debug("Plugin ignored by blocklist", mlog.String("plugin_id", bundleInfo.Manifest.Id))
} else {
filteredList = append(filteredList, bundleInfo)
}
}
return filteredList, nil
}
// Returns a list of prepackaged plugins available in the local prepackaged_plugins folder.

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

@@ -12,6 +12,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/server/platform/shared/mlog"
)
func TestAvailablePlugins(t *testing.T) {
@@ -21,8 +22,10 @@ func TestAvailablePlugins(t *testing.T) {
os.RemoveAll(dir)
})
testLogger, _ := mlog.NewLogger()
env := Environment{
pluginDir: dir,
logger: testLogger,
}
t.Run("Should be able to load available plugins", func(t *testing.T) {
@@ -70,4 +73,26 @@ func TestAvailablePlugins(t *testing.T) {
require.NoError(t, err)
require.Len(t, bundles, 0)
})
t.Run("Should not load bundles on blocklist", func(t *testing.T) {
bundle := model.BundleInfo{
Manifest: &model.Manifest{
Id: "playbooks",
Version: "1",
},
}
err := os.Mkdir(filepath.Join(dir, "plugin4"), 0700)
require.NoError(t, err)
defer os.RemoveAll(filepath.Join(dir, "plugin4"))
path := filepath.Join(dir, "plugin4", "plugin.json")
manifestJSON, jsonErr := json.Marshal(bundle.Manifest)
require.NoError(t, jsonErr)
err = os.WriteFile(path, manifestJSON, 0644)
require.NoError(t, err)
bundles, err := env.Available()
require.NoError(t, err)
require.Len(t, bundles, 0)
})
}

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

@@ -11,7 +11,7 @@ import (
"github.com/hashicorp/go-hclog"
"github.com/mattermost/mattermost-server/v6/shared/mlog"
"github.com/mattermost/mattermost-server/v6/server/platform/shared/mlog"
)
type hclogAdapter struct {

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

@@ -8,7 +8,7 @@ import (
"time"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/shared/mlog"
"github.com/mattermost/mattermost-server/v6/server/platform/shared/mlog"
)
const (

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

@@ -12,8 +12,8 @@ import (
"github.com/stretchr/testify/require"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/shared/mlog"
"github.com/mattermost/mattermost-server/v6/utils"
"github.com/mattermost/mattermost-server/v6/server/channels/utils"
"github.com/mattermost/mattermost-server/v6/server/platform/shared/mlog"
)
func TestPluginHealthCheck(t *testing.T) {

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

@@ -11,7 +11,7 @@ import (
"net/http"
timePkg "time"
"github.com/mattermost/mattermost-server/v6/einterfaces"
"github.com/mattermost/mattermost-server/v6/server/channels/einterfaces"
"github.com/mattermost/mattermost-server/v6/model"
)

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

@@ -12,7 +12,7 @@ import (
"net/http"
"net/rpc"
"github.com/mattermost/mattermost-server/v6/shared/mlog"
"github.com/mattermost/mattermost-server/v6/server/platform/shared/mlog"
)
type hijackedResponse struct {

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

@@ -453,7 +453,7 @@ import (
"net/http"
timePkg "time"
"github.com/mattermost/mattermost-server/v6/einterfaces"
"github.com/mattermost/mattermost-server/v6/server/channels/einterfaces"
"github.com/mattermost/mattermost-server/v6/model"
)
@@ -495,7 +495,7 @@ import (
"net/http"
timePkg "time"
"github.com/mattermost/mattermost-server/v6/einterfaces"
"github.com/mattermost/mattermost-server/v6/server/channels/einterfaces"
"github.com/mattermost/mattermost-server/v6/model"
)

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

@@ -6,8 +6,8 @@ package scheduler
import (
"time"
"github.com/mattermost/mattermost-server/v6/jobs"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/server/channels/jobs"
)
const schedFreq = 24 * time.Hour

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

@@ -4,9 +4,9 @@
package scheduler
import (
"github.com/mattermost/mattermost-server/v6/jobs"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/shared/mlog"
"github.com/mattermost/mattermost-server/v6/server/channels/jobs"
"github.com/mattermost/mattermost-server/v6/server/platform/shared/mlog"
)
type AppIface interface {

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

@@ -18,9 +18,9 @@ import (
plugin "github.com/hashicorp/go-plugin"
"github.com/pkg/errors"
"github.com/mattermost/mattermost-server/v6/einterfaces"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/shared/mlog"
"github.com/mattermost/mattermost-server/v6/server/channels/einterfaces"
"github.com/mattermost/mattermost-server/v6/server/platform/shared/mlog"
)
type supervisor struct {

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

@@ -12,8 +12,8 @@ import (
"github.com/stretchr/testify/require"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/shared/mlog"
"github.com/mattermost/mattermost-server/v6/utils"
"github.com/mattermost/mattermost-server/v6/server/channels/utils"
"github.com/mattermost/mattermost-server/v6/server/platform/shared/mlog"
)
func TestSupervisor(t *testing.T) {