plugin

package
v0.0.0-...-8bbb73d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2023 License: GPL-3.0 Imports: 45 Imported by: 0

Documentation

Overview

Package plugin is a generated GoMock package.

Package plugin is a generated GoMock package.

Index

Constants

View Source
const (
	HelloWorldPluginInterfaceName         = PluginInterfaceName("helloworld") // lower-case always
	SecurityPluginInterfaceName           = PluginInterfaceName("security")
	AccountPluginInterfaceName            = PluginInterfaceName("account")
	QLightTokenManagerPluginInterfaceName = PluginInterfaceName("qlighttokenmanager")
)
View Source
const DefaultPublicKeyFile = "gpg.key"

For Cloudsmith, this references to the latest GPG key being setup in the repo

Variables

This section is empty.

Functions

func ReadMultiFormatConfig

func ReadMultiFormatConfig(config interface{}) ([]byte, error)

Types

type CentralClient

type CentralClient struct {
	// contains filtered or unexported fields
}

Central https centralClient communicating with Plugin Central

func NewPluginCentralClient

func NewPluginCentralClient(config *PluginCentralConfiguration) *CentralClient

Create New Central Client

func (*CentralClient) PluginDistribution

func (cc *CentralClient) PluginDistribution(definition *PluginDefinition, outFilePath string) error

retrieve plugin distribution file

func (*CentralClient) PluginSignature

func (cc *CentralClient) PluginSignature(definition *PluginDefinition) ([]byte, error)

retrieve plugin signature

func (*CentralClient) PublicKey

func (cc *CentralClient) PublicKey() ([]byte, error)

Get the public key from central. PublicKeyURI can be relative to the base URL so we need to parse and make sure finally URL is resolved.

type Dialer

type Dialer func(network, addr string) (net.Conn, error)

An adapter function for tls.Dial with CA verification & SSL Pinning support.

type Downloader

type Downloader struct {
	// contains filtered or unexported fields
}

get plugin zip file from local or remote

func NewDownloader

func NewDownloader(pm *PluginManager) *Downloader

func (*Downloader) Download

func (d *Downloader) Download(definition *PluginDefinition) (string, error)

type EnvironmentAwaredValue

type EnvironmentAwaredValue string

support URI format with 'env' scheme during JSON/TOML/TEXT unmarshalling e.g.: env://FOO_VAR means read a string value from FOO_VAR environment variable

func (EnvironmentAwaredValue) String

func (d EnvironmentAwaredValue) String() string

func (*EnvironmentAwaredValue) UnmarshalJSON

func (d *EnvironmentAwaredValue) UnmarshalJSON(data []byte) error

func (*EnvironmentAwaredValue) UnmarshalTOML

func (d *EnvironmentAwaredValue) UnmarshalTOML(data []byte) error

func (*EnvironmentAwaredValue) UnmarshalText

func (d *EnvironmentAwaredValue) UnmarshalText(data []byte) error

type HelloWorldPluginTemplate

type HelloWorldPluginTemplate struct {
	// contains filtered or unexported fields
}

a template that returns the hello world plugin instance

func (HelloWorldPluginTemplate) Config

func (bp HelloWorldPluginTemplate) Config() *PluginDefinition

func (*HelloWorldPluginTemplate) Get

func (HelloWorldPluginTemplate) Info

func (bp HelloWorldPluginTemplate) Info() (PluginInterfaceName, interface{})

func (HelloWorldPluginTemplate) Start

func (bp HelloWorldPluginTemplate) Start() (err error)

func (HelloWorldPluginTemplate) Stop

func (bp HelloWorldPluginTemplate) Stop() error

type LocalVerifier

type LocalVerifier struct {
	PublicKeyPath    string // where to obtain PGP public key
	SignatureBaseDir string // where to obtain plugin signature file
}

Local Implementation of plugin.Verifier

func NewLocalVerifier

func NewLocalVerifier(publicKeyPath string, pluginSignatureBaseDir string) (*LocalVerifier, error)

Build a new LocalVerifier

func (*LocalVerifier) VerifySignature

func (v *LocalVerifier) VerifySignature(definition *PluginDefinition, checksum string) error

Verify a plugin giving its name from Central

type MetaData

type MetaData struct {
	Version    string   `json:"version"`
	Os         string   `json:"os"`
	Arch       string   `json:"arch"`
	EntryPoint string   `json:"entrypoint"`
	Parameters []string `json:"parameters,omitempty"`
}

Plugin-meta.json

type MockPluginManagerInterface

type MockPluginManagerInterface struct {
	// contains filtered or unexported fields
}

MockPluginManagerInterface is a mock of PluginManagerInterface interface.

func NewMockPluginManagerInterface

func NewMockPluginManagerInterface(ctrl *gomock.Controller) *MockPluginManagerInterface

NewMockPluginManagerInterface creates a new mock instance.

func (*MockPluginManagerInterface) APIs

func (m *MockPluginManagerInterface) APIs() []rpc.API

APIs mocks base method.

func (*MockPluginManagerInterface) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockPluginManagerInterface) GetPluginTemplate

func (m *MockPluginManagerInterface) GetPluginTemplate(name PluginInterfaceName, v managedPlugin) error

GetPluginTemplate mocks base method.

func (*MockPluginManagerInterface) IsEnabled

IsEnabled mocks base method.

func (*MockPluginManagerInterface) PluginsInfo

func (m *MockPluginManagerInterface) PluginsInfo() interface{}

PluginsInfo mocks base method.

func (*MockPluginManagerInterface) Reload

Reload mocks base method.

func (*MockPluginManagerInterface) Start

func (m *MockPluginManagerInterface) Start() error

Start mocks base method.

func (*MockPluginManagerInterface) Stop

Stop mocks base method.

type MockPluginManagerInterfaceMockRecorder

type MockPluginManagerInterfaceMockRecorder struct {
	// contains filtered or unexported fields
}

MockPluginManagerInterfaceMockRecorder is the mock recorder for MockPluginManagerInterface.

func (*MockPluginManagerInterfaceMockRecorder) APIs

APIs indicates an expected call of APIs.

func (*MockPluginManagerInterfaceMockRecorder) GetPluginTemplate

func (mr *MockPluginManagerInterfaceMockRecorder) GetPluginTemplate(name, v interface{}) *gomock.Call

GetPluginTemplate indicates an expected call of GetPluginTemplate.

func (*MockPluginManagerInterfaceMockRecorder) IsEnabled

func (mr *MockPluginManagerInterfaceMockRecorder) IsEnabled(name interface{}) *gomock.Call

IsEnabled indicates an expected call of IsEnabled.

func (*MockPluginManagerInterfaceMockRecorder) PluginsInfo

PluginsInfo indicates an expected call of PluginsInfo.

func (*MockPluginManagerInterfaceMockRecorder) Reload

func (mr *MockPluginManagerInterfaceMockRecorder) Reload(name interface{}) *gomock.Call

Reload indicates an expected call of Reload.

func (*MockPluginManagerInterfaceMockRecorder) Start

Start indicates an expected call of Start.

func (*MockPluginManagerInterfaceMockRecorder) Stop

Stop indicates an expected call of Stop.

type MockQLightTokenManagerPluginTemplateInterface

type MockQLightTokenManagerPluginTemplateInterface struct {
	// contains filtered or unexported fields
}

MockQLightTokenManagerPluginTemplateInterface is a mock of QLightTokenManagerPluginTemplateInterface interface.

func NewMockQLightTokenManagerPluginTemplateInterface

func NewMockQLightTokenManagerPluginTemplateInterface(ctrl *gomock.Controller) *MockQLightTokenManagerPluginTemplateInterface

NewMockQLightTokenManagerPluginTemplateInterface creates a new mock instance.

