Plugins: Ignore symlinked folders when verifying plugin signature (#34434)
* add check + test * fix test * add manifest * fix linter * add nolint * separate err cond checks * only collect relevant plugin files * skip symlinks * refactor * add missing test files + enable scanning Chromium.app/ * remove test since case already covered * remove unnecessary changes from before * refactor * remove comment
This commit is contained in:
@@ -371,7 +371,7 @@ func TestPluginManager_Init(t *testing.T) {
|
||||
assert.Nil(t, pm.plugins[("test")])
|
||||
})
|
||||
|
||||
t.Run("With back-end plugin with a lib dir that has symbolic links", func(t *testing.T) {
|
||||
t.Run("With plugin that contains symlink file + directory", func(t *testing.T) {
|
||||
origAppURL := setting.AppUrl
|
||||
t.Cleanup(func() {
|
||||
setting.AppUrl = origAppURL
|
||||
@@ -379,23 +379,25 @@ func TestPluginManager_Init(t *testing.T) {
|
||||
setting.AppUrl = defaultAppURL
|
||||
|
||||
pm := createManager(t, func(pm *PluginManager) {
|
||||
pm.Cfg.PluginsPath = "testdata/symbolic-file-links"
|
||||
pm.Cfg.PluginsPath = "testdata/includes-symlinks"
|
||||
})
|
||||
err := pm.Init()
|
||||
require.NoError(t, err)
|
||||
// This plugin should be properly registered, even though it has a symbolicly linked file in it.
|
||||
require.Empty(t, pm.scanningErrors)
|
||||
const pluginID = "test"
|
||||
assert.NotNil(t, pm.plugins[pluginID])
|
||||
assert.Equal(t, "datasource", pm.plugins[pluginID].Type)
|
||||
assert.Equal(t, "Test", pm.plugins[pluginID].Name)
|
||||
assert.Equal(t, pluginID, pm.plugins[pluginID].Id)
|
||||
assert.Equal(t, "1.0.0", pm.plugins[pluginID].Info.Version)
|
||||
assert.Equal(t, plugins.PluginSignatureValid, pm.plugins[pluginID].Signature)
|
||||
assert.Equal(t, plugins.GrafanaType, pm.plugins[pluginID].SignatureType)
|
||||
assert.Equal(t, "Grafana Labs", pm.plugins[pluginID].SignatureOrg)
|
||||
assert.False(t, pm.plugins[pluginID].IsCorePlugin)
|
||||
assert.NotNil(t, pm.plugins[("test")])
|
||||
|
||||
const pluginID = "test-app"
|
||||
p := pm.GetPlugin(pluginID)
|
||||
|
||||
assert.NotNil(t, p)
|
||||
assert.NotNil(t, pm.GetApp(pluginID))
|
||||
assert.Equal(t, pluginID, p.Id)
|
||||
assert.Equal(t, "app", p.Type)
|
||||
assert.Equal(t, "Test App", p.Name)
|
||||
assert.Equal(t, "1.0.0", p.Info.Version)
|
||||
assert.Equal(t, plugins.PluginSignatureValid, p.Signature)
|
||||
assert.Equal(t, plugins.GrafanaType, p.SignatureType)
|
||||
assert.Equal(t, "Grafana Labs", p.SignatureOrg)
|
||||
assert.False(t, p.IsCorePlugin)
|
||||
})
|
||||
|
||||
t.Run("With back-end plugin that is symlinked to plugins dir", func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user