Help us shape the future of Go! Take the 2026 Go Developer Survey

plugin

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxInstallBytes bounds the total payload copied from an install source.
	MaxInstallBytes = 8 << 20
	// MaxInstallFiles bounds the number of entries copied from an install source.
	MaxInstallFiles = 128
)
View Source
const (
	ManifestFile   = "manifest.json"
	SchemaVersion  = "sshx.dev/plugin/v1"
	ObservationV1  = "sshx.observation/v1"
	LockFile       = "plugin-lock.json"
	MaxManifest    = 1 << 20
	MaxSchema      = 2 << 20
	MaxCollector   = 2 << 20
	MaxFixture     = 10 << 20
	DefaultTimeout = 30 * time.Second
)
View Source
const MaxObservation = 10 << 20

Variables

This section is empty.

Functions

func CacheReusable

func CacheReusable(observation Observation, resolved *Resolved, target TargetRef, privilege, parameters string, now time.Time, maxAge time.Duration) (bool, bool, string)

func CurrentPlatform

func CurrentPlatform() string

func FixturePath

func FixturePath(resolved *Resolved, fixture string) (string, error)

func Path

func Path(id string) (string, error)

func Remove

func Remove(id string) (string, error)

func Root

func Root() (string, error)

func SupportsPlatform

func SupportsPlatform(platforms []string, target string) bool

func Test

func Test(id, fixture string) (*Resolved, Result, string, error)

func ValidateID

func ValidateID(id string) error

Types

type ActionResult

type ActionResult struct {
	Success     bool      `json:"success"`
	Action      string    `json:"action"`
	PluginID    string    `json:"plugin_id,omitempty"`
	Path        string    `json:"path,omitempty"`
	Builtin     bool      `json:"builtin,omitempty"`
	PluginRoot  string    `json:"plugin_root,omitempty"`
	Source      string    `json:"source,omitempty"`
	BackupPath  string    `json:"backup_path,omitempty"`
	Digest      string    `json:"digest,omitempty"`
	Trusted     bool      `json:"trusted,omitempty"`
	Valid       bool      `json:"valid,omitempty"`
	Files       []string  `json:"files,omitempty"`
	Plugins     []Summary `json:"plugins,omitempty"`
	Plugin      *Summary  `json:"plugin,omitempty"`
	Manifest    *Manifest `json:"manifest,omitempty"`
	TestResult  *Result   `json:"test_result,omitempty"`
	Fixture     string    `json:"fixture,omitempty"`
	NextActions []string  `json:"next_actions,omitempty"`
	ErrorKind   string    `json:"error_kind,omitempty"`
	Error       string    `json:"error,omitempty"`
}

type CachePolicy

type CachePolicy struct {
	RecommendedTTL string `json:"recommended_ttl"`
	HardMaxAge     string `json:"hard_max_age"`
}

type CacheState

type CacheState struct {
	Mode       string `json:"mode"`
	Hit        bool   `json:"hit"`
	Stale      bool   `json:"stale"`
	AgeSeconds int64  `json:"age_seconds,omitempty"`
}

type CapabilityRef

type CapabilityRef struct {
	ID      string `json:"id"`
	Version string `json:"version"`
	Digest  string `json:"digest"`
	Builtin bool   `json:"builtin"`
}

type CreateOptions

type CreateOptions struct {
	ID        string
	Runner    string
	Platform  string
	Privilege string
	Template  string
	Replace   bool
}

type CreateResult

type CreateResult struct {
	Resolved   *Resolved
	Files      []string
	BackupPath string
}

func Create

func Create(options CreateOptions) (*CreateResult, error)

type Evidence

type Evidence struct {
	Kind   string `json:"kind"`
	Source string `json:"source"`
}

type InstallOptions added in v0.18.0

type InstallOptions struct {
	Source  string // local directory that holds the plugin
	Replace bool   // preserve an existing plugin as a backup (--replace)
	Trust   bool   // trust the installed digest in the same step (--trust)
}

InstallOptions configures `sshx plugin install`.

type InstallResult added in v0.18.0

type InstallResult struct {
	Resolved   *Resolved
	Files      []string
	BackupPath string
}

InstallResult reports the published plugin.

func Install added in v0.18.0

func Install(options InstallOptions) (*InstallResult, error)

Install publishes a local plugin directory into the runtime plugin root ($SSHX_HOME/plugins/<id>). The source is staged with sshx's own restrictive modes, validated through the same loader the executor uses, and only then published, so an invalid source can never replace an installed plugin. --trust records the published digest in the local trust lock in the same step.

