Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
3487e518
Unverified
Commit
3487e518
authored
May 04, 2020
by
Ryan McKinley
Committed by
GitHub
May 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Signing: allow unsigned plugin in dev mode (#24242)
parent
83683d87
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
19 deletions
+28
-19
pkg/plugins/plugins.go
+25
-19
pkg/plugins/plugins_test.go
+3
-0
No files found.
pkg/plugins/plugins.go
View file @
3487e518
...
@@ -282,26 +282,32 @@ func (scanner *PluginScanner) loadPlugin(pluginJsonFilePath string) error {
...
@@ -282,26 +282,32 @@ func (scanner *PluginScanner) loadPlugin(pluginJsonFilePath string) error {
pluginCommon
.
PluginDir
=
filepath
.
Dir
(
pluginJsonFilePath
)
pluginCommon
.
PluginDir
=
filepath
.
Dir
(
pluginJsonFilePath
)
// For the time being, we choose to only require back-end plugins to be signed
// For the time being, we choose to only require back-end plugins to be signed
// NOTE: the state is calculated again for when setting metadata on the object
if
pluginCommon
.
Backend
&&
scanner
.
requireSigned
{
if
pluginCommon
.
Backend
&&
scanner
.
requireSigned
{
scanner
.
log
.
Debug
(
"Plugin signature required, validating"
,
"pluginID"
,
pluginCommon
.
Id
,
sig
:=
GetPluginSignatureState
(
&
pluginCommon
)
"pluginDir"
,
pluginCommon
.
PluginDir
)
if
sig
!=
PluginSignatureValid
{
allowUnsigned
:=
false
scanner
.
log
.
Debug
(
"Invalid Plugin Signature"
,
"pluginID"
,
pluginCommon
.
Id
,
"pluginDir"
,
pluginCommon
.
PluginDir
,
"state"
,
sig
)
for
_
,
plug
:=
range
scanner
.
cfg
.
PluginsAllowUnsigned
{
if
sig
==
PluginSignatureUnsigned
{
if
plug
==
pluginCommon
.
Id
{
allowUnsigned
:=
false
allowUnsigned
=
true
for
_
,
plug
:=
range
scanner
.
cfg
.
PluginsAllowUnsigned
{
break
if
plug
==
pluginCommon
.
Id
{
}
allowUnsigned
=
true
}
break
if
sig
:=
GetPluginSignatureState
(
&
pluginCommon
);
sig
!=
PluginSignatureValid
&&
!
allowUnsigned
{
}
switch
sig
{
}
case
PluginSignatureUnsigned
:
if
setting
.
Env
!=
setting
.
DEV
&&
!
allowUnsigned
{
return
fmt
.
Errorf
(
"plugin %q is unsigned"
,
pluginCommon
.
Id
)
return
fmt
.
Errorf
(
"plugin %q is unsigned"
,
pluginCommon
.
Id
)
case
PluginSignatureInvalid
:
}
return
fmt
.
Errorf
(
"plugin %q has an invalid signature"
,
pluginCommon
.
Id
)
scanner
.
log
.
Warn
(
"Running an unsigned backend plugin"
,
"pluginID"
,
pluginCommon
.
Id
,
"pluginDir"
,
pluginCommon
.
PluginDir
)
case
PluginSignatureModified
:
}
else
{
return
fmt
.
Errorf
(
"plugin %q's signature has been modified"
,
pluginCommon
.
Id
)
switch
sig
{
default
:
case
PluginSignatureInvalid
:
return
fmt
.
Errorf
(
"unrecognized plugin signature state %v"
,
sig
)
return
fmt
.
Errorf
(
"plugin %q has an invalid signature"
,
pluginCommon
.
Id
)
case
PluginSignatureModified
:
return
fmt
.
Errorf
(
"plugin %q's signature has been modified"
,
pluginCommon
.
Id
)
default
:
return
fmt
.
Errorf
(
"unrecognized plugin signature state %v"
,
sig
)
}
}
}
}
}
}
}
...
...
pkg/plugins/plugins_test.go
View file @
3487e518
...
@@ -18,15 +18,18 @@ import (
...
@@ -18,15 +18,18 @@ import (
func
TestPluginManager_Init
(
t
*
testing
.
T
)
{
func
TestPluginManager_Init
(
t
*
testing
.
T
)
{
origRootPath
:=
setting
.
StaticRootPath
origRootPath
:=
setting
.
StaticRootPath
origRaw
:=
setting
.
Raw
origRaw
:=
setting
.
Raw
origEnv
:=
setting
.
Env
t
.
Cleanup
(
func
()
{
t
.
Cleanup
(
func
()
{
setting
.
StaticRootPath
=
origRootPath
setting
.
StaticRootPath
=
origRootPath
setting
.
Raw
=
origRaw
setting
.
Raw
=
origRaw
setting
.
Env
=
origEnv
})
})
var
err
error
var
err
error
setting
.
StaticRootPath
,
err
=
filepath
.
Abs
(
"../../public/"
)
setting
.
StaticRootPath
,
err
=
filepath
.
Abs
(
"../../public/"
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
setting
.
Raw
=
ini
.
Empty
()
setting
.
Raw
=
ini
.
Empty
()
setting
.
Env
=
setting
.
PROD
t
.
Run
(
"Base case"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"Base case"
,
func
(
t
*
testing
.
T
)
{
pm
:=
&
PluginManager
{
pm
:=
&
PluginManager
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment