mirror of
https://github.com/grafana/grafana.git
synced 2025-02-03 12:11:09 -06:00
Chore: Adding debug logging to signature checks (#86915)
Adding debug logging to signature checks
This commit is contained in:
parent
18c4bee18e
commit
ed89354eaa
@ -169,6 +169,7 @@ func (s *Signature) Calculate(ctx context.Context, src plugins.PluginSource, plu
|
||||
|
||||
// Make sure the versions all match
|
||||
if manifest.Plugin != plugin.JSONData.ID || manifest.Version != plugin.JSONData.Info.Version {
|
||||
s.log.Debug("Plugin signature invalid because ID or Version mismatch", "pluginId", plugin.JSONData.ID, "manifestPluginId", manifest.Plugin, "pluginVersion", plugin.JSONData.Info.Version, "manifestPluginVersion", manifest.Version)
|
||||
return plugins.Signature{
|
||||
Status: plugins.SignatureStatusModified,
|
||||
}, nil
|
||||
@ -194,6 +195,7 @@ func (s *Signature) Calculate(ctx context.Context, src plugins.PluginSource, plu
|
||||
for p, hash := range manifest.Files {
|
||||
err = verifyHash(s.log, plugin, p, hash)
|
||||
if err != nil {
|
||||
s.log.Debug("Plugin signature invalid", "pluginId", plugin.JSONData.ID, "error", err)
|
||||
return plugins.Signature{
|
||||
Status: plugins.SignatureStatusModified,
|
||||
}, nil
|
||||
@ -259,7 +261,7 @@ func verifyHash(mlog log.Logger, plugin plugins.FoundPlugin, path, hash string)
|
||||
|
||||
h := sha256.New()
|
||||
if _, err := io.Copy(h, f); err != nil {
|
||||
return errors.New("could not calculate plugin file checksum")
|
||||
return fmt.Errorf("could not calculate plugin file checksum. Path: %s. Error: %w", path, err)
|
||||
}
|
||||
sum := hex.EncodeToString(h.Sum(nil))
|
||||
if sum != hash {
|
||||
|
Loading…
Reference in New Issue
Block a user