func (*MockQLightTokenManagerPluginTemplateInterface) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockQLightTokenManagerPluginTemplateInterface) Get

Get mocks base method.

func (*MockQLightTokenManagerPluginTemplateInterface) ManagedPlugin

func (m *MockQLightTokenManagerPluginTemplateInterface) ManagedPlugin() managedPlugin

ManagedPlugin mocks base method.

func (*MockQLightTokenManagerPluginTemplateInterface) Start

Start mocks base method.

func (*MockQLightTokenManagerPluginTemplateInterface) Stop

Stop mocks base method.

type MockQLightTokenManagerPluginTemplateInterfaceMockRecorder

type MockQLightTokenManagerPluginTemplateInterfaceMockRecorder struct {
	// contains filtered or unexported fields
}

MockQLightTokenManagerPluginTemplateInterfaceMockRecorder is the mock recorder for MockQLightTokenManagerPluginTemplateInterface.

func (*MockQLightTokenManagerPluginTemplateInterfaceMockRecorder) Get

Get indicates an expected call of Get.

func (*MockQLightTokenManagerPluginTemplateInterfaceMockRecorder) ManagedPlugin

ManagedPlugin indicates an expected call of ManagedPlugin.

func (*MockQLightTokenManagerPluginTemplateInterfaceMockRecorder) Start

Start indicates an expected call of Start.

func (*MockQLightTokenManagerPluginTemplateInterfaceMockRecorder) Stop

Stop indicates an expected call of Stop.

type NonVerifier

type NonVerifier struct {
}

func NewNonVerifier

func NewNonVerifier() *NonVerifier

func (*NonVerifier) VerifySignature

func (*NonVerifier) VerifySignature(definition *PluginDefinition, checksum string) error

type OnlineVerifier

type OnlineVerifier struct {
	// contains filtered or unexported fields
}

Implementation of plugin.Verifier that uses remote server to verify plugins.

func NewOnlineVerifier

func NewOnlineVerifier(centralClient *CentralClient) *OnlineVerifier

func (*OnlineVerifier) VerifySignature

func (v *OnlineVerifier) VerifySignature(definition *PluginDefinition, checksum string) error

Verify a plugin giving its name from Central

type PluginCentralConfiguration

type PluginCentralConfiguration struct {
	// To implement certificate pinning while communicating with PluginCentral
	// if it's empty, we skip cert pinning logic
	CertFingerprint       string `json:"certFingerprint" toml:""`
	BaseURL               string `json:"baseURL" toml:""`
	PublicKeyURI          string `json:"publicKeyURI" toml:""`
	InsecureSkipTLSVerify bool   `json:"insecureSkipTLSVerify" toml:""`

	// URL path template to the plugin distribution file.
	// It uses Golang text template.
	PluginDistPathTemplate string `json:"pluginDistPathTemplate" toml:""`
	// URL path template to the plugin sha256 checksum signature file.
	// It uses Golang text template.
	PluginSigPathTemplate string `json:"pluginSigPathTemplate" toml:""`
}

func (*PluginCentralConfiguration) SetDefaults

func (c *PluginCentralConfiguration) SetDefaults()

populate default values from quorumPluginCentralConfiguration

type PluginDefinition

type PluginDefinition struct {
	Name string `json:"name" toml:""`
	// the semver version of the plugin
	Version Version `json:"version" toml:""`
	// plugin configuration in a form of map/slice/string
	Config interface{} `json:"config,omitempty" toml:",omitempty"`
}

This is to describe a plugin

Information is used to discover the plugin binary and verify its integrity before forking a process running the plugin

func (*PluginDefinition) DistFileName

func (m *PluginDefinition) DistFileName() string

return plugin distribution file name stored locally

func (*PluginDefinition) FullName

func (m *PluginDefinition) FullName() string

return plugin distribution name. i.e.: <Name>-<Version>-<OS>-<Arch>