This is the audited alternative to hand-placing files under the plugin root: it is one CLI invocation, it refuses symlinks and non-regular files, and it is bounded by MaxInstallBytes/MaxInstallFiles.

type Lock

type Lock struct {
	Version int                  `json:"version"`
	Plugins map[string]LockEntry `json:"plugins"`
}

type LockEntry

type LockEntry struct {
	Digest    string    `json:"digest"`
	TrustedAt time.Time `json:"trusted_at"`
}

type Manifest

type Manifest struct {
	APIVersion       string          `json:"api_version"`
	ID               string          `json:"id"`
	Version          string          `json:"version"`
	Kind             string          `json:"kind"`
	Description      string          `json:"description,omitempty"`
	Platforms        []string        `json:"platforms"`
	Runner           Runner          `json:"runner"`
	RequiredCommands []string        `json:"required_commands,omitempty"`
	Privilege        string          `json:"privilege"`
	Timeout          string          `json:"timeout"`
	Effects          []string        `json:"effects"`
	Output           OutputContract  `json:"output"`
	Cache            CachePolicy     `json:"cache"`
	Redaction        RedactionPolicy `json:"redaction"`
}

type Observation

type Observation struct {
	Schema      string         `json:"schema"`
	Capability  CapabilityRef  `json:"capability"`
	Target      TargetRef      `json:"target"`
	CollectedAt time.Time      `json:"collected_at"`
	ExpiresAt   time.Time      `json:"expires_at"`
	Status      string         `json:"status"`
	Privilege   string         `json:"privilege"`
	Parameters  string         `json:"parameters_digest"`
	Cache       CacheState     `json:"cache"`
	Facts       map[string]any `json:"facts"`
	Evidence    []Evidence     `json:"evidence"`
	Errors      []ResultError  `json:"errors"`
	Redaction   []string       `json:"redacted_fields,omitempty"`
}

func DecodeObservation

func DecodeObservation(data []byte) (Observation, error)

type OutputContract

type OutputContract struct {
	Schema string `json:"schema"`
}

type RedactionPolicy

type RedactionPolicy struct {
	DenyFields []string `json:"deny_fields,omitempty"`
}

type Resolved

type Resolved struct {
	Manifest  Manifest `json:"manifest"`
	Path      string   `json:"path"`
	Digest    string   `json:"digest"`
	Trusted   bool     `json:"trusted"`
	Builtin   bool     `json:"builtin"`
	Collector []byte   `json:"-"`
	Schema    any      `json:"-"`
}

func Resolve

func Resolve(id string) (*Resolved, error)

func Trust

func Trust(id string) (*Resolved, error)

type Result

type Result struct {
	Status   string         `json:"status"`
	Facts    map[string]any `json:"facts"`
	Evidence []Evidence     `json:"evidence"`
	Errors   []ResultError  `json:"errors"`
}

func RedactResult

func RedactResult(result Result, policy RedactionPolicy) (Result, []string)

func ValidateResult

func ValidateResult(resolved *Resolved, data []byte) (Result, error)

type ResultError

type ResultError struct {
	Kind    string `json:"kind"`
	Section string `json:"section,omitempty"`
	Message string `json:"message,omitempty"`
}

type Runner

type Runner struct {
	Type       string `json:"type"`
	Entrypoint string `json:"entrypoint"`
}

type Summary

type Summary struct {
	ID          string `json:"id"`
	Version     string `json:"version,omitempty"`
	Description string `json:"description,omitempty"`
	Path        string `json:"path"`
	Digest      string `json:"digest,omitempty"`
	Trusted     bool   `json:"trusted"`
	Builtin     bool   `json:"builtin"`
	Valid       bool   `json:"valid"`
	ErrorKind   string `json:"error_kind,omitempty"`
	Error       string `json:"error,omitempty"`
}

func BuiltinSummaries

func BuiltinSummaries() []Summary

func List

func List() ([]Summary, error)

func SummaryFromResolved

func SummaryFromResolved(resolved *Resolved) Summary

type TargetRef

type TargetRef struct {
	Host               string `json:"host"`
	Port               string `json:"port"`
	User               string `json:"user"`
	UID                string `json:"uid,omitempty"`
	HostKeyFingerprint string `json:"host_key_fingerprint"`
	Platform           string `json:"platform"`
	BootID             string `json:"boot_id,omitempty"`
}

Jump to

Keyboard shortcuts

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