Documentation
ΒΆ
Overview ΒΆ
Package sdk provides core functionality for DevEx plugin development and management Version: v0.1.0 - improved error handling and timeout configuration
Package sdk provides security testing utilities for DevEx plugins
Index ΒΆ
- Constants
- Variables
- func CommandExists(cmd string) bool
- func DefaultUpdateCallback(status UpdateStatus)
- func ExecCommandOutputWithContext(ctx context.Context, name string, args ...string) (string, error)
- func ExecCommandOutputWithTimeout(timeout time.Duration, name string, args ...string) (string, error)
- func ExecCommandOutputWithTimeoutAndOperation(timeout time.Duration, operation string, name string, args ...string) (string, error)
- func ExecCommandWithContext(ctx context.Context, useSudo bool, name string, args ...string) error
- func ExecCommandWithTimeout(timeout time.Duration, useSudo bool, name string, args ...string) error
- func ExecCommandWithTimeoutAndOperation(timeout time.Duration, operation string, useSudo bool, name string, ...) error
- func FileExists(path string) bool
- func HandleArgs(plugin Plugin, args []string)
- func IsDownloadError(err error) bool
- func IsRoot() bool
- func IsSecurityTestPassing(summary TestResultSummary, minimumPassRate float64) bool
- func IsTimeoutError(err error) bool
- func NormalizeTimeout(timeout time.Duration, operationType string) time.Duration
- func ParseUpdateInterval(interval string) (time.Duration, error)
- func PrintSecurityTestReport(summary TestResultSummary) string
- func RequireSudo() bool
- func RunCommand(name string, args ...string) (string, error)
- func SafeGetEnv(name string) (string, error)
- func SafeGetEnvWithDefault(name, defaultValue string) (string, error)
- func SanitizeEnvVarForLogging(name, value string) string
- func SanitizeEnvironmentForLogging(env []string) []string
- func ValidateEnvironmentVariable(name, value string) error
- func ValidateSecurityTestResults(results []SecurityTestResult) (bool, []string)
- func ValidateTimeout(timeout time.Duration, operationType string) error
- func ValidateTimeoutConfig(config TimeoutConfig) error
- type AdvancedPatternGenerator
- func (g *AdvancedPatternGenerator) BoundaryTestPatterns() []string
- func (g *AdvancedPatternGenerator) GenerateObfuscatedCommands() []string
- func (g *AdvancedPatternGenerator) GeneratePolyglotPayloads() []string
- func (g *AdvancedPatternGenerator) ProtocolConfusionPatterns() []string
- func (g *AdvancedPatternGenerator) TimeBasedPatterns() []string
- type BackgroundUpdater
- func (bu *BackgroundUpdater) AddUpdateCallback(callback UpdateCallback)
- func (bu *BackgroundUpdater) CheckForUpdatesNow(ctx context.Context) error
- func (bu *BackgroundUpdater) GetLastUpdateTime() time.Time
- func (bu *BackgroundUpdater) IsRunning() bool
- func (bu *BackgroundUpdater) SetUpdateInterval(interval time.Duration)
- func (bu *BackgroundUpdater) Start(ctx context.Context) error
- func (bu *BackgroundUpdater) Stop()
- type BasePlugin
- func (p *BasePlugin) GetLogger() Logger
- func (p *BasePlugin) GetTimeout(operationType string) time.Duration
- func (p *BasePlugin) GetTimeouts() TimeoutConfig
- func (p *BasePlugin) Info() PluginInfo
- func (p *BasePlugin) OutputPluginInfo()
- func (p *BasePlugin) SetLogger(logger Logger)
- func (p *BasePlugin) SetTimeouts(timeouts TimeoutConfig)
- type Cache
- type CacheEntry
- type CacheMetrics
- type DefaultLogger
- func (l *DefaultLogger) Debug(msg string, keyvals ...any)
- func (l *DefaultLogger) Error(msg string, err error, keyvals ...any)
- func (l *DefaultLogger) ErrorMsg(msg string, args ...any)
- func (l *DefaultLogger) Info(msg string, keyvals ...any)
- func (l *DefaultLogger) Printf(format string, args ...any)
- func (l *DefaultLogger) Println(msg string, args ...any)
- func (l *DefaultLogger) Success(msg string, args ...any)
- func (l *DefaultLogger) Warn(msg string, keyvals ...any)
- func (l *DefaultLogger) Warning(msg string, args ...any)
- type DesktopPlugin
- type DownloadError
- type DownloadStrategy
- type Downloader
- func (d *Downloader) DownloadPluginWithContext(ctx context.Context, pluginName string) error
- func (d *Downloader) DownloadRequiredPluginsWithContext(ctx context.Context, requiredPlugins []string) error
- func (d *Downloader) DownloadRequiredPluginsWithContextAndOptions(ctx context.Context, requiredPlugins []string, criticalPlugins []string) error
- func (d *Downloader) GetAvailablePlugins(ctx context.Context) (map[string]PluginMetadata, error)
- func (d *Downloader) SearchPlugins(ctx context.Context, query string) (map[string]PluginMetadata, error)
- func (d *Downloader) SetLogger(logger Logger)
- func (d *Downloader) SetSilent(silent bool)
- func (d *Downloader) SetStrategy(strategy DownloadStrategy)
- type DownloaderConfig
- type EnvVarConfig
- type EnvVarSeverity
- type ExecutableManager
- func (em *ExecutableManager) DiscoverPlugins() error
- func (em *ExecutableManager) DiscoverPluginsWithContext(ctx context.Context) error
- func (em *ExecutableManager) ExecutePlugin(pluginName string, args []string) error
- func (em *ExecutableManager) GetPluginDir() string
- func (em *ExecutableManager) InstallPlugin(sourcePath, pluginName string) error
- func (em *ExecutableManager) ListPlugins() map[string]PluginMetadata
- func (em *ExecutableManager) ListPluginsWithContext(ctx context.Context) map[string]PluginMetadata
- func (em *ExecutableManager) RegisterCommands(rootCmd interface{}) error
- func (em *ExecutableManager) RemovePlugin(pluginName string) error
- type GPGVerifier
- type Logger
- type MemoryCache
- func (c *MemoryCache) Clear()
- func (c *MemoryCache) Close()
- func (c *MemoryCache) Delete(key string)
- func (c *MemoryCache) Get(key string) (interface{}, bool)
- func (c *MemoryCache) GetEvictions() int64
- func (c *MemoryCache) GetHits() int64
- func (c *MemoryCache) GetMetrics() CacheMetrics
- func (c *MemoryCache) GetMisses() int64
- func (c *MemoryCache) Set(key string, value interface{})
- func (c *MemoryCache) SetWithTTL(key string, value interface{}, ttl time.Duration)
- type MultiError
- type PackageManagerPlugin
- func (p *PackageManagerPlugin) EnsureAvailable()
- func (p *PackageManagerPlugin) ExecManagerCommand(operation string, useSudo bool, args ...string) error
- func (p *PackageManagerPlugin) ExecManagerCommandOutput(operation string, args ...string) (string, error)
- func (p *PackageManagerPlugin) IsAvailable() bool
- type PlatformBinary
- type Plugin
- type PluginCommand
- type PluginInfo
- type PluginMetadata
- type PluginRegistry
- type Registry
- type RegistryClient
- func (c *RegistryClient) GetPlugin(ctx context.Context, pluginName string) (*PluginMetadata, error)
- func (c *RegistryClient) GetRegistry(ctx context.Context) (*PluginRegistry, error)
- func (c *RegistryClient) SearchPlugins(ctx context.Context, query string, tags []string, limit int) ([]PluginMetadata, error)
- type RegistryConfig
- type RegistryDownloader
- func (rd *RegistryDownloader) GetAvailablePlugins(ctx context.Context) (map[string]PluginMetadata, error)
- func (rd *RegistryDownloader) GetPluginDetails(ctx context.Context, pluginName string) (*PluginMetadata, error)
- func (rd *RegistryDownloader) SearchPlugins(ctx context.Context, query string) (map[string]PluginMetadata, error)
- type RegistryDownloaderInterface
- type RegistryError
- type RegistryResponse
- type SearchIndex
- type SecurityIssue
- type SecurityTestResult
- type SecurityTestSuite
- func (s *SecurityTestSuite) TestArgumentSplitting(validator func(string) error) []SecurityTestResult
- func (s *SecurityTestSuite) TestCommandInjection(validator func(string) error) []SecurityTestResult
- func (s *SecurityTestSuite) TestPathInjection(validator func(string) error) []SecurityTestResult
- func (s *SecurityTestSuite) TestPatternValidation(validator func(string) error, patterns []string, testName string) []SecurityTestResult
- func (s *SecurityTestSuite) TestURLInjection(validator func(string) error) []SecurityTestResult
- func (s *SecurityTestSuite) TestUnicodeInjection(validator func(string) error) []SecurityTestResult
- type SystemGPGVerifier
- type TestResultSummary
- type TimeoutConfig
- type TimeoutError
- type UpdateCallback
- type UpdateStatus
- type UpdaterConfig
Constants ΒΆ
const ( DefaultBaseURL = "https://registry.devex.sh" DefaultTimeout = 30 * time.Second DefaultUserAgent = "devex-cli/1.0" DefaultSearchLimit = 100 DefaultCacheTTL = 5 * time.Minute MaxPluginNameLength = 100 DefaultMaxIdleConns = 10 DefaultMaxIdleConnsPerHost = 2 DefaultIdleConnTimeout = 30 * time.Second )
Constants for default configuration values
Variables ΒΆ
var RegexValidationPatterns = struct { SafeFilename *regexp.Regexp SafeURL *regexp.Regexp SafeCommand *regexp.Regexp SafeEnvironmentVar *regexp.Regexp }{ SafeFilename: regexp.MustCompile(`^[a-zA-Z0-9._-]+$`), SafeURL: regexp.MustCompile(`^https?://[a-zA-Z0-9.-]+(/[a-zA-Z0-9._/-]*)?(\?[a-zA-Z0-9=&_-]*)?$`), SafeCommand: regexp.MustCompile(`^[a-zA-Z0-9\s./=_-]+$`), SafeEnvironmentVar: regexp.MustCompile(`^[A-Z_][A-Z0-9_]*$`), }
RegexValidationPatterns provides regex patterns for common validation scenarios
Functions ΒΆ
func CommandExists ΒΆ
CommandExists checks if a command exists in PATH
func DefaultUpdateCallback ΒΆ
func DefaultUpdateCallback(status UpdateStatus)
DefaultUpdateCallback provides a simple console output callback
func ExecCommandOutputWithContext ΒΆ added in v0.0.2
ExecCommandOutputWithContext executes a command and returns output with context support
func ExecCommandOutputWithTimeout ΒΆ added in v0.0.2
func ExecCommandOutputWithTimeout(timeout time.Duration, name string, args ...string) (string, error)
ExecCommandOutputWithTimeout executes a command and returns output with timeout
func ExecCommandOutputWithTimeoutAndOperation ΒΆ added in v0.0.2
func ExecCommandOutputWithTimeoutAndOperation(timeout time.Duration, operation string, name string, args ...string) (string, error)
ExecCommandOutputWithTimeoutAndOperation executes a command and returns output with timeout and operation context
func ExecCommandWithContext ΒΆ added in v0.0.2
ExecCommandWithContext executes a command with context support for cancellation
func ExecCommandWithTimeout ΒΆ added in v0.0.2
ExecCommandWithTimeout executes a command with a specific timeout
func ExecCommandWithTimeoutAndOperation ΒΆ added in v0.0.2
func ExecCommandWithTimeoutAndOperation(timeout time.Duration, operation string, useSudo bool, name string, args ...string) error
ExecCommandWithTimeoutAndOperation executes a command with timeout and operation context
func HandleArgs ΒΆ
HandleArgs provides standard argument handling for plugins
func IsDownloadError ΒΆ
IsDownloadError checks if an error is a DownloadError
func IsSecurityTestPassing ΒΆ added in v0.0.2
func IsSecurityTestPassing(summary TestResultSummary, minimumPassRate float64) bool
IsSecurityTestPassing determines if security tests meet minimum standards
func IsTimeoutError ΒΆ added in v0.0.2
IsTimeoutError checks if an error is a TimeoutError
func NormalizeTimeout ΒΆ added in v0.0.2
NormalizeTimeout ensures timeout is within reasonable bounds
func ParseUpdateInterval ΒΆ
ParseUpdateInterval parses a duration string for update intervals
func PrintSecurityTestReport ΒΆ added in v0.0.2
func PrintSecurityTestReport(summary TestResultSummary) string
PrintSecurityTestReport prints a formatted security test report
func RunCommand ΒΆ
RunCommand runs a command and returns its output
func SafeGetEnv ΒΆ added in v0.0.2
SafeGetEnv safely retrieves an environment variable with validation
func SafeGetEnvWithDefault ΒΆ added in v0.0.2
SafeGetEnvWithDefault safely retrieves an environment variable with default and validation
func SanitizeEnvVarForLogging ΒΆ added in v0.0.2
SanitizeEnvVarForLogging sanitizes a single environment variable for logging
func SanitizeEnvironmentForLogging ΒΆ added in v0.0.2
SanitizeEnvironmentForLogging removes sensitive environment variables for logging
func ValidateEnvironmentVariable ΒΆ added in v0.0.2
ValidateEnvironmentVariable validates a specific environment variable value
func ValidateSecurityTestResults ΒΆ added in v0.0.2
func ValidateSecurityTestResults(results []SecurityTestResult) (bool, []string)
ValidateSecurityTestResults checks if security tests passed (all patterns blocked)
func ValidateTimeout ΒΆ added in v0.0.2
ValidateTimeout validates a specific timeout duration
func ValidateTimeoutConfig ΒΆ added in v0.0.2
func ValidateTimeoutConfig(config TimeoutConfig) error
ValidateTimeoutConfig validates a timeout configuration
Types ΒΆ
type AdvancedPatternGenerator ΒΆ added in v0.0.2
type AdvancedPatternGenerator struct{}
AdvancedPatternGenerator generates sophisticated attack patterns
func NewAdvancedPatternGenerator ΒΆ added in v0.0.2
func NewAdvancedPatternGenerator() *AdvancedPatternGenerator
NewAdvancedPatternGenerator creates a generator for complex attack patterns
func (*AdvancedPatternGenerator) BoundaryTestPatterns ΒΆ added in v0.0.2
func (g *AdvancedPatternGenerator) BoundaryTestPatterns() []string
BoundaryTestPatterns generates edge case patterns for boundary testing
func (*AdvancedPatternGenerator) GenerateObfuscatedCommands ΒΆ added in v0.0.2
func (g *AdvancedPatternGenerator) GenerateObfuscatedCommands() []string
GenerateObfuscatedCommands creates obfuscated versions of dangerous commands
func (*AdvancedPatternGenerator) GeneratePolyglotPayloads ΒΆ added in v0.0.2
func (g *AdvancedPatternGenerator) GeneratePolyglotPayloads() []string
GeneratePolyglotPayloads creates payloads that work across multiple contexts
func (*AdvancedPatternGenerator) ProtocolConfusionPatterns ΒΆ added in v0.0.2
func (g *AdvancedPatternGenerator) ProtocolConfusionPatterns() []string
ProtocolConfusionPatterns generates protocol confusion attack patterns
func (*AdvancedPatternGenerator) TimeBasedPatterns ΒΆ added in v0.0.2
func (g *AdvancedPatternGenerator) TimeBasedPatterns() []string
TimeBasedPatterns generates patterns for time-based attacks
type BackgroundUpdater ΒΆ
type BackgroundUpdater struct {
// contains filtered or unexported fields
}
BackgroundUpdater handles automatic plugin updates in the background
func NewBackgroundUpdater ΒΆ
func NewBackgroundUpdater(downloader *Downloader, manager *ExecutableManager) *BackgroundUpdater
NewBackgroundUpdater creates a new background updater
func (*BackgroundUpdater) AddUpdateCallback ΒΆ
func (bu *BackgroundUpdater) AddUpdateCallback(callback UpdateCallback)
AddUpdateCallback adds a callback to be called on updates
func (*BackgroundUpdater) CheckForUpdatesNow ΒΆ
func (bu *BackgroundUpdater) CheckForUpdatesNow(ctx context.Context) error
CheckForUpdatesNow immediately checks for and applies updates
func (*BackgroundUpdater) GetLastUpdateTime ΒΆ
func (bu *BackgroundUpdater) GetLastUpdateTime() time.Time
GetLastUpdateTime returns the last update check time
func (*BackgroundUpdater) IsRunning ΒΆ
func (bu *BackgroundUpdater) IsRunning() bool
IsRunning returns whether the updater is currently running
func (*BackgroundUpdater) SetUpdateInterval ΒΆ
func (bu *BackgroundUpdater) SetUpdateInterval(interval time.Duration)
SetUpdateInterval sets the update check interval
func (*BackgroundUpdater) Start ΒΆ
func (bu *BackgroundUpdater) Start(ctx context.Context) error
Start starts the background updater
func (*BackgroundUpdater) Stop ΒΆ
func (bu *BackgroundUpdater) Stop()
Stop stops the background updater
type BasePlugin ΒΆ
type BasePlugin struct {
// contains filtered or unexported fields
}
BasePlugin provides common functionality for plugins
func NewBasePlugin ΒΆ
func NewBasePlugin(info PluginInfo) *BasePlugin
NewBasePlugin creates a new base plugin
func (*BasePlugin) GetLogger ΒΆ added in v0.0.2
func (p *BasePlugin) GetLogger() Logger
GetLogger returns the plugin's logger
func (*BasePlugin) GetTimeout ΒΆ added in v0.0.2
func (p *BasePlugin) GetTimeout(operationType string) time.Duration
GetTimeout returns the appropriate timeout for an operation type
func (*BasePlugin) GetTimeouts ΒΆ added in v0.0.2
func (p *BasePlugin) GetTimeouts() TimeoutConfig
GetTimeouts returns the plugin's timeout configuration
func (*BasePlugin) Info ΒΆ
func (p *BasePlugin) Info() PluginInfo
Info returns the plugin information
func (*BasePlugin) OutputPluginInfo ΒΆ
func (p *BasePlugin) OutputPluginInfo()
OutputPluginInfo outputs plugin info as JSON (for --plugin-info)
func (*BasePlugin) SetLogger ΒΆ added in v0.0.2
func (p *BasePlugin) SetLogger(logger Logger)
SetLogger sets a custom logger for the plugin
func (*BasePlugin) SetTimeouts ΒΆ added in v0.0.2
func (p *BasePlugin) SetTimeouts(timeouts TimeoutConfig)
SetTimeouts sets custom timeout configuration for the plugin
type Cache ΒΆ added in v0.0.2
type Cache interface {
// Get retrieves a value from the cache
Get(key string) (interface{}, bool)
// Set stores a value in the cache with a TTL
Set(key string, value interface{})
// Delete removes a value from the cache
Delete(key string)
// Clear removes all values from the cache
Clear()
// Close stops background processes and cleans up resources
Close()
}
Cache defines the interface for caching registry data
type CacheEntry ΒΆ added in v0.0.2
CacheEntry represents a cached item with expiration
type CacheMetrics ΒΆ added in v0.0.2
type CacheMetrics struct {
// contains filtered or unexported fields
}
CacheMetrics tracks cache performance using atomic operations
type DefaultLogger ΒΆ
type DefaultLogger struct {
// contains filtered or unexported fields
}
DefaultLogger provides basic console logging for plugins
func (*DefaultLogger) Debug ΒΆ
func (l *DefaultLogger) Debug(msg string, keyvals ...any)
Debug implements Logger interface
func (*DefaultLogger) Error ΒΆ
func (l *DefaultLogger) Error(msg string, err error, keyvals ...any)
Error implements Logger interface
func (*DefaultLogger) ErrorMsg ΒΆ
func (l *DefaultLogger) ErrorMsg(msg string, args ...any)
ErrorMsg implements Logger interface
func (*DefaultLogger) Info ΒΆ
func (l *DefaultLogger) Info(msg string, keyvals ...any)
Info implements Logger interface
func (*DefaultLogger) Printf ΒΆ
func (l *DefaultLogger) Printf(format string, args ...any)
Printf implements Logger interface
func (*DefaultLogger) Println ΒΆ
func (l *DefaultLogger) Println(msg string, args ...any)
Println implements Logger interface
func (*DefaultLogger) Success ΒΆ
func (l *DefaultLogger) Success(msg string, args ...any)
Success implements Logger interface
func (*DefaultLogger) Warn ΒΆ
func (l *DefaultLogger) Warn(msg string, keyvals ...any)
Warn implements Logger interface
func (*DefaultLogger) Warning ΒΆ
func (l *DefaultLogger) Warning(msg string, args ...any)
Warning implements Logger interface
type DesktopPlugin ΒΆ
type DesktopPlugin interface {
Plugin
// IsAvailable Desktop-specific methods
IsAvailable() bool
GetDesktopEnvironment() string
}
DesktopPlugin interface for desktop environment plugins
type DownloadError ΒΆ
DownloadError represents an error that occurred during plugin download
func GetDownloadErrors ΒΆ
func GetDownloadErrors(err error) []*DownloadError
GetDownloadErrors extracts all DownloadErrors from a MultiError
func (*DownloadError) Error ΒΆ
func (e *DownloadError) Error() string
func (*DownloadError) Unwrap ΒΆ
func (e *DownloadError) Unwrap() error
Unwrap returns the underlying error for error wrapping support
type DownloadStrategy ΒΆ
type DownloadStrategy int
DownloadStrategy defines how to handle download failures
const ( // ContinueOnError continues downloading other plugins if one fails ContinueOnError DownloadStrategy = iota // FailOnError stops downloading if any plugin fails FailOnError // RequireCritical only fails if critical plugins fail RequireCritical )
type Downloader ΒΆ
type Downloader struct {
// contains filtered or unexported fields
}
Downloader handles secure plugin downloading from registry with verification
func NewDownloader ΒΆ
func NewDownloader(registryURL, pluginDir string) *Downloader
NewDownloader creates a new plugin downloader with default security settings
func NewSecureDownloader ΒΆ
func NewSecureDownloader(config DownloaderConfig) *Downloader
NewSecureDownloader creates a downloader with custom security configuration
func (*Downloader) DownloadPluginWithContext ΒΆ
func (d *Downloader) DownloadPluginWithContext(ctx context.Context, pluginName string) error
DownloadPluginWithContext downloads a plugin with context for cancellation
func (*Downloader) DownloadRequiredPluginsWithContext ΒΆ
func (d *Downloader) DownloadRequiredPluginsWithContext(ctx context.Context, requiredPlugins []string) error
DownloadRequiredPluginsWithContext downloads all required plugins with context support
func (*Downloader) DownloadRequiredPluginsWithContextAndOptions ΒΆ
func (d *Downloader) DownloadRequiredPluginsWithContextAndOptions(ctx context.Context, requiredPlugins []string, criticalPlugins []string) error
DownloadRequiredPluginsWithContextAndOptions downloads plugins with full control
func (*Downloader) GetAvailablePlugins ΒΆ
func (d *Downloader) GetAvailablePlugins(ctx context.Context) (map[string]PluginMetadata, error)
GetAvailablePlugins returns available plugins from registry with caching
func (*Downloader) SearchPlugins ΒΆ
func (d *Downloader) SearchPlugins(ctx context.Context, query string) (map[string]PluginMetadata, error)
SearchPlugins searches for plugins by query with caching
func (*Downloader) SetLogger ΒΆ
func (d *Downloader) SetLogger(logger Logger)
SetLogger allows setting a custom logger for the downloader
func (*Downloader) SetSilent ΒΆ
func (d *Downloader) SetSilent(silent bool)
SetSilent enables/disables silent mode for the default logger
func (*Downloader) SetStrategy ΒΆ
func (d *Downloader) SetStrategy(strategy DownloadStrategy)
SetStrategy sets the download strategy
type DownloaderConfig ΒΆ
type DownloaderConfig struct {
RegistryURL string
PluginDir string
CacheDir string
VerifyChecksums bool
VerifySignatures bool
PublicKeyPath string
Strategy DownloadStrategy
}
DownloaderConfig configures the plugin downloader
type EnvVarConfig ΒΆ added in v0.0.2
type EnvVarConfig struct {
Name string
Severity EnvVarSeverity
Description string
AllowEmpty bool
ValidateFunc func(string) error
}
EnvVarConfig represents validation configuration for an environment variable
type EnvVarSeverity ΒΆ added in v0.0.2
type EnvVarSeverity int
EnvVarSeverity represents the security risk level of environment variables
const ( // EnvVarSafe indicates the variable is generally safe to use EnvVarSafe EnvVarSeverity = iota // EnvVarWarning indicates the variable may pose security risks EnvVarWarning // EnvVarDangerous indicates the variable poses significant security risks EnvVarDangerous // EnvVarBlocked indicates the variable should never be used EnvVarBlocked )
type ExecutableManager ΒΆ
type ExecutableManager struct {
// contains filtered or unexported fields
}
ExecutableManager manages plugin executables with caching and timeouts
func NewExecutableManager ΒΆ
func NewExecutableManager(pluginDir string) *ExecutableManager
NewExecutableManager creates a new executable manager with caching
func (*ExecutableManager) DiscoverPlugins ΒΆ
func (em *ExecutableManager) DiscoverPlugins() error
DiscoverPlugins discovers and caches plugins in the plugin directory
func (*ExecutableManager) DiscoverPluginsWithContext ΒΆ
func (em *ExecutableManager) DiscoverPluginsWithContext(ctx context.Context) error
DiscoverPluginsWithContext discovers plugins with context support
func (*ExecutableManager) ExecutePlugin ΒΆ
func (em *ExecutableManager) ExecutePlugin(pluginName string, args []string) error
ExecutePlugin executes a plugin with given arguments and timeout
func (*ExecutableManager) GetPluginDir ΒΆ
func (em *ExecutableManager) GetPluginDir() string
GetPluginDir returns the plugin directory
func (*ExecutableManager) InstallPlugin ΒΆ
func (em *ExecutableManager) InstallPlugin(sourcePath, pluginName string) error
InstallPlugin installs a plugin from a source path
func (*ExecutableManager) ListPlugins ΒΆ
func (em *ExecutableManager) ListPlugins() map[string]PluginMetadata
ListPlugins returns installed plugins with caching
func (*ExecutableManager) ListPluginsWithContext ΒΆ added in v0.0.5
func (em *ExecutableManager) ListPluginsWithContext(ctx context.Context) map[string]PluginMetadata
ListPluginsWithContext returns installed plugins with caching and context support
func (*ExecutableManager) RegisterCommands ΒΆ
func (em *ExecutableManager) RegisterCommands(rootCmd interface{}) error
RegisterCommands registers plugin commands (placeholder)
func (*ExecutableManager) RemovePlugin ΒΆ
func (em *ExecutableManager) RemovePlugin(pluginName string) error
RemovePlugin removes a plugin executable
type GPGVerifier ΒΆ
type GPGVerifier struct {
// contains filtered or unexported fields
}
GPGVerifier handles GPG signature verification for plugins
func (*GPGVerifier) LoadPublicKey ΒΆ
func (v *GPGVerifier) LoadPublicKey(keyPath string) error
LoadPublicKey loads a public key from file or URL
func (*GPGVerifier) LoadPublicKeyFromKeyserver ΒΆ
func (v *GPGVerifier) LoadPublicKeyFromKeyserver(keyID string) error
LoadPublicKeyFromKeyserver loads a public key from a keyserver
func (*GPGVerifier) VerifySignature ΒΆ
func (v *GPGVerifier) VerifySignature(filePath, signaturePath string) error
VerifySignature verifies a GPG signature for a file
func (*GPGVerifier) VerifySignatureFromURL ΒΆ
func (v *GPGVerifier) VerifySignatureFromURL(filePath, signatureURL string) error
VerifySignatureFromURL downloads and verifies a signature from a URL
type Logger ΒΆ
type Logger interface {
Printf(format string, args ...any)
Println(msg string, args ...any)
Success(msg string, args ...any)
Warning(msg string, args ...any)
ErrorMsg(msg string, args ...any)
Info(msg string, keyvals ...any)
Warn(msg string, keyvals ...any)
Error(msg string, err error, keyvals ...any)
Debug(msg string, keyvals ...any)
}
Logger interface for plugin SDK logging Plugins can provide their own logger implementation or use a default
func NewDefaultLogger ΒΆ
NewDefaultLogger creates a new default logger
type MemoryCache ΒΆ added in v0.0.2
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache implements an in-memory cache with TTL support
func NewMemoryCache ΒΆ added in v0.0.2
func NewMemoryCache(ttl time.Duration) *MemoryCache
NewMemoryCache creates a new memory cache with the specified TTL
func (*MemoryCache) Clear ΒΆ added in v0.0.2
func (c *MemoryCache) Clear()
Clear removes all values from the cache
func (*MemoryCache) Close ΒΆ added in v0.0.2
func (c *MemoryCache) Close()
Close stops the cleanup goroutine and marks the cache as closed
func (*MemoryCache) Delete ΒΆ added in v0.0.2
func (c *MemoryCache) Delete(key string)
Delete removes a value from the cache
func (*MemoryCache) Get ΒΆ added in v0.0.2
func (c *MemoryCache) Get(key string) (interface{}, bool)
Get retrieves a value from the cache
func (*MemoryCache) GetEvictions ΒΆ added in v0.0.2
func (c *MemoryCache) GetEvictions() int64
GetEvictions returns the number of cache evictions
func (*MemoryCache) GetHits ΒΆ added in v0.0.2
func (c *MemoryCache) GetHits() int64
GetHits returns the number of cache hits
func (*MemoryCache) GetMetrics ΒΆ added in v0.0.2
func (c *MemoryCache) GetMetrics() CacheMetrics
GetMetrics returns cache performance metrics as a consistent snapshot
func (*MemoryCache) GetMisses ΒΆ added in v0.0.2
func (c *MemoryCache) GetMisses() int64
GetMisses returns the number of cache misses
func (*MemoryCache) Set ΒΆ added in v0.0.2
func (c *MemoryCache) Set(key string, value interface{})
Set stores a value in the cache with the configured TTL
func (*MemoryCache) SetWithTTL ΒΆ added in v0.0.2
func (c *MemoryCache) SetWithTTL(key string, value interface{}, ttl time.Duration)
SetWithTTL stores a value in the cache with a custom TTL
type MultiError ΒΆ
type MultiError struct {
Errors []error
}
MultiError represents multiple errors that occurred
func (*MultiError) Error ΒΆ
func (e *MultiError) Error() string
func (*MultiError) HasErrors ΒΆ
func (e *MultiError) HasErrors() bool
HasErrors returns true if there are any errors
func (*MultiError) Unwrap ΒΆ
func (e *MultiError) Unwrap() []error
type PackageManagerPlugin ΒΆ
type PackageManagerPlugin struct {
*BasePlugin
// contains filtered or unexported fields
}
PackageManagerPlugin provides common functionality for package manager plugins
func NewPackageManagerPlugin ΒΆ
func NewPackageManagerPlugin(info PluginInfo, managerCommand string) *PackageManagerPlugin
NewPackageManagerPlugin creates a new package manager plugin
func (*PackageManagerPlugin) EnsureAvailable ΒΆ
func (p *PackageManagerPlugin) EnsureAvailable()
EnsureAvailable ensures the package manager is available or exits with an error
func (*PackageManagerPlugin) ExecManagerCommand ΒΆ added in v0.0.2
func (p *PackageManagerPlugin) ExecManagerCommand(operation string, useSudo bool, args ...string) error
ExecManagerCommand executes a package manager command with timeout
func (*PackageManagerPlugin) ExecManagerCommandOutput ΒΆ added in v0.0.2
func (p *PackageManagerPlugin) ExecManagerCommandOutput(operation string, args ...string) (string, error)
ExecManagerCommandOutput executes a package manager command and returns output with timeout
func (*PackageManagerPlugin) IsAvailable ΒΆ
func (p *PackageManagerPlugin) IsAvailable() bool
IsAvailable checks if the package manager is available on the system
type PlatformBinary ΒΆ
type PlatformBinary struct {
URL string `json:"url"`
Checksum string `json:"checksum"`
Size int64 `json:"size"`
OS string `json:"os"`
Arch string `json:"arch"`
}
PlatformBinary represents a binary for a specific platform
type Plugin ΒΆ
type Plugin interface {
Info() PluginInfo
Execute(command string, args []string) error
}
Plugin interface for implementing plugins
type PluginCommand ΒΆ
type PluginCommand struct {
Name string `json:"name"`
Description string `json:"description"`
Usage string `json:"usage"`
Flags map[string]string `json:"flags,omitempty"`
}
PluginCommand represents a command provided by a plugin
type PluginInfo ΒΆ
type PluginInfo struct {
Name string `json:"name"`
Version string `json:"version"`
Description string `json:"description"`
Commands []PluginCommand `json:"commands"`
Author string `json:"author,omitempty"`
Repository string `json:"repository,omitempty"`
Tags []string `json:"tags,omitempty"`
// Timeout configuration for plugin operations
Timeouts TimeoutConfig `json:"timeouts,omitempty"`
}
PluginInfo represents the standard plugin information
type PluginMetadata ΒΆ
type PluginMetadata struct {
PluginInfo
Path string `json:"path"`
Platforms []string `json:"platforms,omitempty"` // Supported platforms (OS names)
Binaries map[string]PlatformBinary `json:"binaries,omitempty"` // Platform-specific binaries (e.g., "linux-amd64")
Priority int `json:"priority,omitempty"` // Installation priority
Type string `json:"type,omitempty"` // Plugin type (package-manager, desktop, etc.)
}
PluginMetadata represents plugin metadata with path and platform information
type PluginRegistry ΒΆ
type PluginRegistry struct {
BaseURL string `json:"base_url"`
Version string `json:"version"`
LastUpdated time.Time `json:"last_updated"`
Plugins map[string]PluginMetadata `json:"plugins"`
}
PluginRegistry represents the plugin registry structure
type Registry ΒΆ added in v0.0.2
type Registry interface {
// GetRegistry fetches the complete plugin registry
GetRegistry(ctx context.Context) (*PluginRegistry, error)
// GetPlugin fetches detailed information about a specific plugin
GetPlugin(ctx context.Context, pluginName string) (*PluginMetadata, error)
// SearchPlugins searches for plugins by name or tags with optional limit
SearchPlugins(ctx context.Context, query string, tags []string, limit int) ([]PluginMetadata, error)
}
Registry defines the interface for plugin registry operations. This interface allows for easy testing and mocking of registry functionality.
type RegistryClient ΒΆ
type RegistryClient struct {
// contains filtered or unexported fields
}
RegistryClient provides simple, read-only access to the plugin registry API. This client connects to a simplified registry API that does not require authentication. It implements the Registry interface for easy testing and mocking.
func NewRegistryClient ΒΆ
func NewRegistryClient(config RegistryConfig) (*RegistryClient, error)
NewRegistryClient creates a new registry client for simple, read-only access. This client connects to a simplified registry API without authentication.
func (*RegistryClient) GetPlugin ΒΆ
func (c *RegistryClient) GetPlugin(ctx context.Context, pluginName string) (*PluginMetadata, error)
GetPlugin fetches detailed information about a specific plugin
func (*RegistryClient) GetRegistry ΒΆ
func (c *RegistryClient) GetRegistry(ctx context.Context) (*PluginRegistry, error)
GetRegistry fetches the complete plugin registry with caching
func (*RegistryClient) SearchPlugins ΒΆ
func (c *RegistryClient) SearchPlugins(ctx context.Context, query string, tags []string, limit int) ([]PluginMetadata, error)
SearchPlugins searches for plugins by name or tags with optimized indexing and caching
type RegistryConfig ΒΆ
type RegistryConfig struct {
BaseURL string // Base URL of the registry API (defaults to DefaultBaseURL)
Timeout time.Duration // HTTP timeout (defaults to DefaultTimeout)
UserAgent string // User agent string (defaults to DefaultUserAgent)
CacheTTL time.Duration // Cache TTL (defaults to DefaultCacheTTL)
Logger Logger // Logger for debugging (optional)
MaxIdleConns int // Maximum idle connections (defaults to 10)
MaxIdleConnsPerHost int // Maximum idle connections per host (defaults to 2)
IdleConnTimeout time.Duration // Idle connection timeout (defaults to 30s)
}
RegistryConfig configures the registry client for simple, read-only access
type RegistryDownloader ΒΆ added in v0.0.2
type RegistryDownloader struct {
*Downloader
// contains filtered or unexported fields
}
Enhanced Downloader with registry client
func NewRegistryDownloader ΒΆ added in v0.0.2
func NewRegistryDownloader(config DownloaderConfig, registryConfig RegistryConfig) (*RegistryDownloader, error)
NewRegistryDownloader creates a downloader with registry access
func (*RegistryDownloader) GetAvailablePlugins ΒΆ added in v0.0.2
func (rd *RegistryDownloader) GetAvailablePlugins(ctx context.Context) (map[string]PluginMetadata, error)
GetAvailablePlugins fetches all available plugins from the registry
func (*RegistryDownloader) GetPluginDetails ΒΆ added in v0.0.2
func (rd *RegistryDownloader) GetPluginDetails(ctx context.Context, pluginName string) (*PluginMetadata, error)
GetPluginDetails returns detailed plugin information from the registry API
func (*RegistryDownloader) SearchPlugins ΒΆ added in v0.0.2
func (rd *RegistryDownloader) SearchPlugins(ctx context.Context, query string) (map[string]PluginMetadata, error)
SearchPlugins searches for plugins using the registry API
type RegistryDownloaderInterface ΒΆ added in v0.0.2
type RegistryDownloaderInterface interface {
// GetAvailablePlugins fetches all available plugins from the registry
GetAvailablePlugins(ctx context.Context) (map[string]PluginMetadata, error)
// SearchPlugins searches for plugins by query string
SearchPlugins(ctx context.Context, query string) (map[string]PluginMetadata, error)
// GetPluginDetails fetches detailed information about a specific plugin
GetPluginDetails(ctx context.Context, pluginName string) (*PluginMetadata, error)
}
RegistryDownloaderInterface defines the interface for registry-aware downloaders
type RegistryError ΒΆ added in v0.0.2
RegistryError represents an error from the registry API
func (*RegistryError) Error ΒΆ added in v0.0.2
func (e *RegistryError) Error() string
func (*RegistryError) Unwrap ΒΆ added in v0.0.2
func (e *RegistryError) Unwrap() error
type RegistryResponse ΒΆ added in v0.0.2
type RegistryResponse struct {
BaseURL string `json:"base_url"`
Version string `json:"version"`
LastUpdated string `json:"last_updated"`
Plugins map[string]PluginMetadata `json:"plugins"`
}
Simple registry response structure
type SearchIndex ΒΆ added in v0.0.2
type SearchIndex struct {
// contains filtered or unexported fields
}
SearchIndex provides efficient searching capabilities with pre-sorted data
type SecurityIssue ΒΆ added in v0.0.2
SecurityIssue represents a security issue found during environment validation
func CheckEnvironmentSecurity ΒΆ added in v0.0.2
func CheckEnvironmentSecurity() []SecurityIssue
CheckEnvironmentSecurity performs a comprehensive security check of environment variables
type SecurityTestResult ΒΆ added in v0.0.2
SecurityTestResult represents the result of a security test
type SecurityTestSuite ΒΆ added in v0.0.2
type SecurityTestSuite struct {
// Shell metacharacter injection patterns
ShellMetacharacters []string
// Command substitution attack patterns
CommandSubstitutionPatterns []string
// Path traversal attack patterns
PathTraversalPatterns []string
// Environment variable injection patterns
EnvVarInjectionPatterns []string
// Null byte injection patterns
NullBytePatterns []string
// Unicode and encoding attack patterns
UnicodeAttackPatterns []string
// Argument splitting attack patterns
ArgumentSplittingPatterns []string
// Script injection patterns
ScriptInjectionPatterns []string
// Network-based injection patterns
NetworkInjectionPatterns []string
// Process manipulation patterns
ProcessManipulationPatterns []string
}
SecurityTestSuite provides comprehensive security testing patterns for plugins
func NewSecurityTestSuite ΒΆ added in v0.0.2
func NewSecurityTestSuite() *SecurityTestSuite
NewSecurityTestSuite creates a new comprehensive security test suite
func (*SecurityTestSuite) TestArgumentSplitting ΒΆ added in v0.0.2
func (s *SecurityTestSuite) TestArgumentSplitting(validator func(string) error) []SecurityTestResult
TestArgumentSplitting tests argument splitting and parsing attacks
func (*SecurityTestSuite) TestCommandInjection ΒΆ added in v0.0.2
func (s *SecurityTestSuite) TestCommandInjection(validator func(string) error) []SecurityTestResult
TestCommandInjection comprehensively tests command injection prevention
func (*SecurityTestSuite) TestPathInjection ΒΆ added in v0.0.2
func (s *SecurityTestSuite) TestPathInjection(validator func(string) error) []SecurityTestResult
TestPathInjection tests path traversal and file system injection prevention
func (*SecurityTestSuite) TestPatternValidation ΒΆ added in v0.0.2
func (s *SecurityTestSuite) TestPatternValidation(validator func(string) error, patterns []string, testName string) []SecurityTestResult
TestPatternValidation tests that validation functions properly reject malicious patterns
func (*SecurityTestSuite) TestURLInjection ΒΆ added in v0.0.2
func (s *SecurityTestSuite) TestURLInjection(validator func(string) error) []SecurityTestResult
TestURLInjection tests URL-based injection prevention
func (*SecurityTestSuite) TestUnicodeInjection ΒΆ added in v0.0.2
func (s *SecurityTestSuite) TestUnicodeInjection(validator func(string) error) []SecurityTestResult
TestUnicodeInjection tests Unicode and encoding-based attacks
type SystemGPGVerifier ΒΆ
type SystemGPGVerifier struct {
// contains filtered or unexported fields
}
SystemGPGVerifier uses system GPG for verification (fallback)
func NewSystemGPGVerifier ΒΆ
func NewSystemGPGVerifier() (*SystemGPGVerifier, error)
NewSystemGPGVerifier creates a GPG verifier using system gpg command
func (*SystemGPGVerifier) ImportPublicKey ΒΆ
func (v *SystemGPGVerifier) ImportPublicKey(keyPath string) error
ImportPublicKey imports a public key using system GPG
func (*SystemGPGVerifier) VerifyDetachedSignature ΒΆ
func (v *SystemGPGVerifier) VerifyDetachedSignature(filePath, signaturePath string) error
VerifyDetachedSignature verifies a detached signature using system GPG
type TestResultSummary ΒΆ added in v0.0.2
type TestResultSummary struct {
TotalTests int
PassedTests int
FailedTests int
FailedPatterns []string
PassRate float64
}
TestResultSummary provides a summary of security test results
func SummarizeResults ΒΆ added in v0.0.2
func SummarizeResults(results []SecurityTestResult) TestResultSummary
SummarizeResults creates a summary of security test results
type TimeoutConfig ΒΆ added in v0.0.2
type TimeoutConfig struct {
// Default timeout for all operations
Default time.Duration `json:"default"`
// Install operation timeout
Install time.Duration `json:"install"`
// Update operation timeout
Update time.Duration `json:"update"`
// Upgrade operation timeout
Upgrade time.Duration `json:"upgrade"`
// Search operation timeout
Search time.Duration `json:"search"`
// Network operation timeout
Network time.Duration `json:"network"`
// Build operation timeout
Build time.Duration `json:"build"`
// Shell command timeout
Shell time.Duration `json:"shell"`
}
TimeoutConfig represents timeout configuration for different operation types
func DefaultTimeouts ΒΆ added in v0.0.2
func DefaultTimeouts() TimeoutConfig
DefaultTimeouts provides sensible default timeout values
func TimeoutConfigFromDefaults ΒΆ added in v0.0.2
func TimeoutConfigFromDefaults(overrides map[string]time.Duration) TimeoutConfig
TimeoutConfigFromDefaults creates a timeout config with specific overrides
func (TimeoutConfig) GetTimeout ΒΆ added in v0.0.2
func (tc TimeoutConfig) GetTimeout(operationType string) time.Duration
GetTimeout returns the appropriate timeout for an operation type
type TimeoutError ΒΆ added in v0.0.2
TimeoutError represents a command execution timeout error
func GetTimeoutError ΒΆ added in v0.0.2
func GetTimeoutError(err error) *TimeoutError
GetTimeoutError extracts TimeoutError from error chain
func (*TimeoutError) Error ΒΆ added in v0.0.2
func (e *TimeoutError) Error() string
type UpdateCallback ΒΆ
type UpdateCallback func(status UpdateStatus)
UpdateCallback is called when plugin updates occur
type UpdateStatus ΒΆ
type UpdateStatus struct {
PluginName string
Success bool
Error error
OldVersion string
NewVersion string
UpdatedAt time.Time
}
UpdateStatus represents the status of a plugin update
type UpdaterConfig ΒΆ
type UpdaterConfig struct {
Enabled bool `json:"enabled"`
UpdateInterval string `json:"update_interval"` // e.g., "24h", "12h"
AutoApplyUpdates bool `json:"auto_apply_updates"`
NotifyOnUpdates bool `json:"notify_on_updates"`
QuietMode bool `json:"quiet_mode"`
}
UpdaterConfig represents configuration for the background updater