func (*PluginDefinition) SignatureFileName

func (m *PluginDefinition) SignatureFileName() string

return plugin distribution signature file name stored locally

type PluginInterfaceName

type PluginInterfaceName string

must be always be lowercase when define constants as when unmarshaling from config, value will be case-lowered

func (PluginInterfaceName) String

func (p PluginInterfaceName) String() string

func (*PluginInterfaceName) UnmarshalJSON

func (p *PluginInterfaceName) UnmarshalJSON(data []byte) error

When this is used as a key in map. This function is not invoked.

func (*PluginInterfaceName) UnmarshalTOML

func (p *PluginInterfaceName) UnmarshalTOML(data []byte) error

func (*PluginInterfaceName) UnmarshalText

func (p *PluginInterfaceName) UnmarshalText(data []byte) error

type PluginManager

type PluginManager struct {
	// contains filtered or unexported fields
}

this implements geth service

func NewEmptyPluginManager

func NewEmptyPluginManager() *PluginManager

func NewPluginManager

func NewPluginManager(nodeName string, settings *Settings, skipVerify bool, localVerify bool, publicKey string) (*PluginManager, error)

func (*PluginManager) APIs

func (s *PluginManager) APIs() []rpc.API

this is called after PluginManager service has been successfully started See node/node.go#Start()

func (*PluginManager) AddAccountPluginToBackend

func (s *PluginManager) AddAccountPluginToBackend(b *pluggable.Backend) error

AddAccountPluginToBackend adds the account plugin to the provided account backend

func (*PluginManager) GetPluginTemplate

func (s *PluginManager) GetPluginTemplate(name PluginInterfaceName, v managedPlugin) error

store the plugin instance to the value of the pointer v and cache it this function makes sure v value will never be nil

func (*PluginManager) IsEnabled

func (s *PluginManager) IsEnabled(name PluginInterfaceName) bool

Check if a plugin is enabled/setup

func (*PluginManager) PluginsInfo

func (s *PluginManager) PluginsInfo() interface{}

Provide details of current plugins being used

func (*PluginManager) Reload

func (s *PluginManager) Reload(name PluginInterfaceName) (bool, error)

func (*PluginManager) Start

func (s *PluginManager) Start() (err error)

func (*PluginManager) Stop

func (s *PluginManager) Stop() error

type PluginManagerAPI

type PluginManagerAPI struct {
	// contains filtered or unexported fields
}

func NewPluginManagerAPI

func NewPluginManagerAPI(pm *PluginManager) *PluginManagerAPI

func (*PluginManagerAPI) ReloadPlugin

func (pmapi *PluginManagerAPI) ReloadPlugin(name PluginInterfaceName) (bool, error)

type PluginManagerInterface

type PluginManagerInterface interface {
	APIs() []rpc.API
	Start() (err error)
	Stop() error
	IsEnabled(name PluginInterfaceName) bool
	PluginsInfo() interface{}
	Reload(name PluginInterfaceName) (bool, error)
	GetPluginTemplate(name PluginInterfaceName, v managedPlugin) error
}

type QLightTokenManagerPluginTemplate

type QLightTokenManagerPluginTemplate struct {
	// contains filtered or unexported fields
}

func (QLightTokenManagerPluginTemplate) Config

func (bp QLightTokenManagerPluginTemplate) Config() *PluginDefinition

func (*QLightTokenManagerPluginTemplate) Get

func (QLightTokenManagerPluginTemplate) Info

func (bp QLightTokenManagerPluginTemplate) Info() (PluginInterfaceName, interface{})

func (*QLightTokenManagerPluginTemplate) ManagedPlugin

func (p *QLightTokenManagerPluginTemplate) ManagedPlugin() managedPlugin

func (QLightTokenManagerPluginTemplate) Start

func (bp QLightTokenManagerPluginTemplate) Start() (err error)

func (QLightTokenManagerPluginTemplate) Stop

