Documentation
¶
Index ¶
- Variables
- func ClassifyWithPlugins(services []ClassifierService, filename, ext string) string
- type ClassifierPluginRPC
- type ClassifierRPCClient
- type ClassifierRPCServer
- type ClassifierService
- type Manager
- func (m *Manager) GetInfo(name string) (*Manifest, error)
- func (m *Manager) GetPluginDir() string
- func (m *Manager) Install(sourcePath string) (*Manifest, error)
- func (m *Manager) List() ([]Manifest, error)
- func (m *Manager) LoadAllClassifiers() ([]ClassifierService, []models.Rule, func())
- func (m *Manager) LoadClassifier(name string) (ClassifierService, func(), error)
- func (m *Manager) Remove(name string) error
- type Manifest
Constants ¶
This section is empty.
Variables ¶
var HandshakeConfig = hplugin.HandshakeConfig{
ProtocolVersion: 1,
MagicCookieKey: "CHEST_PLUGIN",
MagicCookieValue: "CHEST_IN_A_CHEST",
}
HandshakeConfig ensures plugin and host agree on protocol
var PluginMap = map[string]hplugin.Plugin{ "classifier": &ClassifierPluginRPC{}, }
PluginMap maps plugin types to implementations
Functions ¶
func ClassifyWithPlugins ¶
func ClassifyWithPlugins(services []ClassifierService, filename, ext string) string
ClassifyWithPlugins tries each loaded plugin service to classify a file. Returns the first non-empty, non-"Other" result, or empty string if no plugin matched.
Types ¶
type ClassifierPluginRPC ¶
type ClassifierPluginRPC struct {
Impl ClassifierService
}
type ClassifierRPCClient ¶
type ClassifierRPCClient struct {
// contains filtered or unexported fields
}
RPC Server/Client implementation
func (*ClassifierRPCClient) Classify ¶
func (c *ClassifierRPCClient) Classify(filename string, ext string) (string, error)
func (*ClassifierRPCClient) GetCustomRules ¶
func (c *ClassifierRPCClient) GetCustomRules() ([]models.Rule, error)
func (*ClassifierRPCClient) GetInfo ¶
func (c *ClassifierRPCClient) GetInfo() (Manifest, error)
type ClassifierRPCServer ¶
type ClassifierRPCServer struct {
Impl ClassifierService
}
func (*ClassifierRPCServer) Classify ¶
func (s *ClassifierRPCServer) Classify(args []string, resp *string) error
func (*ClassifierRPCServer) GetCustomRules ¶
func (s *ClassifierRPCServer) GetCustomRules(args interface{}, resp *[]models.Rule) error
func (*ClassifierRPCServer) GetInfo ¶
func (s *ClassifierRPCServer) GetInfo(args interface{}, resp *Manifest) error
type ClassifierService ¶
type ClassifierService interface {
GetInfo() (Manifest, error)
Classify(filename string, ext string) (string, error)
GetCustomRules() ([]models.Rule, error)
}
ClassifierService is the interface exposed by plugins
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager discovers and manages local plugins
func NewManager ¶
NewManager creates a plugin manager pointing to target directory (default ~/.chest/plugins)
func (*Manager) GetPluginDir ¶
GetPluginDir returns plugin storage folder
func (*Manager) Install ¶
Install installs a plugin from a local directory containing manifest.toml or manifest.json
func (*Manager) List ¶
List installed plugins by reading manifest.toml or manifest.json in each plugin folder
func (*Manager) LoadAllClassifiers ¶
func (m *Manager) LoadAllClassifiers() ([]ClassifierService, []models.Rule, func())
LoadAllClassifiers discovers all installed plugins with "classifier" capability, spawns each one, collects custom rules via GetCustomRules(), and returns:
- services: slice of active ClassifierService instances
- rules: aggregated custom rules from all plugins
- cleanup: function to kill all spawned plugin processes
func (*Manager) LoadClassifier ¶
func (m *Manager) LoadClassifier(name string) (ClassifierService, func(), error)
LoadClassifier spawns external plugin process and returns client
type Manifest ¶
type Manifest struct {
Name string `json:"name" toml:"name"`
Version string `json:"version" toml:"version"`
Description string `json:"description" toml:"description"`
Author string `json:"author,omitempty" toml:"author,omitempty"`
Capabilities []string `json:"capabilities" toml:"capabilities"` // e.g. ["classifier", "preset", "rule"]
Binary string `json:"binary" toml:"binary"` // executable filename
}
Manifest represents plugin metadata stored in manifest.json, manifest.toml, or returned by plugin