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

backend

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Overview

Package backend is lockfile on lockkit's console: the Backend that connects a profile's source, validates and shows plans for approval, runs the approved ones and returns only the closed result of docs/security-model.md.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sanitizer

func Sanitizer() *sanitize.Sanitizer

Sanitizer returns lockfile's sanitizer: lockkit's, with the patterns of the S3 and SFTP clients and the OS.

Types

type Backend

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

Backend implements console.Backend for one profile.

func New

func New(o Options) (*Backend, error)

New prepares the backend: plugin store, workspace (its orphans swept), runner. Close removes the workspace.

func (*Backend) Checks

func (b *Backend) Checks(ctx context.Context, s console.Session) []console.Finding

Checks implements console.Backend: no sandbox, no console.

func (*Backend) Close

func (b *Backend) Close() error

Close stops the expiry loop and removes every fetched file.

func (*Backend) Connect

Connect implements console.Backend.

func (*Backend) LoadPolicy

func (b *Backend) LoadPolicy() (console.Policy, error)

LoadPolicy implements console.Backend.

func (*Backend) Methods

func (b *Backend) Methods() map[string]console.Handler

Methods implements console.Backend.

func (*Backend) OnHub added in v0.5.0

func (b *Backend) OnHub(h *console.Hub)

OnHub is console.Options.OnHub: the console's hub, before any request, gets the recompute, so a renewal asked from the hub right after a start is checked too.

func (*Backend) Sanitizer added in v0.3.0

func (b *Backend) Sanitizer() *sanitize.Sanitizer

Sanitizer is the backend's sanitizer, for console.Options: the profile values join it as policies are loaded and sources connected.

func (*Backend) Status

func (b *Backend) Status(console.Session) any

Status implements console.Backend.

type Options

type Options struct {
	// ConfigPath is the config file; Profile the profile served.
	ConfigPath string
	Profile    string
	// StateDir is lockkit's state base (kit.StateBase() when empty): the
	// approved policy, the audit log, and by default the plugins and the
	// workspace live under <StateDir>/lockfile.
	StateDir string
	// PluginDir and WorkDir override the defaults (tests).
	PluginDir, WorkDir string
	// Run replaces sandbox.Run, Probe sandbox.Probe (tests).
	Run   func(context.Context, sandbox.Spec) (pluginspec.Outcome, sandbox.Report, error)
	Probe func() (int, bool, error)
	// ProcHidden replaces procmount.CheckSystem: nil when /proc hides the
	// plugins' processes from other accounts. Set only by tests (CI
	// runners do not mount /proc with hidepid); no flag or config reaches
	// it.
	ProcHidden func() error
	Now        func() time.Time
	// ExpireEvery is how often expired handles are removed (30 s).
	ExpireEvery time.Duration
}

Options configure a Backend.

type Record

type Record struct {
	audit.Base
	PlanID       string   `json:"plan_id,omitempty"`
	Handle       string   `json:"handle,omitempty"`
	Key          string   `json:"key,omitempty"`
	Plugins      []string `json:"plugins,omitempty"`
	Size         int64    `json:"size,omitempty"`
	SHA256       string   `json:"sha256,omitempty"`
	FetchCause   string   `json:"fetch_cause,omitempty"`
	Plugin       string   `json:"plugin,omitempty"`
	Version      string   `json:"version,omitempty"`
	BinarySHA256 string   `json:"binary_sha256,omitempty"`
	Result       *int     `json:"result,omitempty"`
	Cause        string   `json:"cause,omitempty"`
	ConsoleError string   `json:"console_error,omitempty"`
	ExitCode     int      `json:"exit_code,omitempty"`
	Signal       string   `json:"signal,omitempty"`
	StderrBytes  int64    `json:"stderr_bytes,omitempty"`
	DurationMS   int64    `json:"duration_ms,omitempty"`
}

Record is lockfile's audit record: lockkit's base fields and the plan's. The audit file is the lockfile account's (0600): the one place where file metadata (key, size, sha256, failure causes) is kept (docs/security-model.md, "Data at rest"). Never file bytes; error text is sanitized first.

Jump to

Keyboard shortcuts

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