func (bp QLightTokenManagerPluginTemplate) Stop() error

type QLightTokenManagerPluginTemplateInterface

type QLightTokenManagerPluginTemplateInterface interface {
	Get() (qlight.PluginTokenManager, error)
	Start() (err error)
	Stop() (err error)
	ManagedPlugin() managedPlugin
}

type ReloadableAccountServiceFactory

type ReloadableAccountServiceFactory struct {
	// contains filtered or unexported fields
}

func (ReloadableAccountServiceFactory) Config

func (bp ReloadableAccountServiceFactory) Config() *PluginDefinition

func (*ReloadableAccountServiceFactory) Create

func (ReloadableAccountServiceFactory) Info

func (bp ReloadableAccountServiceFactory) Info() (PluginInterfaceName, interface{})

func (ReloadableAccountServiceFactory) Start

func (bp ReloadableAccountServiceFactory) Start() (err error)

func (ReloadableAccountServiceFactory) Stop

func (bp ReloadableAccountServiceFactory) Stop() error

type SecurityPluginTemplate

type SecurityPluginTemplate struct {
	// contains filtered or unexported fields
}

func (*SecurityPluginTemplate) AuthenticationManager

func (sp *SecurityPluginTemplate) AuthenticationManager() (security.AuthenticationManager, error)

AuthenticationManager returns an implementation of security.AuthenticationManager which could be a deferred implemenation or a disabled implementation.

The deferred implementation delegates to the actual implemenation (which is the plugin client).

The disabled implementation allows no authentication verification.

func (SecurityPluginTemplate) Config

func (bp SecurityPluginTemplate) Config() *PluginDefinition

func (SecurityPluginTemplate) Info

func (bp SecurityPluginTemplate) Info() (PluginInterfaceName, interface{})

func (SecurityPluginTemplate) Start

func (bp SecurityPluginTemplate) Start() (err error)

func (SecurityPluginTemplate) Stop

func (bp SecurityPluginTemplate) Stop() error

func (*SecurityPluginTemplate) TLSConfigurationSource

func (sp *SecurityPluginTemplate) TLSConfigurationSource() (security.TLSConfigurationSource, error)

TLSConfigurationSource returns an implementation of security.TLSConfigurationSource which could be nil in case the plugin doesn't implement the corresponding service. In order to verify that, it attempts to make a call and inspect the error.

type Settings

type Settings struct {
	BaseDir       EnvironmentAwaredValue                   `json:"baseDir" toml:""`
	CentralConfig *PluginCentralConfiguration              `json:"central" toml:"Central"`
	Providers     map[PluginInterfaceName]PluginDefinition `json:"providers" toml:""`
}

this defines plugins used in the geth node

func (*Settings) CheckSettingsAreSupported

func (s *Settings) CheckSettingsAreSupported(supportedPlugins []PluginInterfaceName) error

CheckSettingsAreSupported validates Settings by ensuring that only supportedPlugins are defined. It is not required for all supportedPlugins to be defined. An error containing plugin details is returned if one or more unsupported plugins are defined.

func (*Settings) GetPluginDefinition

func (s *Settings) GetPluginDefinition(name PluginInterfaceName) (*PluginDefinition, bool)

func (*Settings) SetDefaults

func (s *Settings) SetDefaults()

type Verifier

type Verifier interface {
	// verify plugin signature using checksum & pgp public key
	VerifySignature(definition *PluginDefinition, checksum string) error
}

Plugin Integrity Verifier. Verifier works on the assumption an attacker can not compromise the integrity of geth running process.

func NewVerifier

func NewVerifier(pm *PluginManager, localVerify bool, publicKey string) (Verifier, error)

type Version

type Version string

Directories

Path Synopsis
gen
proto_common
Package proto_common is a generated GoMock package.
Package proto_common is a generated GoMock package.
Package qlight is a generated GoMock package.
Package qlight is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL